Media in a tool result (FunctionResponse.parts) is dropped when another agent's turn is relayed as context
维护者通常 3 天内回复
评估
这个 Issue 还没有评估数据。
描述
🔴 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 @ c74df83c0)
- 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.
- 主要语言
- Python
- 星标
- 22.3k
- 派生
- 4.4k
- 平均合并
- 1 天 2 小时
- 30 天内合并 PR
- 6
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
google/adk-python 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
google/adk-python#8360 ·
维护者通常 3 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
google/adk-python#8359 ·
维护者通常 3 天内回复
-
Can pin to litellm version be changed?可能已有人在做 @llalitkumarrr 于 10 天前认领。 未关闭models
难度 1/5 1 小时以内 新手友好度 65/100
google/adk-python#8129 · 2 条评论 · 已指派 1 人 ·
维护者通常 3 天内回复
-
OpenAPI tools ignore operation- and path-level server overrides可能已有人在做 @sanketpatil06 于 14 天前认领。 未关闭tools
难度 2/5 1-3 小时 新手友好度 75/100
google/adk-python#8064 · 4 条评论 · 已指派 1 人 ·
维护者通常 3 天内回复
-
Two docstrings in openapi_tool document parameters the signatures do not accept可能已有人在做 @surajksharma07 于 17 天前认领。 未关闭
难度 1/5 1 小时以内 新手友好度 88/100
google/adk-python#8024 · 1 条评论 · 已指派 1 人 ·
维护者通常 3 天内回复
查看 google/adk-python 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
vllm-project/vllm#70030 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
TigreGotico/tugaphone#408 ·
维护者通常 1 天内回复
-
t: bug
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 3 天内回复
-
needs-triage
难度 1/5 1 小时以内 新手友好度 85/100
Azure/azure-sdk-for-python#50155 · 1 个 reaction ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 66/100
维护者通常 1 天内回复