fix(antigravity): 修复 Gemini 3 thought_signature 和 schema 验证问题

- 添加 dummyThoughtSignature 常量,在 thinking 模式下为无 signature 的 tool_use 自动添加
- 增强 cleanJSONSchema:过滤 required 中不存在的属性,确保 type/properties 字段存在
- 扩展 excludedSchemaKeys:增加 $id, $ref, strict, const, examples 等不支持的字段
- 修复 429 重试逻辑:仅在所有重试失败后才标记账户为 rate_limited
- 添加 e2e 集成测试:TestClaudeMessagesWithThinkingAndTools
This commit is contained in:
song
2025-12-28 21:25:04 +08:00
parent ff06583c5d
commit 9594c9c83a
3 changed files with 757 additions and 46 deletions

View File

@@ -271,14 +271,15 @@ func (s *AntigravityGatewayService) Forward(ctx context.Context, c *gin.Context,
respBody, _ := io.ReadAll(io.LimitReader(resp.Body, 2<<20))
_ = resp.Body.Close()
if resp.StatusCode == 429 {
s.handleUpstreamError(ctx, account, resp.StatusCode, resp.Header, respBody)
}
if attempt < antigravityMaxRetries {
log.Printf("Antigravity account %d: upstream status %d, retry %d/%d", account.ID, resp.StatusCode, attempt, antigravityMaxRetries)
sleepAntigravityBackoff(attempt)
continue
}
// 所有重试都失败,标记限流状态
if resp.StatusCode == 429 {
s.handleUpstreamError(ctx, account, resp.StatusCode, resp.Header, respBody)
}
// 最后一次尝试也失败
resp = &http.Response{
StatusCode: resp.StatusCode,