Repository navigation
Conversation
…alias AgentTool validated the model's arguments by alias but dumped them to JSON by field name. The agent's node then re-validated that JSON against the same schema and raised a ValidationError, failing the whole run when the input_schema used aliases (for example alias_generator=to_camel).
8 of 9 tasks
copybara-service Bot
pushed a commit
that referenced
this pull request
Nov 6, 2026
Merge #7764 AgentTool validates the call's args against the wrapped agent's input_schema, then sends the validated model as JSON to that agent, whose node runtime validates it again. That JSON is keyed by field name, so the second validation rejected it for any field read through an alias. Node input and output validation now also accepts field names, so the JSON validates again for validation_alias, alias_generator, AliasPath and nested schemas. That JSON is also keyed by field name when the schema sets serialize_by_alias. Data a node validates against a schema is now accepted by field name even when the schema reads that field only through an alias or sets validate_by_name=False. The JSON AgentTool sends still leaves out every field whose value is None, as before. PiperOrigin-RevId: 1015265843
Collaborator
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.
Link to Issue or Description of Change
2. Or, if no issue exists, describe the change:
Problem:
When an agent wrapped in
AgentToolhas aninput_schemawhose fields use aliases (for examplealias_generator=to_camelorField(alias=...)), the whole run fails with aValidationErrorand the agent never runs.AgentTool.run_asyncvalidates the model's arguments by alias, then dumps them withmodel_dump_json(exclude_none=True), which writes field names. The agent's node then validates that JSON again against the same schema, and that schema expects the aliases:The function declaration the model sees already uses the aliases (
cityName), so the model sends the right keys. Only the dump in between is wrong.Solution:
Dump with
by_alias=True, so the JSON uses the same keys the schema validates. Schemas without aliases produce the same output as before.One trade-off I checked: a field with only a
serialization_alias(and no validation alias) would now be dumped under a name the validator does not accept. That seems unusual for an input schema, since it only renames output. Another option would be to forward the originalargsinstead of re-dumping. I did not do that because the agent would then no longer get defaults filled in orNonevalues dropped. Happy to switch if you prefer that.Testing Plan
Unit Tests:
Added
test_input_schema_with_aliasesintests/unittests/tools/test_agent_tool.py. It fails on main with theValidationErrorabove and passes with the fix.tests/unittests/tools/test_agent_tool.py: 74 passedtests/unittests/tools,agents,workflow,flows: all passed except 7 bash/symlink tests (test_skill_toolset.pyintegration shell tests,test_tool_node.py::test_execute_bash_tool_node_runs_command_after_approval). Those also fail on unmodified main on my machine because Windows has no/bin/bash.Manual End-to-End (E2E) Tests:
Parent agent with a
MockModelthat calls the wrapped agent with{"cityName": "Paris"}, child agent with an aliasedinput_schema:Before:
After:
Checklist