fix: handle raw dict output_schema in SetModelResponseTool#5470
fix: handle raw dict output_schema in SetModelResponseTool#5470harche wants to merge 2 commits intogoogle:mainfrom
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
|
Response from ADK Triaging Agent Hello @harche, thank you for creating this PR! Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). You can visit https://cla.developers.google.com/ to see your current agreements or to sign a new one. This information will help reviewers to review your PR more efficiently. Thanks! |
When output_schema is a raw dict instance (e.g.,
{"type": "object", "properties": {...}}), SetModelResponseTool sets it
as the parameter annotation directly. This crashes in
_is_builtin_primitive_or_compound because dict instances are not
hashable and the check does `annotation in dict.keys()`.
Fix: add an explicit isinstance(output_schema, dict) branch that uses
`dict` (the type) as the annotation instead of the dict instance.
Fixes google#5469
6b9b9ef to
6e44f37
Compare
|
After testing this more, the The model sees "return any dict" with no field constraints — it ignores field names, types, required properties, and enum values from the original schema. In our evals the model returned completely different JSON structures that didn't match the schema at all. The deeper issue is that Closing this in favor of updating the issue with the full findings. |
Summary
TypeError: unhashable type: 'dict'when passing a rawdictinstance asoutput_schematoLlmAgentFixes #5469
Root Cause
SetModelResponseTool.__init__setsannotation=output_schema(the dict instance) as a function parameter annotation. Downstream,_is_builtin_primitive_or_compounddoesannotation in _py_builtin_type_to_schema_type.keys(), which tries to hash the dict instance and raisesTypeError.Fix
Add an
isinstance(output_schema, dict)branch that usesdict(the type, which is hashable and already in_py_builtin_type_to_schema_type) as the annotation instead of the dict instance.Test plan
test_tool_initialization_raw_dict_instancecovering the exact crash casetest_tool_initialization_dict_schema(usesdict[str, int]GenericAlias) still passes — no regression