Commit 81b865b8 authored by ianshaw's avatar ianshaw
Browse files

fix(antigravity): Claude 模型透传 tool_use 的 signature

- Vertex/Google API 需要完整签名链路
- Claude 模型不再清空 tool_use 的 signature
parent b0d41823
...@@ -240,10 +240,13 @@ func buildParts(content json.RawMessage, toolIDToName map[string]string, allowDu ...@@ -240,10 +240,13 @@ func buildParts(content json.RawMessage, toolIDToName map[string]string, allowDu
ID: block.ID, ID: block.ID,
}, },
} }
// 只有 Gemini 模型使用 dummy signature // tool_use 的 signature 处理:
// Claude 模型不设置 signature(避免验证问题) // - Gemini 模型:使用 dummy signature(跳过 thought_signature 校验)
// - Claude 模型:透传上游返回的真实 signature(Vertex/Google 需要完整签名链路)
if allowDummyThought { if allowDummyThought {
part.ThoughtSignature = dummyThoughtSignature part.ThoughtSignature = dummyThoughtSignature
} else if block.Signature != "" && block.Signature != dummyThoughtSignature {
part.ThoughtSignature = block.Signature
} }
parts = append(parts, part) parts = append(parts, part)
......
...@@ -103,7 +103,7 @@ func TestBuildParts_ToolUseSignatureHandling(t *testing.T) { ...@@ -103,7 +103,7 @@ func TestBuildParts_ToolUseSignatureHandling(t *testing.T) {
} }
}) })
t.Run("Claude model - no signature for tool_use", func(t *testing.T) { t.Run("Claude model - preserve valid signature for tool_use", func(t *testing.T) {
toolIDToName := make(map[string]string) toolIDToName := make(map[string]string)
parts, err := buildParts(json.RawMessage(content), toolIDToName, false) parts, err := buildParts(json.RawMessage(content), toolIDToName, false)
if err != nil { if err != nil {
...@@ -112,9 +112,9 @@ func TestBuildParts_ToolUseSignatureHandling(t *testing.T) { ...@@ -112,9 +112,9 @@ func TestBuildParts_ToolUseSignatureHandling(t *testing.T) {
if len(parts) != 1 || parts[0].FunctionCall == nil { if len(parts) != 1 || parts[0].FunctionCall == nil {
t.Fatalf("expected 1 functionCall part, got %+v", parts) t.Fatalf("expected 1 functionCall part, got %+v", parts)
} }
// Claude 模型不设置 signature // Claude 模型应透传有效的 signature(Vertex/Google 需要完整签名链路)
if parts[0].ThoughtSignature != "" { if parts[0].ThoughtSignature != "sig_tool_abc" {
t.Fatalf("expected no tool signature for Claude, got %q", parts[0].ThoughtSignature) t.Fatalf("expected preserved tool signature %q, got %q", "sig_tool_abc", parts[0].ThoughtSignature)
} }
}) })
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment