Commit Graph
8336 Commits
Author SHA1 Message Date
Shilin Zhou fe40612b80 fix: allow disabling concurrency wait pings 2026-11-11 17:46:45 +08:00
feeeei 23ac69a021 fix(bedrock): 按错误语义区分封号、用例缺失、限流与内容过滤,流中断保留 usage
- 400 消息整句为 "Operation not allowed"(AWS 封号):账号置 error 并换号;其余 Bedrock 400 一律按请求错误处理,不按消息子串改账号状态(ValidationException 会把请求字段名回显进消息)
- 404 "Model use case details have not been submitted..."(未提交模型用例):账号置 error 并换号
- 429 只冷却 (账号, 模型),时长取「429 默认回避」配置,配置关闭时不写;模型未知时沿用账号级兜底
- 500/502/503/504 且消息含 "blocked by content filtering policy":不换号、不惩罚账号,返回客户端 400 invalid_request_error 与上游原文
- 渠道模型映射生效时,handler 经 WithGatewaySchedulingModel 传入选号模型,模型级账号状态写在调度器按客户端模型读取的键上
- 流式输出中断时与错误一起返回已观测的 usage,照常计费
- 临时不可调度规则仍优先于以上默认分类
2026-11-11 16:01:47 +08:00
alfadb 796455c1c9 fix(billing): 为硅基流动 Qwen3-Reranker 系列补兜底定价 2026-11-11 15:48:38 +08:00
alfadb 43c1ca0148 fix(billing): 为硅基流动 Qwen3-Embedding 系列补兜底定价
生产日志出现 WARN openai_usage.pricing_missing_record_zero_cost:模型
Qwen/Qwen3-Embedding-8B 经 OpenAI 兼容 /v1/embeddings(上游硅基流动)调用时,
分组价 → 渠道价 → LiteLLM 目录 → 代码兜底表全链查不到价格,按 0 成本记账。
LiteLLM 目录无 qwen 条目,故在代码兜底表补入白名单条目。

