Interactions: stateless replay of an `mcp_server_tool_result` whose `structured_content` holds a `$ref` returns 400
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
Start by tracing how the SDK models and serializes mcp_server_tool_result steps for stateless Interactions API requests; the issue does not name specific files or tests. Compare the returned structured_content reference with the replayed function response, then add a regression test using the reproduction shape. Done means replaying the emitted steps succeeds when structured_content contains a $ref.
由索引模型根据 Issue 内容生成。
描述
This issue was posted by Claude Code using claude-opus-5-5 on behalf of David.
Interactions API rejects its own mcp_server_tool_result step on stateless replay when structured_content contains a $ref.
With store: false, sending back the steps a previous interaction returned fails with HTTP 400 when an MCP image result came from a server that also sets structuredContent:
400 {"error":{"message":"The referenced name `structured_content.result[0]` in function_response.response does not match to a display_name in the function_response.parts.","code":"invalid_request"}}
The step is exactly what the API emitted. Image results without structured_content, and audio and embedded-resource results, replay fine (200).
Reproduce (raw HTTP, no SDK)
-
Run a public MCP server with a tool returning an
ImageContentblock and matchingstructuredContent. FastMCP does this for a tool annotated-> list[ImageContent]:from mcp.server.fastmcp import FastMCP from mcp.types import ImageContent PNG = 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR4nGNg+M/A8B8ABf4C/gzLSmsAAAAASUVORK5CYII=' mcp = FastMCP('probe', stateless_http=True) @mcp.tool() def get_image() -> list[ImageContent]: return [ImageContent(type='image', data=PNG, mimeType='image/png')] mcp.run(transport='streamable-http') -
POST /v1beta/interactionswithmodel: gemini-3.8-flash,store: false,tools: [{"type": "mcp_server", "name": "probe", "url": "<server>/mcp"}], and auser_inputasking it to callget_image. The response contains:{"type": "mcp_server_tool_result", "call_id": "...", "signature": "...", "name": "probe:get_image", "server_name": "probe", "result": {"call_tool_result_json": "{\"content\":[{\"type\":\"image\",...}],\"structuredContent\":{...}}", "structured_content": {"result": [{"$ref": "structured_content.result[0]"}]}}} -
Send a second request whose
inputis the firstuser_input, every returned step unchanged, and a newuser_input. It returns the 400 above. Dropping only that tool's call and result steps returns 200.
Related: the live result shape differs from the reference and SDK types
- The API reference documents
mcp_server_tool_result.resultas(ImageContent or TextContent) array,objectorstring. Live results for text, image, audio and embedded-resource tools all arrive as an undocumented object:call_tool_result_json(the MCPCallToolResultas a JSON string), optionalstructured_content, a plain-textresult, and for blob resources a key named after the MIME type ("application/pdf": "<base64>"). MCPServerToolResultStepResultin this SDK is an empty model, so none of those fields are typed. The list branch types only text and image items; audio, video and document items parse asUnknownFunctionResultSubcontent.
Observed with google-genai 2.30.0 on the Gemini API (gemini-3.8-flash), November 2026.
- 主要语言
- Python
- 星标
- 4.1k
- 派生
- 1.1k
- 平均合并
- 1 天 21 小时
- 30 天内合并 PR
- 103
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
googleapis/python-genai 的其他 Issue
-
Test import module that doesn't exist可能已有人在做 @Venkaiahbabuneelam 于 24 天前认领。 未关闭priority: p2 type: bug
难度 2/5 1-3 小时 新手友好度 66/100
googleapis/python-genai#3122 · 6 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
Curated history keeps half a user turn when the model turn is invalid可能已有人在做 @Venkaiahbabuneelam 于 33 天前认领。 未关闭priority: p2 type: bug
难度 2/5 1-3 小时 新手友好度 62/100
googleapis/python-genai#3051 · 3 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
[Bug]: Unsubscripted typing.List and typing.Dict crash convert_if_exist_pydantic_model in AFC可能已有人在做 @Venkaiahbabuneelam 于 33 天前认领。 未关闭priority: p2 type: bug
难度 2/5 1-3 小时 新手友好度 82/100
googleapis/python-genai#3044 · 1 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 48/100
googleapis/python-genai#3314 ·
维护者通常 1 天内回复
-
SyntaxWarning on import in 3.0.0 (invalid escape sequence in types.py)可能已有人在做 @VISHNU0906 于 1 天前认领。 未关闭
难度 1/5 1 小时以内 新手友好度 35/100
googleapis/python-genai#3308 · 2 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
查看 googleapis/python-genai 的全部 Issue
相似的 Issue
-
ChatBedrockConverse changes the keys of JSON tool results to camelCase (`order_id` becomes `orderId`)可能已有人在做 @geyazheng 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
langchain-ai/langchain-aws#1469 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 88/100
维护者通常 1 天内回复
-
b4b usability
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
fix(schedule): align list_tasks since cursor filter boundary from strict > to >=可能已有人在做 @bfs2021 今天认领。 未关闭agent-ready bug p2 schedule
难度 2/5 1-3 小时 新手友好度 83/100
allenporter/supernote#540 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 76/100
frazane/scoringrules#164 ·
维护者通常 1 天内回复