Repository navigation
Description
🔴 Required Information
Describe the Bug:
When a tool returns media (an image, audio or a document as a types.Part), ADK moves it into FunctionResponse.parts and leaves the JSON response without it (_extract_multimodal_parts in flows/llm_flows/tools/_caller.py). ComputerUseTool screenshots go through the same path.
When another agent later reads that event as context, _present_other_agent_message (flows/llm_flows/context/_fencing.py) renders the tool result as text with str(part.function_response.response) and never looks at function_response.parts. The media is lost. If the tool returned only media, the next agent sees an empty result:
[analyst_agent] `render_chart` tool returned result:
<<<BEGIN_QUOTED_AGENT_CONTENT>>>
{}
<<<END_QUOTED_AGENT_CONTENT>>>
So the receiving agent is told the tool returned nothing. The agent that called the tool still has the media in its own history. The same function already passes media through on its own part type for ordinary inline_data and file_data parts. Tool-result media is the case it misses.
Steps to Reproduce:
pip install google-adk- Run this script. It needs no API key and uses the same functions ADK uses to build the tool result and relay it:
from google.genai import types
from google.adk.events.event import Event
from google.adk.flows.llm_flows.context._fencing import _present_other_agent_message
from google.adk.flows.llm_flows.tools._caller import _build_function_response_content
from google.adk.tools.function_tool import FunctionTool
def render_chart(metric: str):
"""Renders a chart for a metric."""
return types.Part.from_bytes(data=b"\x89PNG fake chart", mime_type="image/png")
tool = FunctionTool(render_chart)
content = _build_function_response_content(tool, render_chart("sales"), "call-1")
fr = content.parts[0].function_response
print("caller's history:", fr.response, "| media parts:", len(fr.parts or []))
relayed = _present_other_agent_message(Event(author="analyst_agent", content=content))
print("next agent sees:", relayed.content.parts[-1].text)
print("media reaches next agent:", any(p.inline_data or p.file_data for p in relayed.content.parts))In a real app this happens in any multi-agent setup where one agent calls a media-returning tool and another agent runs later in the same session, for example after transfer_to_agent or in a sequential pipeline.
Expected Behavior:
The relayed context includes the tool's media as its own parts, next to the fenced text of the JSON result, the same way media in ordinary message parts is relayed.
Observed Behavior:
caller's history: {} | media parts: 1
next agent sees: [analyst_agent] `render_chart` tool returned result:
<<<BEGIN_QUOTED_AGENT_CONTENT>>>
{}
<<<END_QUOTED_AGENT_CONTENT>>>
media reaches next agent: False
Environment Details:
- ADK Library Version: 2.14.1 (main @ c74df83)
- Desktop OS: Windows 11 (the bug isn't OS-specific)
- Python Version: 3.11
Model Information:
- Are you using LiteLLM: No
- Which model is being used: N/A (the context is built before any model call). This affects any model that receives the relayed history.
🟡 Optional Information
Regression:
Not that I know of. Related to #729, which reported image parts being lost at the AgentTool boundary.
Proposed fix:
In the function_response branch of _present_other_agent_message, after the fenced text part, add each entry of function_response.parts as its own part: inline_data becomes a types.Part(inline_data=...) and file_data becomes a types.Part(file_data=...). Run them through _elide_relayed_part_markers, as the existing media branch does, so text/* blobs can't forge quote markers. Add regression tests for a media-only result, a mixed JSON-and-media result, and a text/* blob containing a marker. I'm happy to send a PR.
Activity