- 08 Feb, 2026 16 commits
-
-
erio authored
Without this routing guard, ForwardUpstream is never called because Forward() always proceeds with the standard OAuth/cookie flow.
-
erio authored
- In handleSmartRetry, use the actual upstream retryDelay to set model rate limit duration instead of always using the 30s default - Return info.RetryDelay from shouldTriggerAntigravitySmartRetry when shouldRateLimitModel=true, so callers know the actual delay - Extract getDefaultRateLimitDuration() and resolveResetTime() helpers to reduce duplication in handleUpstreamError 429 handling - Improve debug logging with upstream_retry_delay and response body
-
erio authored
-
erio authored
-
erio authored
-
erio authored
-
erio authored
-
erio authored
ParseGatewayRequest only parsed Anthropic format (system/messages), ignoring Gemini native format (systemInstruction/contents). This caused GenerateSessionHash to produce identical hashes for all Gemini sessions. Add protocol parameter to ParseGatewayRequest to branch between Anthropic and Gemini parsing. Update GenerateSessionHash message traversal to extract text from both formats.
-
erio authored
Mix SessionContext (ClientIP, UserAgent, APIKeyID) into GenerateSessionHash 3rd-level fallback to differentiate requests from different users sending identical content. Also switch hashContent from SHA256-truncated to XXHash64 for better performance, and optimize Trie Lua script to match from longest prefix first.
-
bayma888 authored
- Add `sort_order` field to groups table with migration - Add `PUT /api/v1/admin/groups/sort-order` API for batch update - Implement drag-and-drop UI using vue-draggable-plus - All queries now order groups by sort_order - Add i18n support (en/zh) for sort-related UI text - Update test stubs to satisfy new interface methods
-
erio authored
-
shaw authored
-
erio authored
Upstream accounts now use the standard APIKey type instead of a dedicated upstream type. GetBaseURL() and new GetGeminiBaseURL() automatically append /antigravity for Antigravity platform APIKey accounts, eliminating the need for separate upstream forwarding methods. - Remove ForwardUpstream, ForwardUpstreamGemini, testUpstreamConnection - Remove upstream branch guards in Forward/ForwardGemini/TestConnection - Add migration 052 to convert existing upstream accounts to apikey - Update frontend CreateAccountModal to create apikey type - Add unit tests for GetBaseURL and GetGeminiBaseURL
-
erio authored
ForwardUpstream/ForwardUpstreamGemini should pipe the upstream response directly to the client (headers + body), not parse it as SSE stream.
-
erio authored
-
erio authored
Replace manual header setting (Content-Type, anthropic-version, anthropic-beta) with full client header passthrough in ForwardUpstream/ForwardUpstreamGemini. Only authentication headers (Authorization, x-api-key) are overridden with upstream account credentials. Hop-by-hop headers are excluded. Add unit tests covering header passthrough, auth override, and hop-by-hop filtering.
-
- 07 Feb, 2026 20 commits
-
-
erio authored
v0.1.74 merged upstream accounts into the OAuth path, causing requests to hit the wrong protocol and endpoint. Add three upstream-specific methods (testUpstreamConnection, ForwardUpstream, ForwardUpstreamGemini) that use base_url + apiKey auth and passthrough the original body, while reusing the existing response handling and error/retry logic.
-
erio authored
- Change antigravitySmartRetryMaxAttempts from 3 to 1 to prevent repeated rate limiting and long waits - Clear sticky session binding (DeleteSessionAccountID) after smart retry exhaustion, so subsequent requests don't hit the same rate-limited account - Add flow diagrams to Forward/ForwardGemini doc comments - Add comprehensive unit tests covering: - Sticky session cleared on retry failure (429, 503, network error) - Sticky session NOT cleared on retry success - Sticky session NOT cleared for non-sticky requests (empty hash) - Sticky session NOT cleared on long delay path (handled by handler) - Nil cache safety (no panic) - MaxAttempts constant verification - End-to-end retryLoop → switchError propagation with session clear
-
shaw authored
-
erio authored
-
erio authored
The previous fallback (step 3) in GenerateSessionHash hashed system + all messages together, producing a different hash each round as the conversation grew ([a] -> [a,b] -> [a,b,c]). This made fallback sticky sessions ineffective for multi-turn conversations. Implement per-message Trie digest chain matching (reusing Gemini's Trie infrastructure) so that the previous round's chain is always a prefix of the current round's chain, enabling reliable session affinity.
-
shaw authored
- avoid panic by using safe UUID prefix truncation in Gemini digest fallback logs\n- remove unconditional Antigravity 429 full-body debug logs and honor log truncation config\n- align Antigravity quick preset mappings to opus 4.6-thinking targets only\n- restore scope rate-limit aggregation/output in ops availability stats
-
erio authored
Remove threshold-based waiting in both sticky session and antigravity pre-check paths. When a model is rate-limited, immediately clear the sticky session and switch accounts instead of waiting for short durations.
-
erio authored
-
erio authored
1. Frontend: replace hardcoded antigravityDefaultMappings with async fetch from GET /admin/accounts/antigravity/default-model-mapping, eliminating the duplicate data source that caused frontend/backend mapping inconsistency. 2. Backend: convert handleSmartRetry and antigravityRetryLoop from standalone functions to AntigravityGatewayService methods, enabling Redis cache sync (updateAccountModelRateLimitInCache) after both rate-limit write paths — long-delay branch and retry-exhausted branch.
-
erio authored
Remove extra blank line that caused golangci-lint gofmt check to fail.
-
erio authored
-
erio authored
- Add GetAccessToken upstream branch tests (success/failure/empty/nil) - Add mapAntigravityModel wildcard-target-equals-request edge case tests - Add upstream account smart retry test case - Add GeminiMessagesCompatService custom model_mapping and empty model tests
-
erio authored
- GetAccessToken: add upstream branch to read api_key from credentials - shouldTriggerAntigravitySmartRetry: relax check from IsOAuth to Platform-based - isModelSupportedByAccount/WithContext: replace IsAntigravityModelSupported whitelist with mapAntigravityModel for unified scheduling/forwarding logic - mapAntigravityModel: fix edge case where wildcard target equals request model - Update tests for new behavior and add custom model_mapping test cases
-
erio authored
-
erio authored
-
erio authored
Key changes: - Upgrade model mapping: Opus 4.5 → Opus 4.6-thinking with precise matching - Unified rate limiting: scope-level → model-level with Redis snapshot sync - Load-balanced scheduling by call count with smart retry mechanism - Force cache billing support - Model identity injection in prompts with leak prevention - Thinking mode auto-handling (max_tokens/budget_tokens fix) - Frontend: whitelist mode toggle, model mapping validation, status indicators - Gemini session fallback with Redis Trie O(L) matching - Ops: enhanced concurrency monitoring, account availability, retry logic - Migration scripts: 049-051 for model mapping unification
-
erio authored
The default fallback cooldown when rate limit reset time cannot be parsed was 5 minutes, which is too aggressive and causes accounts to be unnecessarily locked out. Reduce to 30 seconds for faster recovery. Config override still works (unit remains minutes).
-
shaw authored
- OAuth 账号:使用完整的 DefaultBetaHeader 和 Claude Code 客户端 headers - API Key 账号:使用 APIKeyBetaHeader(不含 oauth beta)
-
shaw authored
-
shaw authored
-
- 06 Feb, 2026 4 commits
-
-
shaw authored
在敏感字段检测中添加白名单,排除 API 参数和用量统计字段: - max_tokens, max_completion_tokens, max_output_tokens - completion_tokens, prompt_tokens, total_tokens - input_tokens, output_tokens - cache_creation_input_tokens, cache_read_input_tokens 这些字段名虽然包含 "token" 但只是数值参数,不应被脱敏处理。
-
shaw authored
移除响应阶段的工具名/schema/description 转换逻辑,修复第三方工具调用时 工具名被错误转换的问题(如 Task → task)。 移除内容: - 工具名相关正则变量(toolPrefixRe, toolNameBoundaryRe 等) - openCodeToolOverrides 和 claudeToolNameOverrides 映射表 - 工具名转换函数(normalizeToolNameForClaude, normalizeToolNameForOpenCode 等) - 响应体工具名替换函数(replaceToolNamesInText, replaceToolNamesInResponseBody 等) - 参数名转换函数(normalizeParamNameForOpenCode, rewriteParamKeysInValue) - 工具描述清理函数(sanitizeToolDescription) - 输入 schema 转换函数(normalizeToolInputSchema) - 模型 ID 正则替换函数(replaceModelIDInText) 保留内容: - 系统提示词清理(sanitizeSystemText) - Claude Code 指纹 headers 处理 - 模型 ID 映射(通过 JSON 对象操作)
-
yangjianbo authored
-
yangjianbo authored
Kimi 等 Claude 兼容 API 返回缓存信息使用 OpenAI 风格的 cached_tokens 字段, 而非 Claude 标准的 cache_read_input_tokens,导致客户端收不到缓存命中信息且 内部计费缓存折扣为 0。 新增 reconcileCachedTokens 辅助函数,在 cache_read_input_tokens == 0 且 cached_tokens > 0 时自动填充,覆盖流式(message_start/message_delta)和 非流式两种响应路径。对 Claude 原生上游无影响。 Co-Authored-By:Claude Opus 4.6 <noreply@anthropic.com>
-