Commit Graph
8336 Commits
Author SHA1 Message Date
Wesley Liddick 1209e71e6d Merge pull request #8437 from m11y/fix/error-passthrough-before-body-limit-failover
fix(openai): let error passthrough rules override the built-in body-limit 413
2026-11-07 10:53:41 +08:00
Wesley Liddick c86645c3b6 Merge pull request #8521 from william-drakemond/pr/antigravity-internal500-scope
fix(antigravity): INTERNAL 500 只冷却出错的图像模型,账号惩罚档位可配置 / Scope INTERNAL 500 penalties to image models; configurable account tiers
2026-11-07 10:53:16 +08:00
Wesley Liddick c70ef412e3 Merge pull request #8531 from william-drakemond/pr/antigravity-test-prompt
fix(antigravity): 账号测试发送管理员输入的提示词并允许模型作答 / Account test sends the admin's prompt and lets the model answer
2026-11-07 10:52:57 +08:00
Wesley Liddick 2ee66a660f Merge pull request #8429 from lkon2112/fix/responses-message-content
fix(responses): preserve message content fields in completed responses
2026-11-07 10:52:25 +08:00
Wesley Liddick b628339986 Merge pull request #8563 from r266-tech/codex/buffered-reasoning-content
fix(apicompat): preserve buffered reasoning content
2026-11-07 10:52:10 +08:00
shaw e6c19082f2 chore: update sponsors 2026-11-07 09:49:12 +08:00
r266-tech 0578fb160e fix(openai): stop native WS later-turn first-frame replay 2026-11-07 09:40:59 +08:00
r266-tech 30ec2ecc98 fix(apicompat): preserve buffered reasoning content 2026-11-07 04:47:20 +08:00
cyh 22693fb4fe fix(grok): classify Grok Voice body read failures
Stalled uploads to /v1/tts, /v1/stt and /v1/custom-voices reach GrokVoice
directly. Its read errors fell through to a 400 carrying err.Error(): with
the read timeout now preserved, that reported a timeout as a malformed
request and returned the raw socket error. Keep the validation message for
a missing body and send every read error through the shared classifier.
2026-11-07 02:07:37 +08:00
cyh fdfadb2442 Merge upstream main; classify WithBodyReadTimeout failures
Upstream added WithBodyReadTimeout (gateway.request_body_read_timeout_seconds)
and client-gone handling for body reads. Drop this branch's own server-level
idle-timeout wrapper and server.request_body_idle_timeout setting in favor of
it, and keep the classification and diagnostics on top:

- readRequestBodyChunksWithBudget reports the read error before ctx.Err():
  on HTTP/1 a read deadline also cancels the request context, which turned
  every timeout into context.Canceled. Read errors carry bytes read and
  elapsed time in RequestBodyReadError.
- handleRequestBodyReadError and RejectRequestBodyReadError skip the
  client-gone (empty 499) path for read timeouts, so they are reported as
  408 instead of a client cancellation (HTTP/1) or a generic 400 (HTTP/2).
- Every gateway body read site and both body-reading middlewares log
  payload-free diagnostics, including the client-gone path.
2026-11-07 01:52:36 +08:00
lkon f9d1b10c2c Merge remote-tracking branch 'upstream/main' into fix/gemini-tool-response-media 2026-11-07 00:47:34 +08:00
lkon b7c0e9c90b Merge remote-tracking branch 'upstream/main' into fix/responses-message-content 2026-11-07 00:47:33 +08:00
Wesley Liddick 0eee80ba87 Merge pull request #8518 from StarryKira/codex/json-hotpath-performance
perf(gateway): reduce JSON copies and repeated request parsing
2026-11-06 18:49:10 +08:00
harukaandClaude Opus 5.5 1c83bb825a test(repository): assert the auth projection carries require_privacy_set
OpenAI scheduling now reads the privacy gate from the auth snapshot; cover
the GetByKeyForAuth projection so a dropped column fails here instead of
admitting accounts without privacy set.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-06 03:00:03 -05:00
harukaandClaude Opus 5.5 f654c23eb7 perf(gateway): decide thinking-block filtering without decoding the body
FilterThinkingBlocks runs on every Anthropic forward. Its substring fast path
matches any request with top-level thinking config or signed thinking
history, which is nearly all Claude Code traffic, so it decoded the whole body
into a map even when nothing would be filtered.

Mirror the filter decision on borrowed gjson views, applying encoding/json's
last-wins rule for duplicate keys, and return the body untouched when no block
would be dropped. Bodies that need filtering still take the original decode
and marshal path, so output bytes are unchanged; a differential test and fuzz
target compare both paths.

