You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
validate_schema skips validation for non-BaseModel schemas (list[str], dict[…], raw JSON Schema) #7280
validate_schema (google/adk/utils/_schema_utils.py) and SchemaType advertise support for list[str], list[int], dict[str, T], raw dict JSON schemas, and types.Schema.
Only BaseModel / list[BaseModel] go through Pydantic. The else branch is a bare safe_json_loads — noTypeAdapter / jsonschema check — so invalid values are silently accepted into session state / tool results.
Raw JSON Schema requiring string a + '{"a": 1}' → {'a': 1}
BaseModel path still raises ValidationError (control OK)
Expected
Non-BaseModel schemas should be validated (e.g. TypeAdapter(schema).validate_json(...) for GenericAlias types; jsonschema for raw dict / types.Schema), or unsupported types should fail loudly — not silently accept invalid values.
Impact
Agents with output_schema=list[str] (etc.) + output_key write invalid values into session state. AgentTool returns unvalidated payloads to the parent. Downstream agents/tools treat garbage as schema-valid.
Suggested fix
For GenericAlias / non-dict schema types, use TypeAdapter(schema).validate_json(json_text) (same as list[BaseModel]). For raw dict / types.Schema JSON schemas, validate with jsonschema (already a dependency) or reject unsupported types loudly.
Notes
Nearby #5054 (output_schema=str + tools loop) and #6747 (python-mode dump) are different root causes. Happy to open a PR.
Picking this one up now — opening a PR shortly. Flagging it here so nobody duplicates the work; if someone is already on it, say so and I will drop mine.
Thanks for picking this up so quickly — and for the PRs (#7285 / #7284 / #7283). Happy to review or clarify anything from the original repros if useful.
Your observations in this report are correct validation is being skipped which may cause issues for agents with an output_schema. The linked PR addresses this concern but it requires an in-depth review. We appreciate your patience while the reviewer examines it.
Additionally if you could share your observations on the PR, that would be a great help.
Looked at #7285. Routing generic aliases through TypeAdapter, and dict / types.Schema through jsonschema, matches the report. The new tests cover the list[str] and dict[str, int] rejections, plus raw JSON Schema and types.Schema.
Callers that only catch pydantic's ValidationError will still miss jsonschema.ValidationError on the dict and types.Schema path, so it may be worth wrapping those into one error type. I reviewed the diff only and have not run the suite.
Follow-up after running the tests. On #7285 (8dff62f), test_schema_utils.py passed 71 tests.
The split is real. list[str] and dict[str, int] raise pydantic's ValidationError. A raw JSON Schema dict and a types.Schema raise jsonschema.ValidationError for the same kind of bad value.
Activity
chelsealong commentedon Sep 25, 2026
Picking this one up now — opening a PR shortly. Flagging it here so nobody duplicates the work; if someone is already on it, say so and I will drop mine.
michaelkillgta commentedon Sep 25, 2026
Thanks for picking this up so quickly — and for the PRs (#7285 / #7284 / #7283). Happy to review or clarify anything from the original repros if useful.
llalitkumarrr commentedon Sep 29, 2026
Hello @michaelkillgta,
Your observations in this report are correct validation is being skipped which may cause issues for agents with an
output_schema. The linked PR addresses this concern but it requires an in-depth review. We appreciate your patience while the reviewer examines it.Additionally if you could share your observations on the PR, that would be a great help.
michaelkillgta commentedon Sep 30, 2026
Looked at #7285. Routing generic aliases through TypeAdapter, and dict /
types.Schemathrough jsonschema, matches the report. The new tests cover thelist[str]anddict[str, int]rejections, plus raw JSON Schema andtypes.Schema.Callers that only catch pydantic's ValidationError will still miss
jsonschema.ValidationErroron the dict andtypes.Schemapath, so it may be worth wrapping those into one error type. I reviewed the diff only and have not run the suite.michaelkillgta commentedon Sep 30, 2026
Follow-up after running the tests. On #7285 (
8dff62f),test_schema_utils.pypassed 71 tests.The split is real.
list[str]anddict[str, int]raise pydantic'sValidationError. A raw JSON Schema dict and atypes.Schemaraisejsonschema.ValidationErrorfor the same kind of bad value.