Skip to content

Commit e12d997

Browse files
harcheclaude
andcommitted
tighten comment and add test for raw dict schema
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent b6ec1ca commit e12d997

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

src/google/adk/tools/set_model_response_tool.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,7 @@ def set_model_response() -> str:
8888
)
8989
]
9090
elif isinstance(output_schema, dict):
91-
# Raw dict schema instance — use `dict` type as annotation, not the
92-
# instance itself, because dict instances are unhashable and break
93-
# _is_builtin_primitive_or_compound's `annotation in ...` check.
91+
# Use `dict` type, not the instance — dict instances are unhashable.
9492
params = [
9593
inspect.Parameter(
9694
'response',

tests/unittests/tools/test_set_model_response_tool.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,3 +467,18 @@ async def test_run_async_dict_schema():
467467
assert result is not None
468468
assert isinstance(result, dict)
469469
assert result == {'a': 1, 'b': 2, 'c': 3}
470+
471+
472+
def test_tool_initialization_raw_dict_instance():
473+
"""Test tool initialization with a raw dict schema instance."""
474+
raw_schema = {'type': 'object', 'properties': {'name': {'type': 'string'}}}
475+
tool = SetModelResponseTool(raw_schema)
476+
477+
assert tool.output_schema == raw_schema
478+
assert not tool._is_basemodel
479+
assert not tool._is_list_of_basemodel
480+
481+
sig = inspect.signature(tool.func)
482+
assert 'response' in sig.parameters
483+
assert len(sig.parameters) == 1
484+
assert sig.parameters['response'].annotation is dict

0 commit comments

Comments
 (0)