On a 450 KB signed history: 1.29 ms, 904 KB, 10,629 allocs -> 0.67 ms, 0 B.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-06 03:00:03 -05:00
harukaandClaude Opus 5.5 4ca1a2097c perf(openai): skip full-body decodes for Codex bootstrap and compaction
Every /v1/responses request ran the automation and delegation bootstrap
normalizers, each a json.Decoder token scan plus a full map decode, and
NormalizeCompactionTriggerInputOrder decoded the whole body on each HTTP
request and WebSocket turn, although almost none of them can change it.

- Bootstrap normalizers return early unless the raw body contains
  function_call_output and one of their tool names, or any \u escape that
  could spell them.
- The compaction normalizer returns early when the body has neither
  compaction_trigger nor a \u escape and is a valid JSON object, so invalid
  or non-object bodies still report the original decode error.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-06 03:00:03 -05:00
harukaandClaude Opus 5.5 00660a227a perf(gemini): stop copying the emitted prefix on every stream delta
computeGeminiTextDelta returned seen+incoming for each incremental chunk, so
a long thinking, text or tool-argument block copied its whole prefix per
chunk and grew quadratically.

Keep the emitted text in a strings.Builder per block. Only storage changes:
the cumulative, duplicate/rewind and delta decisions and the returned deltas
are identical, verified against the previous implementation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-06 03:00:03 -05:00
harukaandClaude Opus 5.5 d446c4a6bb fix(gemini): bound upstream SSE lines and antigravity non-stream reads
The Gemini native, Claude-compat, Chat Completions-compat and stream collector
paths read upstream SSE with bufio.Reader.ReadString, so a custom base_url
upstream that never sends a newline could grow one line without limit.

- Read these streams through boundedSSELineReader, which keeps line endings
  and EOF semantics and enforces the configured line and event limits. An
  overflow is a stream read error; no truncated prefix is forwarded.
- Thread cfg into collectGeminiSSE/collectGeminiSSEObserved.
- Antigravity ForwardUpstream reads non-stream responses with
  ReadUpstreamResponseBody instead of an unlimited io.ReadAll.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-06 03:00:03 -05:00
harukaandClaude Opus 5.5 9bb073d0d1 perf(openai): read the group privacy gate from the auth snapshot
Each OpenAI account selection read the group row twice: once to resolve
require_privacy_set into the request, and again in selectByLoadBalance,
which ignored that result.

- Project require_privacy_set into the auth snapshot (v27) and resolve it
  from the ctx group when it is the scheduled group; composite members and
  other mismatches still read the repository.
- selectByLoadBalance filters on the already-resolved req.RequirePrivacySet,
  so a failed group read is handled once, fail-closed, as in Select.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-06 03:00:03 -05:00
harukaandClaude Opus 5.5 76221c9cb0 perf(billing): stop querying the RPM override on every request
The auth snapshot stored "no override" and "lookup failed" both as nil, so
checkRPM fell back to SELECT rpm_override on nearly every gateway request.

Record the group whose override lookup succeeded (snapshot v26). checkRPM
trusts a nil override only for that group; lookup failures and other groups,
such as composite members, still query the database. Admin override writes
already invalidate the auth cache by group.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-06 03:00:03 -05:00
harukaandClaude Opus 5.5 a0b058a9e9 fix(bedrock): validate EventStream frame lengths before allocating
The decoder allocated total_length bytes straight from the upstream prelude
(up to ~4 GiB) and sliced headers by an unchecked headers_length, which could
panic in the decode goroutine outside gin's recovery and crash the process.

Reject frames whose headers exceed 128 KiB or the frame, or whose payload
exceeds 16 MiB (the AWS EventStream protocol limits), before allocating.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-06 03:00:03 -05:00
harukaandClaude Opus 5.5 0853d16036 fix(images): give async image tasks their own body memory reservation
Async tasks inherited the ingress reservation through context.WithoutCancel,
but RequestBodyLimit releases and closes it when Submit returns. The task's
request body was a plain reader, so the gateway's read reserved against the
closed reservation and every task failed with a 503 budget error.

- Add httputil.DetachRequestBodyMemory: a reservation on the same budget that
  the handler's release does not close. It takes over the retained body's
  existing charge from the request and reserves only the remainder, so the
  body is never counted twice; the caller releases it when the work ends.
- Submit reserves the retained body before creating the task, returning 503
  with Retry-After on exhaustion instead of accepting a task that cannot run;
  the task releases it when execution finishes.
