diff --git a/backend/internal/integration/e2e_gateway_test.go b/backend/internal/integration/e2e_gateway_test.go index 70343a3d..c7c58661 100644 --- a/backend/internal/integration/e2e_gateway_test.go +++ b/backend/internal/integration/e2e_gateway_test.go @@ -631,26 +631,26 @@ func testClaudeThinkingWithToolHistory(t *testing.T, model string) { t.Logf("✅ thinking 模式工具调用测试通过, id=%v", result["id"]) } -// TestClaudeMessagesWithInvalidThinkingSignature 测试历史 thinking block 带有无效 signature 的场景 -// 验证:系统应使用 dummy signature 替换历史的无效 signature -func TestClaudeMessagesWithInvalidThinkingSignature(t *testing.T) { +// TestClaudeMessagesWithNoSignature 测试历史 thinking block 不带 signature 的场景 +// 验证:Gemini 模型接受没有 signature 的 thinking block +func TestClaudeMessagesWithNoSignature(t *testing.T) { models := []string{ - "claude-haiku-4-5-20251001", // gemini-3-flash + "claude-haiku-4-5-20251001", // gemini-3-flash - 支持无 signature } for i, model := range models { if i > 0 { time.Sleep(testInterval) } - t.Run(model+"_无效thinking签名", func(t *testing.T) { - testClaudeWithInvalidThinkingSignature(t, model) + t.Run(model+"_无signature", func(t *testing.T) { + testClaudeWithNoSignature(t, model) }) } } -func testClaudeWithInvalidThinkingSignature(t *testing.T, model string) { +func testClaudeWithNoSignature(t *testing.T, model string) { url := baseURL + "/v1/messages" - // 模拟历史对话包含 thinking block 带有无效/过期的 signature + // 模拟历史对话包含 thinking block 但没有 signature payload := map[string]any{ "model": model, "max_tokens": 200, @@ -665,14 +665,14 @@ func testClaudeWithInvalidThinkingSignature(t *testing.T, model string) { "role": "user", "content": "What is 2+2?", }, - // assistant 消息包含 thinking block 和无效 signature + // assistant 消息包含 thinking block 但没有 signature map[string]any{ "role": "assistant", "content": []map[string]any{ { - "type": "thinking", - "thinking": "Let me calculate 2+2...", - "signature": "invalid_expired_signature_abc123", // 模拟过期的 signature + "type": "thinking", + "thinking": "Let me calculate 2+2...", + // 故意不包含 signature }, { "type": "text", @@ -702,9 +702,8 @@ func testClaudeWithInvalidThinkingSignature(t *testing.T, model string) { respBody, _ := io.ReadAll(resp.Body) - // 400 错误说明 signature 处理失败 if resp.StatusCode == 400 { - t.Fatalf("无效 thinking signature 处理失败,收到 400 错误: %s", string(respBody)) + t.Fatalf("无 signature thinking 处理失败,收到 400 错误: %s", string(respBody)) } if resp.StatusCode == 503 { @@ -727,5 +726,5 @@ func testClaudeWithInvalidThinkingSignature(t *testing.T, model string) { if result["type"] != "message" { t.Errorf("期望 type=message, 得到 %v", result["type"]) } - t.Logf("✅ 无效 thinking signature 处理测试通过, id=%v", result["id"]) + t.Logf("✅ 无 signature thinking 处理测试通过, id=%v", result["id"]) }