fix: Antigravity 跨格式转换链 tool call ID 完整传递

修复通过 Antigravity 适配器发送请求到 Claude 模型时 tool_use 块缺少必需 id 字段的问题。

根本原因:在跨格式转换链 (Gemini → Internal → Claude/Gemini) 中,
functionCall 和 functionResponse 的 id 字段没有被正确传递。

修复内容:
- internal.py: ToolResultBlock 增加 tool_name 字段,区分工具名称和 call id
- gemini.py: 读取/输出 functionCall 和 functionResponse 时保留 id 字段
- gemini.py: 流式响应中正确传递 tool_id
- envelope.py: 同时支持 camelCase/snake_case 两种命名风格
This commit is contained in:
AAEE86
2026-02-10 02:50:45 +08:00
parent 9f5dd6f658
commit 5d36fd7f99
3 changed files with 60 additions and 28 deletions

View File

@@ -161,8 +161,8 @@ def _inject_claude_tool_ids_request(inner_request: dict[str, Any], model: str) -
if not isinstance(part, dict):
continue
# 1. functionCallAssistant 请求调用工具)
fc = part.get("functionCall")
# 1. functionCallAssistant 请求调用工具)- 支持 camelCase 和 snake_case
fc = part.get("functionCall") or part.get("function_call")
if isinstance(fc, dict) and fc.get("id") is None:
name = fc.get("name", "unknown")
if not isinstance(name, str):
@@ -171,8 +171,8 @@ def _inject_claude_tool_ids_request(inner_request: dict[str, Any], model: str) -
fc["id"] = f"call_{name}_{count}"
name_counters[name] = count + 1
# 2. functionResponseUser 回复工具结果)
fr = part.get("functionResponse")
# 2. functionResponseUser 回复工具结果)- 支持 camelCase 和 snake_case
fr = part.get("functionResponse") or part.get("function_response")
if isinstance(fr, dict) and fr.get("id") is None:
name = fr.get("name", "unknown")
if not isinstance(name, str):