- Back the task request with PrereadBody so the body is not buffered again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-06 03:00:03 -05:00
harukaandClaude Opus 5.5 957a83f32e fix(gateway): settle patch budget per attempt and keep map fallback reachable
- ApplyPatches reserves the input size before editing on every strategy
  (batched Doc, single edit, sequential sjson), settles to the exact output
  length, and refunds on failure, so batching no longer adds a rejection
  that the unoptimized paths bypass.
- Forward holds patched outputs in a WithRequestBodyMemoryScope: a newer
  output releases the superseded one and the last is returned when the
  attempt ends, instead of accumulating across failovers until the handler
  returns.
- A Doc edit error retries with sequential sjson; when raw edits cannot
  express the patch set, Forward replays it onto the decoded map rather than
  re-running ApplyPatches and failing the request.
- Snapshot reuse in CloneForBody/ReplaceBody also checks a maphash content
  fingerprint, so in-place edits of shared storage reparse.
- Reuse openAIWSPayloadStringView for borrowed views and split batch path
  eligibility into isOpenAIBatchPatchPath with an O(P^2) ancestor check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-06 03:00:03 -05:00
haruka 6c140b8976 perf(gateway): reduce JSON copies and repeated request parsing 2026-11-06 03:00:02 -05:00
hansnow 7f2876defa fix(openai): 打通 GPT Image 2.6 原生图片链路
让 2.6 走 Codex Images,保留 complexity 和原生编辑选项。兼容编辑端点返回的完整 JSON,并补齐模型目录、格式处理和计费兜底。

