Skip to content

Conversation

@cibernox
Copy link
Contributor

Note: This is bringing back from the death #151583 which was closed because the necessary changes to voluptuous were taking too long to get merged. Those are merged now and voluptuous supports anyOf constraints and thus this PR is finally possible.

Breaking change

Unsure, but I'd say no. This PR changes the OpenAPI definition of the HassLightSet intent to be more exhaustive, but that's not used directly by users.

Proposed change

While technically color, temperature and brightness are optional, al least one of those three must be provided, otherwise nothing is being set. I noticed this because my LLM was making tool calls HassLightSet without any argument, which is obviously wrong.

This should make the OpenAPI json schema generated by voluptuous_openapi express that at least one is required.

It does so by using required(anyOf(...)), which voluptuous_openapi already supports.
Hopefully this helps LLMs make less mistakes calling tools.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:
  • Link to developer documentation pull request:
  • Link to frontend pull request:

Checklist

  • I understand the code I am submitting and can explain how it works.
  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.
  • Any generated code has been carefully reviewed for correctness and compliance with project standards.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.

To help with the load of incoming pull requests:

Copilot AI review requested due to automatic review settings December 31, 2025 21:03
@cibernox cibernox requested a review from a team as a code owner December 31, 2025 21:03
@home-assistant
Copy link

Hey there @home-assistant/core, mind taking a look at this pull request as it has been labeled with an integration (light) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of light can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign light Removes the current integration label and assignees on the pull request, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the pull request.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the pull request.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves the HassLightSet intent definition to require at least one of three optional parameters (color, temperature, or brightness) using voluptuous's new anyOf constraint support. This prevents LLMs from making invalid tool calls with no arguments.

Key changes:

  • Upgrades voluptuous (0.15.2 → 0.16.0) and voluptuous-openapi (0.2.0 → 0.3.0) to support anyOf constraints
  • Adds required_slots with vol.Any("color", "temperature", "brightness") constraint to light intent handler
  • Enhances error messages to include voluptuous validation details for better debugging
  • Adds comprehensive tests for validation success and failure cases

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
homeassistant/components/light/intent.py Adds required_slots with vol.Any constraint to enforce that at least one of color, temperature, or brightness must be provided
homeassistant/helpers/intent.py Adds logic to skip vol.Any keys when building service data and improves error messages to include validation details
tests/components/light/test_intent.py Adds comprehensive tests for the new validation: one test verifying rejection when no required slots are provided, another verifying success when at least one is provided
requirements.txt Updates voluptuous to 0.16.0 and voluptuous-openapi to 0.3.0 to support anyOf constraints
pyproject.toml Updates dependency versions for voluptuous and voluptuous-openapi
homeassistant/package_constraints.txt Updates package constraints to match new dependency versions

Copy link
Contributor

@epenet epenet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update dependencies in a preliminary PR

@home-assistant
Copy link

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

@home-assistant home-assistant bot marked this pull request as draft December 31, 2025 21:33
cibernox added a commit to cibernox/core that referenced this pull request Dec 31, 2025
@cibernox
Copy link
Contributor Author

@epenet I created #160073 containing only the dependency updates.

Copy link
Contributor

@arturpragacz arturpragacz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR needs to be rebased and CI needs to pass.

…intent handling

This has been tested with the current state of the forked libraries, so once those are
merged this could be updated.
@cibernox cibernox force-pushed the support-anyof-validation branch from c675264 to a43cd62 Compare January 1, 2026 21:05
@cibernox cibernox marked this pull request as ready for review January 1, 2026 21:07
@cibernox
Copy link
Contributor Author

cibernox commented Jan 2, 2026

I think this is ready now. The failure in one specific version of python seems unrelated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants