fix(tools): add fallback to code_execution_result.output in AgentTool.run_async when text parts are empty#5496
Conversation
|
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! |
|
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. |
|
Hi @rohityan, thank you for the feedback! I've fixed the failing test. Please let me know if anything else needs to be addressed. |
|
Hi @Jacksunwei , can you please review this. |
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