Fixes #8526
Closes #8534
2026-11-06 15:30:49 +08:00
wucm667 3bf2a375db chore: reconcile upstream transcript and security fixes 2026-11-06 12:41:14 +08:00
wucm667 4656364337 test(usage): assert incomplete cache streams and isolate allocation guard 2026-11-06 12:13:35 +08:00
wucm667 b25dbe3e4b chore: sync upstream main for cache usage validation 2026-11-06 12:13:35 +08:00
Yajun a8d90a72ea fix(anthropic): preserve setup-token weekly usage without 5h limits
Capture weekly usage headers independently of 5h status and before 429 window handlers return. Reuse passive snapshots for Anthropic setup-token usage queries, with regression coverage for weekly/Fable windows and existing cooldowns.
2026-11-06 11:44:33 +08:00
Wesley Liddick c5ca149a3d Merge pull request #8543 from wucm667/feat/issue-8541-openai-transport-cooldown
feat(openai): allow disabling transport error cooldown
2026-11-06 10:45:17 +08:00
Wesley Liddick 9432aa05fc Merge pull request #8549 from Wei-Shaw/fix/issue-8519-cyber-transcript-overflow
fix(openai): 按已屏蔽前缀长度精确匹配 cyber transcript,修复长会话误拦 (#8519)
2026-11-06 10:29:20 +08:00
wucm667 aa245176ae fix(openai): enforce synthesized effort ceilings and final validation 2026-11-06 10:15:12 +08:00
wucm667 fba4c193ae chore: sync upstream main for reasoning policy fix 2026-11-06 10:15:12 +08:00
shaw b6c0ca4256 chore(deps): 升级 brotli v1.2.7 与 klauspost/compress v1.20.2 修复 govulncheck 告警
GO-2026-6888 (brotli 解压过量内存分配) 与 GO-2026-6865 (zstd 双块帧 panic)
均有可达调用路径,backend-security 扫描因此失败。
2026-11-06 09:33:04 +08:00
danvilig 7f07bca99b Merge main and resolve Codex export model default 2026-11-05 16:19:22 +00:00
wucm667 489cfd5f4f feat(openai): allow disabling transport error cooldown 2026-11-05 21:55:07 +08:00
shaw 7e3b6c72fa fix(openai): 按已屏蔽前缀长度精确匹配 cyber transcript,修复长会话误拦 (#8519)
同一来源触发 cyber 屏蔽后,scope 激活期间任何历史超过 256 个 item 的
会话都会因 lookup 截断被 fail-closed 判为 transcript_lookup_limit_exceeded,
即使与被屏蔽会话毫无关系、且带有不同的显式 session_id。

改为在命中时记录 transcript 屏蔽 key 覆盖的历史长度(按 API Key 建 Redis
SET 索引,随 scope 同 TTL),查询时仅在这些长度处重算前缀哈希:
- 无关长会话不再被误拦,历史长度本身不再决定屏蔽
- 追加任意数量 item 仍能命中被屏蔽前缀,防逃逸能力不降
- 查询 MGET 由最多 256 key 降为记录长度数,遍历在最长记录长度处提前终止
- scope 门控、API Key 命名空间与 cyber-transcript:v3 哈希格式均不变
2026-11-05 21:51:26 +08:00
shaw 25608d216b chore: update sponsors 2026-11-05 17:55:19 +08:00
William DrakeandClaude Opus 5.5 0ee6b6c5d1 fix(antigravity): connection test sends the admin's prompt and lets the model answer
Every other platform's account test sends the admin's prompt (default "hi") and returns the
model's reply. The Antigravity text and Claude tests sent "." with a 1-token output cap and
ignored the prompt, so the UI showed "sent: hi" with an empty response, and thinking models
(gemini-4-argon, gemini-3.8-flash) spent the one token thinking. They now send the prompt (or
"hi") with 256 output tokens.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 20:46:03 -07:00
Wesley Liddick 8e92c892b4 Merge pull request #8495 from FeeiCN/patch-1
fix: GPT-5.5已不提供服务,默认导出模型改为GPT5.6-SOL
2026-11-05 09:34:43 +08:00
wucm667 71532bf91c fix(usage): preserve compatible cache snapshot semantics 2026-11-05 09:24:56 +08:00
Wesley Liddick 503617a82f Merge pull request #8484 from StarryKira/codex/backend-resource-safety
fix(backend): bound gateway resources and background work
2026-11-05 09:15:13 +08:00
William DrakeandClaude Opus 5.5 455751402f fix(antigravity): label Pro plans' separate Argon quota as its own row
Pro accounts report a third quota group, gemini-argon-wtu ("For paid Pro plans, Argon
quota is separate", weekly only). It was labelled like the Claude/GPT group, so the cell
showed C·weekly twice. It now shows as A·weekly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 13:35:14 -07:00
William DrakeandClaude Opus 5.5 2ce1849bdf fix(antigravity): scope INTERNAL 500 penalties to image models; make account tiers configurable
An INTERNAL 500 that survives every retry put the whole antigravity account
in the progressive penalty (30 min, 2 h, then disabled), whatever model failed.
The image endpoint (gemini-3.1-flash-image) returns this 500 far more often
than text models, so one failing image request took the account's text models
(gemini-4-argon, gemini-3.8-flash) offline for 30 minutes, and repeats could
disable the account.

- An INTERNAL 500 on an image model now cools only that model (model-level
  rate limit, default 2 min, GATEWAY_ANTIGRAVITY_INTERNAL500_IMAGE_COOLDOWN_SECONDS)
  and does not count toward the account penalty.
- The account penalty tiers can be set per deployment:
  GATEWAY_ANTIGRAVITY_INTERNAL500_TIER1_SECONDS, ..._TIER2_SECONDS and
  GATEWAY_ANTIGRAVITY_INTERNAL500_DISABLE_ACCOUNT (false repeats tier 2 instead
  of disabling). Unset, every value is the previous default.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 13:35:14 -07:00
William DrakeandClaude Opus 5.5 bf4e16b90e feat(antigravity): show each quota group's real 5-hour and weekly window
fetchAvailableModels reports one remainingFraction per model, whichever window is
tighter at the moment, so the 5-hour and the weekly limit could not be told apart:
a used-up weekly limit showed as "5h 99%" with a reset days away. The quota fetcher
now also calls v1internal:retrieveUserQuotaSummary, which reports every window of
every group (Gemini models; Claude and GPT models), and returns it as
antigravity_quota_groups. The account usage cell shows G·5h / G·weekly and
C·5h / C·weekly from it, and keeps the per-model bars when the summary is missing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 13:35:14 -07:00
haruka 457602c8fc fix(backend): bound gateway resources and background work 2026-11-04 23:54:03 +08:00
qsy4 e16e69a7c4 fix(openai-ws): record first token time for every passthrough turn
Problem: on a WS v2 passthrough connection only the first turn gets a
first_token_ms. The per-turn value was stamped in two places: together
with the connection-level first token (which only happens once per
connection), or when the token event itself carries response.id. Token
events (*.delta, response.output_text.done,
response.function_call_arguments.done) never carry response.id, so from
the second turn on every usage log and every scheduler TTFT sample of a
long-lived Codex connection is nil.

Fix: resolve the turn first (by response.id, otherwise the active turn)
and stamp that turn's first token from its own start time. The
connection-level first token is unchanged.

Test: TestRelay_OnTurnComplete_FirstTokenMsRecordedForEveryTurn replays
two real-shaped turns on one connection (deltas without response.id) and
expects each turn's first token to be measured from its own start. It
fails on the second turn without the fix.
2026-11-04 07:16:09 -08:00
shaw 876b96d204 chore: update sponsors 2026-11-04 22:31:07 +08:00
shaw 2510944363 chore: update sponsors 2026-11-04 21:06:20 +08:00
shaw e353c83226 chore: update sponsors 2026-11-04 21:04:17 +08:00