fix(tools): add fallback to code_execution_result.output in AgentTool.run_async when text parts are empty#5496
Open
ilyesJammouci wants to merge 3 commits intogoogle:mainfrom
Conversation
Collaborator
|
Response from ADK Triaging Agent Hello @ilyesJammouci, thank you for creating this PR! To help reviewers verify the fix, could you please provide a manual end-to-end (E2E) test as described in our contribution guidelines? This could be a screenshot from This information will help reviewers to review your PR more efficiently. Thanks! |
Collaborator
|
Hi @ilyesJammouci , Thank you for your contribution! We appreciate you taking the time to submit this pull request. Can you please fix the failing test before we can proceed with the review. |
Author
|
Hi @rohityan, thank you for the feedback! I've fixed the failing test. Please let me know if anything else needs to be addressed. |
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.
Fixes #5481
Summary
AgentToolcurrently extracts tool output from text parts only.When an inner agent finishes with
code_execution_resultparts and no text part,AgentToolreturns an empty result string to the parent agent.This causes silent output loss and prevents parent-level recovery logic.
Changes
Updated
agent_tool.pyinAgentTool.run_async:code_execution_resultpartsBefore
After
code_execution_result.outputBig thanks to @Number531 for the clear bug report and for proposing the fix
Motivation
In multi-agent workflows using
AgentToolwith code execution, inner model responses may contain:executable_codecode_execution_result without a textual summary.Returning an empty result in this case drops valid computation output and can derail long-running optimization or orchestration flows.
This change makes
AgentToolrobust to that response shape and avoids silent failures.Test Plan
Manual E2E verification
Reproduced the issue with the local runner flow:
Before the fix
code_execution_resultpartsAfter the fix
code_execution_result.outputfor the same response shapeUnit tests
test_agent_tool.py:test_run_async_uses_code_execution_result_output_when_no_text