newSelectionResult is the only exit for acquired Anthropic/Gemini
selections. When hydrateSelectedAccount failed, the already acquired
Redis concurrency slot was dropped with the error because callers only
receive ReleaseFunc through a successful result.
Release it on the error path, matching the OpenAI path that already does
this via newAcquiredSelectionResult. Without the fix the slot stays
occupied until its TTL expires, so the account can look idle while
requests queue or fail.
gosec G703 flagged the cgroup path taken from /proc/self/cgroup flowing
into os.ReadFile. Read the limit files through os.Root instead, so the
path can never resolve outside the cgroup mount (including via symlinks),
and cover the escape cases in tests.
The 1 GiB default introduced in v0.2.20 is shared by every group on an
instance and stays charged for the whole streaming response, so large
hosts under high concurrency returned 503 "Request body buffering capacity
is exhausted" long before memory was actually short.
When gateway.request_body_memory_budget_bytes is set in neither the config
file nor a non-empty env var, size it to 1/4 of the process memory limit
(min of physical RAM, cgroup v1/v2 limit along the cgroup path, and
GOMEMLIMIT), never below the previous 1 GiB. Explicit values, including 0,
are used as-is. The example config no longer pins 1 GiB.
Antigravity accounts had no manual query button in the usage cell, unlike Claude
and OpenAI, and the server ignored force=true for them: getAntigravityUsage
always answered from its in-memory cache while fresh. After an upgrade or an
upstream reset the cell kept old figures (an account upgraded to Ultra still
showed its Claude week at 100%).
- getAntigravityUsage takes force; cachedAntigravityUsage skips the cache when
forced. singleflight still merges concurrent fetches.
- The antigravity cell shows the same 查询/Query button (active, force=true) in
every state, including errors.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Problem: SSE streams decide first-token time with the admin
openai_ttft_mode setting (semantic: first non-lifecycle event; visible:
first visible output), but WebSocket passthrough turns always wait for
the first ".delta" event and ignore the setting. On reasoning models the
reasoning item is announced when reasoning starts while the first delta
only arrives after it ends, so in semantic mode a WS turn reports the
reasoning time as first-token latency and an HTTP request does not. The
same user's WS turns look seconds slower than their HTTP requests, and
the gap grows with reasoning tokens while the HTTP numbers stay flat.
Fix: let RelayOptions take the first-token rule and have the passthrough
adapter pass the configured TTFT mode through the same check the SSE
path uses (openAIStreamDataStartsTTFT). codex.* frames are WebSocket-only
out-of-band events and never count; terminal events still never count,
as before. Without a rule the relay keeps the delta-based behaviour.
Test: TestOpenAIWSPassthroughFirstTokenFollowsTTFTMode replays two
reasoning turns on one passthrough connection in both modes and expects
each turn's first token at the event the SSE rule picks.
TestRelay_IsFirstTokenEventDecidesEveryTurnFirstToken checks the relay
applies the injected rule per turn and still skips terminal events.