价格(硅基流动官方,2026-09-23 读取,USD per token):
- 8B   $0.04/MTok = 0.04e-6  https://www.siliconflow.com/models/qwen3-embedding-8b
- 4B   $0.02/MTok = 0.02e-6  (同站 4B 模型页)
- 0.6B $0.01/MTok = 0.01e-6  (同站 0.6B 模型页)
国内站参考价(https://www.siliconflow.cn/pricing):8B ¥0.28/MTok、4B ¥0.14/MTok、
0.6B ¥0.07/MTok,输出 ¥0。embedding 只按输入计费,OutputPricePerToken 显式置 0。

匹配规则:getFallbackPricing 入口已 ToLower,按 8b → 4b → 0.6b most-specific-first
用 strings.Contains 命中;0.6B 同时接受 qwen3-embedding-0.6b 与 qwen3-embedding-0-6b
两种拼法。不加泛化的 qwen3-embedding 家族兜底,未知档位(如 2B)继续不回退,
保持本表「白名单、未知型号不猜测计价」的语义。两处均插在 doubao embedding 条目/分支
紧前面,避免与私有分支在 doubao 之后追加的条目冲突。

测试:TestGetFallbackPricing_FamilyMatching 增 5 条正例(校验输入价与输出价 0)
与 2B 负例;新增 TestGetModelPricing_Qwen3EmbeddingFallback、
TestCalculateOpenAIRecordUsageCost_Qwen3EmbeddingFallback(1000 输入 token
= 1000 × 0.04e-6,且不再返回 pricing unavailable)。
2026-11-11 15:48:38 +08:00
Long Li e055d7bafc fix(antigravity): stream Gemini compat thoughts and anchor pre-content timeout after headers 2026-11-11 16:38:33 +09:00
r266-tech c8f4264f8f fix(grok): preserve upstream media error messages and codes 2026-11-11 14:21:00 +08:00
lishuangqiang a8481f0dec test(gateway): satisfy errcheck in request JSON tests 2026-11-11 13:54:37 +08:00
lishuangqiang 71ef577054 perf(gateway): trim per-request JSON work on the Anthropic request path
- Skip both cache_control walks with a byte-level precheck when the body
  has at most 4 cache_control keys, no thinking block and no 1h TTL; skip
  the block-limit walk when only 1h is present. Bodies containing \u
  escapes always take the original path.
- Replace gjson Array() materialization with Get("0")/ForEach in the
  beta, toolset, tool-rewrite, web-search and system-preview helpers.
- Build the Claude Code mimic debug line lazily; it is only read on
  credential-scope errors.
- Compute the billing-header fingerprint once instead of per block.

Differential tests copy the previous implementations verbatim and
compare byte for byte across edge cases and 3000 randomized bodies.
Batching TTL rewrites with sjson ReplaceInPlace was rejected because it
resolves duplicate keys differently.

Common ~32KB Claude Code request: enforceCacheControlLimit 100us/21
allocs -> 21.6us/0 allocs; helper set 47.6us/103KB -> 37.9us/69KB;
debug line 9.1us/53 allocs -> ~0.
2026-11-11 13:45:09 +08:00
jaxxjj 74ba91aa6b fix(openai): keep Codex forks on their parent's prompt cache key
An ephemeral Codex fork, such as app-server thread/sample, keeps its parent's
session-id header and prompt_cache_key but names itself in
client_metadata.session_id. Account identity scoping compared the key only
with client_metadata.session_id, so a fork's key fell into the prompt-cache
namespace and reached upstream as a different value from its parent's, and
the fork lost the parent's prompt cache.

Treat a key that equals either client_metadata.session_id or the client's
session-id header as a session key.
2026-11-10 19:09:30 -08:00
shaw 530c5e3a4f chore: update sponsors 2026-11-11 10:43:23 +08:00
github-actions[bot] 6dd5a045b6 chore: sync VERSION to 0.2.21 [skip ci] 2026-11-11 02:22:16 +00:00
feeeei 5846bfbbfa fix(gemini): 兼容入口 chat 请求转发 response_format 结构化输出
/v1/chat/completions 走 Gemini 账号时,response_format 在 chat→Responses→Anthropic
转换中丢失,上游只能靠 prompt 约束 JSON 格式。现在按客户端原始 response_format 写
generationConfig:json_object 写 responseMimeType=application/json;json_schema 另把
json_schema.schema 原样写入 responseJsonSchema。请求带 tools 或上游模型为图片输出
模型时不写。

Code Assist(OAuth + project_id)包装改为原字节嵌入 request,避免 Unmarshal→Marshal
重排 schema 属性顺序、截断大整数。
2026-11-11 10:17:12 +08:00
xy3 d70a23f84b feat(gemini): add Gemini 4 Carbon support 2026-11-11 10:01:42 +08:00
Wesley Liddick 10ba8f9b4d Merge pull request #8639 from xy3xy3/feat/claude-fable-mythos-5-2
feat: add Claude Fable 5.2 and Mythos 5.2 support
v0.2.21
2026-11-11 09:37:34 +08:00
lishuangqiang 98a44ba3f3 fix(billing): make group rate/RPM sync transactional
SyncGroupRateMultipliers and SyncGroupRPMOverrides ran three destructive
statements in autocommit mode: clear rows missing from the payload,
delete all-NULL rows, then upsert the payload. If the upsert failed
(deleted user FK, duplicate user_id, transient DB error), the clear and
delete had already committed, silently wiping the group's overrides.

Wrap each sync in one transaction and dedupe entries by user_id before
writing so ON CONFLICT cannot hit the same row twice. Any failure now
rolls the whole sync back.

Add sqlmock tests covering commit, rollback and dedupe.
2026-11-11 09:34:54 +08:00
lishuangqiang 1546c0c18e perf(gateway): skip JSON decode for forwarded Anthropic stream events
Anthropic SSE processing decoded every data line into map[string]any even
though most events (content_block_delta, ping, ...) are forwarded
verbatim. A 120-byte text delta cost ~915ns, 1185B and 20 allocations;
a 1500-chunk response burned ~1.4ms CPU and ~30k allocations for no
semantic gain.

Parse only events that can change usage, model, cache_control or
keepalive state. Replace the per-line SSE regex with a prefix check, and
add a string variant of tool-name restoration so the streaming writer no
longer copies each chunk through []byte/string.

Benchmark (content_block_delta): 915ns/20 allocs/1185B -> 164ns/0
allocs/0B. Output remains byte-for-byte identical; existing streaming
tests pass.
2026-11-11 07:57:56 +08:00
lishuangqiang 37a0f3870b fix(billing): scope RPM override to the group it belongs to
The auth cache snapshot records the (user, group) RPM override for the
API key's group. checkRPM used it for any group whenever it was non-nil,
so a fallback request (for example the Antigravity prompt-too-long path)
applied group A's override to group B: override=0 disabled B's
rpm_limit entirely, while a positive override throttled B to the wrong
rate.

Only trust the snapshot override when UserGroupRPMOverrideGroupID
matches the current group; otherwise fall back to the DB lookup as the
snapshot versioning intended.
2026-11-11 00:55:51 +08:00
lishuangqiang 43511b40e9 fix(payment): make Alipay refund request id stable across retries
Alipay refunds used a UnixNano timestamp as out_request_no, so an admin
retry after an ambiguous gateway error minted a new request and refunded
the user twice. Use the same deterministic order+amount id as the other
providers (wxpayRefundID, Stripe idempotency key).

Same order and amount now map to the same Alipay refund request; the
existing QueryRefund prefix contract is unchanged.
2026-11-10 23:56:34 +08:00
xy3 6a2c744af3 Merge main and reconcile overlapping Claude 5.2 pricing 2026-11-10 22:24:20 +08:00
Wesley Liddick e2c9812190 Merge pull request #8357 from ychy7001/fix/audit-worker-wake
fix(securityaudit): 审计任务入队后立即唤醒本进程 worker
2026-11-10 21:30:34 +08:00
Wesley Liddick 2cc43fdeff Merge pull request #8575 from WGeorgezzzz/fix/openai-responses-reject-invalid-utf8
fix(openai): reject invalid UTF-8 Responses bodies
2026-11-10 21:30:26 +08:00
Wesley Liddick e6981f0ffd Merge pull request #8379 from danvilig/codex/fix-native-image-error-status
fix(openai): preserve native Codex image error statuses
2026-11-10 21:30:19 +08:00
Wesley Liddick b045db4a40 Merge pull request #8622 from Hato626/fix/codex-page-context
fix(openai): normalize Codex Desktop page context before tool validation
2026-11-10 21:30:14 +08:00
Wesley Liddick 41e4a6b108 Merge pull request #8367 from SmallNew2003/feat/settings-save-dock
feat(settings): 系统设置保存按钮改为底部吸附浮标
2026-11-10 21:30:08 +08:00
Wesley Liddick 48b11bf743 Merge pull request #8642 from baowl2022/fix/balance-recharge-multiplier-6-decimals
fix(payment): support up to 6 decimals for balance recharge multiplier
2026-11-10 21:30:02 +08:00
Wesley Liddick 51a0e89b8b Merge pull request #8581 from Ming-Sir-69/fix/accounts-refresh-stability
fix(accounts): retain rows and quota values while refreshing
2026-11-10 21:29:56 +08:00
Wesley Liddick a870836599 Merge pull request #8346 from hezhaoqian1/perf/upstream-keys-usage-index
perf(keys): API 密钥列表不再等待 30 天用量统计,并为其加覆盖索引
2026-11-10 21:29:51 +08:00
Wesley Liddick 5fe13c3c48 Merge pull request #8161 from wucm667/fix/issue-8156-synthesized-reasoning-mapping
fix(openai): apply mappings to synthesized reasoning effort
2026-11-10 21:29:45 +08:00
Wesley Liddick efdc399ecf Merge pull request #8637 from lishuangqiang/fix/atomic-refresh-token-rotation
fix(auth): consume refresh tokens atomically during rotation
2026-11-10 21:29:40 +08:00
Wesley Liddick b455228b46 Merge pull request #8631 from lishuangqiang/fix/slot-leak-on-hydrate-error
fix(scheduling): release acquired slot when account hydration fails
2026-11-10 21:29:34 +08:00
Wesley Liddick d18e1dff60 Merge pull request #8566 from r266-tech/codex/easypay-refund-success-code
fix(payment): configure EasyPay refund success codes per instance
2026-11-10 21:29:29 +08:00
Wesley Liddick 968c1022e6 Merge pull request #8568 from r266-tech/codex/pro-argon-cooldown
fix(antigravity): isolate Pro Argon quota cooldowns
2026-11-10 21:29:24 +08:00
Wesley Liddick 6f6b54d316 Merge pull request #8621 from baryon/contrib/antigravity-parallel-tool-result-images
fix(antigravity): keep parallel tool functionResponses contiguous before media
2026-11-10 21:29:18 +08:00
Wesley Liddick 350c800449 Merge pull request #8584 from feeeei/fix/gemini-nonstream-thought-parts
fix(gemini): 兼容入口非流式响应不再把思考摘要混入正文
2026-11-10 21:29:13 +08:00
Wesley Liddick 9de6dd766b Merge pull request #8385 from r266-tech/codex/compat-account-error-policy
fix(gateway): honor account error policies in compatibility paths
2026-11-10 21:29:07 +08:00
Wesley Liddick f7ddfb8236 Merge pull request #8589 from r266-tech/codex/stable-responses-session-prefix
fix(openai): stabilize Responses session seeds across tool loops
2026-11-10 21:29:02 +08:00
Wesley Liddick 73e75a18d1 Merge pull request #8386 from r266-tech/codex/skip-foreign-reasoning-envelope
fix(apicompat): skip foreign CC Switch reasoning envelopes
2026-11-10 21:28:56 +08:00
Wesley Liddick aa56a4606d Merge pull request #8585 from r266-tech/codex/preserve-sealed-response-calls
fix(apicompat): preserve sealed function call metadata
2026-11-10 21:28:50 +08:00
Wesley Liddick 6e128ba405 Merge pull request #8579 from r266-tech/codex/honor-overload-model-cooldown
fix(openai): honor explicit model cooldowns for capacity errors
2026-11-10 21:28:45 +08:00
Wesley Liddick fc9d811385 Merge pull request #8576 from WGeorgezzzz/fix/openai-codex-metadata-events
fix(openai): keep Codex metadata events retry-safe
2026-11-10 21:28:39 +08:00
Wesley Liddick 32d0576edc Merge pull request #8565 from qsy4/fix/openai-ws-ttft-mode
fix(openai-ws): follow the TTFT mode for WebSocket first token
2026-11-10 21:28:32 +08:00
Wesley Liddick 9725718e12 Merge pull request #8358 from AndersonBY/codex/fix-oauth-ws-search-activation
fix(openai-ws): reconnect pooled OAuth sockets before search activation
2026-11-10 21:28:26 +08:00
Wesley Liddick 2fd34acc1f Merge pull request #8564 from r266-tech/codex/native-ws-later-turn-fail-closed
fix(openai): stop native WS later-turn first-frame replay
2026-11-10 21:28:20 +08:00
Wesley Liddick d216e42156 Merge pull request #8634 from r266-tech/codex/claude52-pricing
fix(pricing): add Claude Fable and Mythos 5.2 fallback rates
2026-11-10 21:28:14 +08:00
Wesley Liddick 1cae79565a Merge pull request #8384 from r266-tech/codex/pricing-sync-body-hash
fix(pricing): retry sync after catalog hash mismatch
2026-11-10 21:28:08 +08:00
Wesley Liddick 722bbf6dbe Merge pull request #8381 from r266-tech/codex/sonnet55-cache-read-pricing
fix: correct Sonnet 5.5 cache read fallback pricing
2026-11-10 21:28:02 +08:00
xy3 ea6b3de808 test: keep Claude Code version fixtures above the built-in floor 2026-11-10 20:05:28 +08:00
r266-tech c115dc27ab fix(usage): read Fable weekly quotas from scoped limits 2026-11-10 19:37:32 +08:00
baowl2022 edd7db77fe fix(payment): support up to 6 decimals for balance recharge multiplier
Persist BALANCE_RECHARGE_MULTIPLIER with up to 6 decimal places so operators
can track a live FX rate (e.g. 1 USD = 7.100000 CNY -> 0.140845). Values with
more than 6 decimals are rejected instead of being silently truncated.
Credited balance still rounds to settlement-currency precision, so order and
ledger semantics are unchanged.

Adds backend unit tests and a frontend formatter test; updates the admin input
step/preview and the checkout rate display.
2026-11-10 18:47:03 +08:00
lishuangqiang 7122efee94 fix(auth): consume refresh tokens atomically during rotation
RefreshTokenPair read the token and deleted it in two Redis calls. Two
concurrent requests with the same refresh token both passed the read and
validation, so both could mint a new token pair, keeping a stolen token
alive across rotations.

Add an atomic ConsumeRefreshToken (Lua GET+DEL) and require rotation to
win that consume. Losers get ErrRefreshTokenInvalid; Redis errors now
fail closed instead of issuing a new pair without invalidating the old
token.
2026-11-10 15:03:59 +08:00