Repository navigation
Conversation
Join answer text without separators before schema validation. Treat whitespace-only structured replies as empty and preserve code output for schema-less callers.
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
This is the Python follow-up to google/adk-go#2468. Thanks to baptmont for requesting the matching Python fix. #5481 provides context for keeping code output in plain-text replies.
Problem
AgentTool can pass executable code and execution output to the JSON validator. It also inserts newlines between text parts, which breaks a JSON token split across two parts.
Solution
For agents with an output schema, join non-thought text parts in order without a separator before validation. A reply with no non-whitespace answer text uses the existing empty-result or error-message convention. Schema-less replies still include code and execution output in their newline-separated text.
Testing Plan
pytest -q tests/unittests/tools/test_agent_tool.py tests/unittests/utils/test_schema_utils.pypassed on Python 3.11, 3.12, 3.13, and 3.14 with 186 tests per version.toxmatrix was started locally on Windows and is still running.End-to-end reproduction
Run
pytest -q tests/unittests/tools/test_agent_tool.py -k test_agent_tool_output_parts. A real parent runner calls AgentTool, which runs a nested LlmAgent using scripted model replies. The test checks the function response received by the parent and requires no model credentials.Checklist
OpenAI Codex assisted with implementation, testing, and preparation of this pull request.