fix: wrap call_service_tool response in dict to fix Pydantic validation#36
Open
brianegge wants to merge 1 commit intovoska:masterfrom
Open
fix: wrap call_service_tool response in dict to fix Pydantic validation#36brianegge wants to merge 1 commit intovoska:masterfrom
brianegge wants to merge 1 commit intovoska:masterfrom
Conversation
The Home Assistant API returns a list of affected entity states for service calls, but call_service_tool was passing this list directly as its return value. Since the function's return type is Dict[str, Any], this caused Pydantic validation errors when calling services like automation.reload that return empty lists. Changes: - Fix call_service return type annotation in hass.py to List[Dict[str, Any]] - Wrap call_service_tool result in a dict with success, domain, service, and affected_entities fields - Add regression tests for the fix Fixes voska#29 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #29
The Home Assistant API returns a list of affected entity states for service calls (e.g.,
[]forautomation.reload), butcall_service_toolwas passing this list directly as its return value. Since the function's return type annotation isDict[str, Any], this caused Pydantic validation errors:Changes
call_servicereturn type annotation fromDict[str, Any]toList[Dict[str, Any]]to reflect actual HA API behaviorcall_service_toolresult in a dict withsuccess,domain,service, andaffected_entitiesfieldsNew Response Format
Before:
[] # Raw list from HA API - causes validation errorAfter:
{ "success": True, "domain": "automation", "service": "reload", "affected_entities": [] }Test Plan
test_call_service_tool_returns_dict- verifies the tool always returns a dicttest_call_service_tool_with_data- verifies data is passed correctly🤖 Generated with Claude Code