- 25 Mar, 2026 1 commit
-
-
QTom authored
- 401 token_invalidated / token_revoked: OAuth token 被永久作废,跳过临时不可调度逻辑,直接 SetError - 402 deactivated_workspace: 解析 detail.code 字段,标记工作区已停用 Co-Authored-By:Claude Opus 4.6 (1M context) <noreply@anthropic.com>
-
- 22 Mar, 2026 1 commit
-
-
Wang Lvyuan authored
-
- 19 Mar, 2026 1 commit
-
-
shaw authored
从上游 /v1/messages 响应头被动采集 5h/7d utilization 并存储到 Account.Extra,页面加载时直接读取本地数据而非调用外部 Usage API。 用户可点击"查询"按钮主动拉取最新数据,主动查询结果自动回写被动缓存。 后端: - UpdateSessionWindow 合并采集 5h + 7d headers 为单次 DB 写入 - 新增 GetPassiveUsage 从 Extra 构建 UsageInfo (复用 estimateSetupTokenUsage) - GetUsage 主动查询后 syncActiveToPassive 回写被动缓存 - passive_usage_ 前缀注册为 scheduler-neutral 前端: - Anthropic 账号 mount/refresh 默认 source=passive - 新增"被动采样"标签和"查询"按钮 (带 loading 动画)
-
- 18 Mar, 2026 1 commit
-
-
shaw authored
Move 529 overload cooldown configuration from config file to admin settings UI. Adds an enable/disable toggle and configurable cooldown duration (1-120 min) under /admin/settings gateway tab, stored as JSON in the settings table. When disabled, 529 errors are logged but accounts are no longer paused from scheduling. Falls back to config file value when DB is unreachable or settingService is nil.
-
- 17 Mar, 2026 1 commit
-
-
haruka authored
- Add compile-time interface assertion for sessionWindowMockRepo - Fix flaky fallback test by capturing time.Now() before calling UpdateSessionWindow - Replace stale hardcoded timestamps with dynamic future values - Add millisecond detection and bounds validation for reset header timestamp - Use pause/resume pattern for interval in UsageProgressBar to avoid idle timers on large lists - Fix gofmt comment alignment Co-Authored-By:Claude Sonnet 4.6 <noreply@anthropic.com>
-
- 16 Mar, 2026 1 commit
-
-
Elysia authored
The 5h window reset time displayed for Setup Token accounts was inaccurate because UpdateSessionWindow predicted the window end as "current hour + 5h" instead of reading the actual `anthropic-ratelimit-unified-5h-reset` response header. This caused the countdown to differ from the official Claude page. Backend: parse the reset header (Unix timestamp) and use it as the real window end, falling back to the hour-truncated prediction only when the header is absent. Also correct stale predictions when a subsequent request provides the real reset time. Frontend: add a reactive 60s timer so the reset countdown in UsageProgressBar ticks down in real-time instead of freezing at the initial value. Co-Authored-By:Claude Opus 4.6 <noreply@anthropic.com>
-
- 15 Mar, 2026 2 commits
-
-
erio authored
Replace process-memory sync.Map + per-model runtime state with a single "AICredits" key in model_rate_limits, making credits exhaustion fully isomorphic with model-level rate limiting. Scheduler: rate-limited accounts with overages enabled + credits available are now scheduled instead of excluded. Forwarding: when model is rate-limited + credits available, inject credits proactively without waiting for a 429 round trip. Storage: credits exhaustion stored as model_rate_limits["AICredits"] with 5h duration, reusing SetModelRateLimit/isRateLimitActiveForKey. Frontend: show credits_active (yellow
⚡ ) when model rate-limited but credits available, credits_exhausted (red) when AICredits key active. Tests: add unit tests for shouldMarkCreditsExhausted, injectEnabledCreditTypes, clearCreditsExhausted, and update existing overages tests. -
SilentFlower authored
feat: implement resolveCreditsOveragesModelKey function to stabilize model key resolution for credit overages
-
- 13 Mar, 2026 2 commits
-
-
erio authored
The 403 detection PR changed the 401 handler condition from `account.Type == AccountTypeOAuth` to `account.Type == AccountTypeOAuth && account.Platform == PlatformOpenAI`, which accidentally excluded Gemini OAuth from the temp-unschedulable path. Fix: use `!= PlatformAntigravity` instead, preserving Gemini behavior while correctly excluding Antigravity (whose 401 is handled by applyErrorPolicy's temp_unschedulable_rules). Update tests to reflect Antigravity's new 401 semantics: - HandleUpstreamError: Antigravity OAuth 401 now uses SetError - CheckErrorPolicy: Antigravity 401 second hit stays TempUnscheduled - DB fallback: split into Gemini (escalates) and Antigravity (stays temp)
-
erio authored
Backend: - Detect and classify 403 responses into three types: validation (account needs Google verification), violation (terms of service / banned), forbidden (generic 403) - Extract verification/appeal URLs from 403 response body (structured JSON parsing with regex fallback) - Add needs_verify, is_banned, needs_reauth, error_code fields to UsageInfo (omitempty for zero impact on other platforms) - Handle 403 in request path: classify and permanently set account error - Save validation_url in error_message for degraded path recovery - Enrich usage with account error on both success and degraded paths - Add singleflight dedup for usage requests with independent context - Differentiate cache TTL: success/403 → 3min, errors → 1min - Return degraded UsageInfo instead of HTTP 500 on quota fetch errors Frontend: - Display forbidden status badges with color coding (red for banned, amber for needs verification, gray for generic) - Show clickable verification/appeal URL links - Display needs_reauth and degraded error states in usage cell - Add Antigravity tier label badge next to platform type Tests: - Comprehensive unit tests for classifyForbiddenType (7 cases) - Unit tests for extractValidationURL (8 cases including unicode escapes) - Integration test for FetchQuota forbidden path
-
- 08 Mar, 2026 1 commit
-
-
kyx236 authored
-
- 07 Mar, 2026 2 commits
- 06 Mar, 2026 1 commit
-
-
FizzlyCode authored
从响应头 anthropic-ratelimit-unified-5h-utilization 获取并存储真实 utilization 值,解决进度条始终显示 0% 的问题。窗口重置时清除旧值, 避免残留上个窗口的数据。 Co-Authored-By:Claude Opus 4.6 <noreply@anthropic.com>
-
- 04 Mar, 2026 2 commits
- 02 Mar, 2026 1 commit
-
-
zqq61 authored
OAuth 账号收到 401 时,原逻辑同时设置 expires_at=now() 和 SetError(), 但刷新服务只查询 status=active 的账号,导致 error 状态的账号永远无法 被刷新服务拾取,expires_at=now() 实际上是死代码。 修复: - OAuth 401 使用 SetTempUnschedulable 替代 SetError,保持 status=active - 新增 oauth_401_cooldown_minutes 配置项(默认 10 分钟) - 刷新成功后同步清除 DB 和 Redis 中的临时不可调度状态 - 不可重试错误检查(invalid_grant 等)从 Antigravity 推广到所有平台 - 可重试错误耗尽后不再标记 error,下个刷新周期继续重试 恢复流程: OAuth 401 → temp_unschedulable + expires_at=now → 刷新服务拾取 → 成功: 清除 temp_unschedulable → 自动恢复 → invalid_grant: SetError → 永久禁用 → 网络错误: 仅记日志 → 下周期重试
-
- 28 Feb, 2026 1 commit
-
-
yangjianbo authored
-
- 22 Feb, 2026 1 commit
-
-
yangjianbo authored
- ClearRateLimit 增加清理 temp_unschedulable 与缓存\n- 新增 ClearRateLimit 相关单元测试覆盖成功与失败分支
-
- 13 Feb, 2026 1 commit
-
-
shaw authored
当账号仅触发 5h 窗口限流时,旧逻辑从聚合头 anthropic-ratelimit-unified-reset 读取重置时间,该值为所有窗口的 最大值(即 7d 重置时间),导致账号被标记为不可调度约 6 天。 新增 calculateAnthropic429ResetTime 函数,解析 Anthropic 的 per-window 头(5h-utilization/reset、7d-utilization/reset、 surpassed-threshold),判断实际触发的窗口并使用对应的重置时间: - 仅 5h 超标 → 使用 5h-reset(约 5 小时) - 仅 7d 超标 → 使用 7d-reset - 两者均超标 → 使用 7d-reset(较长冷却) - per-window 头不存在 → 回退到聚合头(向后兼容)
-
- 09 Feb, 2026 1 commit
-
-
erio authored
-
- 08 Feb, 2026 1 commit
-
-
erio authored
-
- 07 Feb, 2026 1 commit
-
-
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
-
- 02 Feb, 2026 1 commit
-
-
song authored
-
- 26 Jan, 2026 1 commit
-
-
ianshaw authored
- 问题:OpenAI 的 usage_limit_reached 错误(需 37 小时重置)被错误地设置为 5 分钟 - 原因:handle429 只检查 Anthropic 响应头,没有解析 OpenAI 响应体中的 resets_in_seconds - 修复:新增 parseOpenAIRateLimitResetTime 函数解析 OpenAI 响应体 - 影响:避免调度器不断尝试已达配额上限的账户
-
- 25 Jan, 2026 1 commit
-
-
shaw authored
- 解析 x-codex-* 响应头获取正确的重置时间 - 7d 限制用尽时使用 codex_7d_reset_after_seconds - 提取 Normalize() 方法统一窗口规范化逻辑
-
- 19 Jan, 2026 1 commit
-
-
shaw authored
-
- 18 Jan, 2026 1 commit
-
-
yangjianbo authored
-
- 16 Jan, 2026 1 commit
-
-
wfunc authored
-
- 15 Jan, 2026 4 commits
-
-
yangjianbo authored
- Gemini 缓存键统一增加 gemini: 前缀,避免与其他平台命名空间冲突 - OAuth 账号 401 错误时设置 expires_at=now 并持久化,强制下次请求刷新 token - Redis 锁获取失败时降级为无锁刷新,仅在 token 接近过期时执行,并检查 ctx 取消状态 Co-Authored-By:Claude Opus 4.5 <noreply@anthropic.com>
-
yangjianbo authored
新增 OpenAI/Claude TokenProvider 与缓存键生成 扩展 OAuth 缓存失效覆盖更多平台 统一 OAuth 缓存前缀与依赖注入
-
yangjianbo authored
-
yangjianbo authored
- OAuth 401 清理缓存并设置错误状态 - 移除 oauth_401_cooldown_minutes 配置及示例 - 更新 401 相关单测 破坏性变更: OAuth 401 不再临时不可调度,需手动恢复
-
- 14 Jan, 2026 2 commits
-
-
longgexx authored
修复两个问题: 1. Token使用趋势图和模型分布图未响应筛选条件 2. 上午时段选择今天刷新后日期回退到前一天 前端修改: - 更新 dashboard API 类型定义,添加 model、account_id、group_id、stream 参数支持 - 修改 UsageView 趋势图加载逻辑,传递所有筛选参数到后端 - 修复日期格式化函数,使用本地时区避免 UTC 转换导致的日期偏移 后端修改: - Handler 层:接收并解析所有筛选参数(model、account_id、group_id、stream) - Service 层:传递完整的筛选参数到 Repository 层 - Repository 层:SQL 查询动态添加所有过滤条件 - 更新接口定义和所有调用点以保持一致性 影响范围: - /admin/dashboard/trend 端点现支持完整筛选 - /admin/dashboard/models 端点现支持完整筛选 - 用户在后台使用记录页面选择任意筛选条件时,趋势图和模型分布图会实时响应 - 日期选择器在任何时区下都能正确保持今天的选择
-
yangjianbo authored
新增 token 缓存失效接口并在刷新后清理 401 限流支持自定义规则与可配置冷却时间 补齐缓存失效与 401 处理测试 测试: make test
-
- 12 Jan, 2026 2 commits
-
-
ianshaw authored
- 修改 HandleUpstreamError 逻辑,启用自定义错误码时所有在列表中的错误码都会停止调度 - 添加 handleCustomErrorCode 函数处理自定义错误码的账号停用 - 前端添加 429/529 错误码的警告提示,因为这些错误码已有内置处理机制 - 更新 EditAccountModal、CreateAccountModal、BulkEditAccountModal 的错误码添加逻辑
-
ianshaw authored
- 添加 StreamTimeoutSettings 配置结构体和系统设置 - 实现 TimeoutCounterCache Redis 计数器用于累计超时次数 - 在 RateLimitService 添加 HandleStreamTimeout 方法 - 在 gateway_service、openai_gateway_service、antigravity_gateway_service 中调用超时处理 - 添加后端 API 端点 GET/PUT /admin/settings/stream-timeout - 添加前端配置界面到系统设置页面 - 支持配置:启用开关、超时阈值、处理方式、暂停时长、触发阈值、阈值窗口 默认配置: - 启用:true - 超时阈值:60秒 - 处理方式:临时不可调度 - 暂停时长:5分钟 - 触发阈值:3次 - 阈值窗口:10分钟
-
- 11 Jan, 2026 1 commit
-
-
IanShaw027 authored
**新增功能**: - 新建ops_upstream_error_events表存储上游服务错误详情 - 支持记录上游429/529/5xx错误的详细上下文信息 - 提供按时间范围查询上游错误事件的API **后端改动**: 1. 模型层(ops_models.go, ops_port.go): - 新增UpstreamErrorEvent结构体 - 扩展Repository接口支持上游错误事件CRUD 2. 仓储层(ops_repo.go): - 实现InsertUpstreamErrorEvent写入上游错误 - 实现GetUpstreamErrorEvents按时间范围查询 3. 服务层(ops_service.go, ops_upstream_context.go): - ops_service: 新增GetUpstreamErrorEvents查询方法 - ops_upstream_context: 封装上游错误上下文构建逻辑 4. Handler层(ops_error_logger.go): - 新增GetUpstreamErrorsHandler处理上游错误查询请求 5. Gateway层集成: - antigravity_gateway_service.go: 429/529错误时记录上游事件 - gateway_service.go: OpenAI 429/5xx错误时记录 - gemini_messages_compat_service.go: Gemini 429/5xx错误时记录 - openai_gateway_service.go: OpenAI 429/5xx错误时记录 - ratelimit_service.go: 429限流错误时记录 **数据记录字段**: - request_id: 关联ops_logs主记录 - platform/model: 上游服务标识 - status_code/error_message: 错误详情 - request_headers/response_body: 调试信息(可选) - created_at: 错误发生时间
-
- 09 Jan, 2026 2 commits