- Match Anthropic's "refresh token expired" grant description in isTerminalRefreshGrantMessage and normalize it to refresh_token_expired in terminalRefreshErrorCode so expired Claude refresh tokens mark RequiresSignIn and stop scheduling refresh retries.
- Add regression tests verifying terminal sign-in handling for Claude expired refresh tokens while preserving exponential backoff retries for generic Claude invalid_grant errors.
Closes: #7596
- Add bio_policy, cyber_policy_violation, misalignment_policy_violation, content_policy_violation, and image_content_policy_violation to request-fault codes so policy rejections stop failover without cooling down credentials.
- Unify trusted error JSON extraction across auth, model-not-found, credit-balance, and request-fault checks while restricting wrapper unwrapping and policy-text matching to prevent prompt-echo false positives.
- Map typeless policy error codes and body.error layouts consistently across Codex SSE/WebSocket, Responses, xAI, and Claude stream translation paths, filling blank messages with official fallback copy.
- Unpin and exclude the failed credential when a full response.create on a persistent Responses WebSocket fails with a pre-commit quota or auth error.
- Propagate excluded auth IDs through handler metadata into mixed and Home stream selection while blocking replay once any downstream frame is committed.
- Add regression tests for pre-commit 429 failover, post-commit non-replay, and Home repeated excluded-auth rejection.
Closes: #7585
- Add Builder.WithExecutorWrapper applied in the centralized registerExecutor gate so embedder wrappers survive startup sync, auth, and model refresh paths that bypass OnConfigApplied.
- Track the service-owned underlying executor per provider with manager revisions to preserve Claude WithConfig reuse and Codex/XAI session sharing across wrapping without double-wrapping.
- Harden replacement lifecycle for wrapped executors, including shared-session preservation, stale-ownership invalidation, and safe traversal of opaque or cyclic wrappers.
Closes: #7568
- Add ExcludeCandidates with PascalCase and snake_case ojson decoding to pluginapi.SchedulerPickResponse and preserve normalized exclusions in pluginhost when unhandled or delegated.
- Filter excluded auth IDs per selection pass in Manager before priority tiering and built-in selector evaluation so healthy lower-priority credentials can promote without mutating caller tried state.
- Add unit tests covering JSON/RPC compatibility, host normalization, priority promotion, session affinity, and cooldown/empty-pool errors.
Closes: #7535
- Detect the 403 PERMISSION_DENIED ErrorInfo reason=TOS_VIOLATION signature and mark the credential StatusDisabled + Disabled so it is excluded from rotation and persisted across restarts, while OAuth refresh stays intact; carry appeal_url/appeal_url_link_text through Error.Metadata to auth.Metadata and the management API.
- Add an optional pool-wide protective pause (antigravity.tos-pause-window, default 6h) armed only by TOS results, never by transient 429s, covering all Antigravity request paths including SSE mid-stream error frames and CountTokens.
- Distinguish terminal TOS results from stale/superseded results using a new Result.RefreshToken account hint so a same-account OAuth refresh applies the suspension while a genuine credential replacement discards it safely.
Closes: #7515
- Wrap the final 429 in a poolCooldownTerminalError at the Execute/ExecuteCount/ExecuteStream boundaries when every candidate credential for the model is blocked and at least one is in a timed cooldown, preserving the upstream error body and status while marking IsModelCooldown so the Claude handler appends the reset time.
- Compute the Retry-After from the earliest auto-recovery across all blocked candidates (including non-cooldown timed blocks) so the client sees the pool's real recovery instead of the last attempt's hint.
- Add regression coverage for both cooldown variants across the three execution paths, the available-candidate guard, mixed-block earliest deadlines, the sub-floor hint clamp, and the Claude handler end-to-end.
Closes: #7521
- Detect MALFORMED_FUNCTION_CALL, UNEXPECTED_TOOL_CALL, and MALFORMED_RESPONSE with zero visible output before bootstrap commit, reasoning replay caching, or usage finalization across Antigravity, Gemini, Vertex, and AI Studio executors.
- Withhold only contentless leading shell frames while keeping thought chunks unbuffered for TTFT, and align Claude response error handling and stream completion flags while preserving valid partial outputs.
- Add unit, executor, bootstrap failover, and cross-module HTTP regression tests covering credential rotation and HTTP 502 exhaustion.
Closes: #7513
Co-authored-by: Dylan <1990016@gmail.com>
Co-authored-by: lzt404 <2596933790@qq.com>
- Add Builder.WithPluginInterceptorHost so embedders can install a custom PluginInterceptorHost that survives startup and reload; the server wraps it to keep plugin model routing, executor dispatch, lifecycle, and websocket observers delegated to the internal plugin host.
- Add Hooks.OnConfigApplied invoked after each successful config apply so embedders can reinstall executor wrappers and other caller-owned runtime state.
- Cover the delegated interceptor host with nil-safety, skip-forwarding, capability-detection, and real execute-chain regression tests.
Closes: #7499
Co-authored-by: Dylan <1990016@gmail.com>
Co-authored-by: lzt404 <2596933790@qq.com>
- Add a lightweight per-request in-flight tracker on the auth manager that covers selection, upstream calls, retry waits, and the full stream lifetime; it stays disabled in Home mode where the execution registry is authoritative.
- Register GET /v8/management/observability/requests/in-flight returning counts only (in_flight, oldest_started_at, by_provider) with no request bodies or credential identifiers.
Closes: #7476
Co-authored-by: Dylan <1990016@gmail.com>
Co-authored-by: lzt404 <2596933790@qq.com>
- Reuse successful wire beta snapshots across thread turns and executor reloads.
- Keep continuations on their original credential and honor explicit payload/header policies.
- Recover snapshots through KV and publish state before streaming completion, with regression coverage.
Closes: #7470
Co-authored-by: Dylan <1990016@gmail.com>
Co-authored-by: lzt404 <2596933790@qq.com>
- Retain and persist rejected Claude unified quota signals alongside active cooldown deadlines so out-of-order completions, restarts, and dual-layer quota wraps keep accurate window metadata.
- Populate anthropic-ratelimit-unified-* headers on Claude quota modelCooldownError responses aligned with Retry-After while keeping SafeResponseHeaders restricted to trusted retry headers.
- Exclude non-Claude, Cloudflare challenge, and ordinary per-minute rate-limit cooldowns from unified subscription quota header synthesis across selector and scheduler paths.
Closes: #7417
Co-authored-by: Dylan <1990016@gmail.com>
Co-authored-by: lzt404 <2596933790@qq.com>
Add attempt-scoped HomeSelection metadata carrying the reused and
additional flags, scheduling route model, and credential policy
through usage records to the Redis queue. Mark retained executions
and Codex duplex successors as reused so Home can compensate later
turns after completion without redispatching or reacquiring a
concurrency slot.
Mark split additional-model records as additional so they never add
scheduling charges, while preserving independent per-response
execution IDs for deduplication. Document the deferred accounting
and add coverage across conductor, duplex, reporter, and queue.
Extend weighted pinned accounting beyond session affinity so pinned
and ordinary requests share the same credits even when affinity is
disabled. Route scheduler, legacy, mixed, and bare selector picks
through the shared weighted pool, exclude zero-weight credentials
before priority selection, and preserve single-provider transport
preference for mixed requests.
Replace string pool keys and map-based credit state with SHA-256
digest keys and sorted slice members holding weight, current, and
pending credits in a single allocation. Reservations now retain
only the member index instead of a weights map and auth ID.
Verify full pool identity on digest hits and chain collisions so
unrelated candidate pools never share credits or weights. Update
tests to access pool credits through test helpers.
Charge session-affinity hits, parent inheritance, LCP matches,
and pinned requests against the eligible weighted pool without
moving existing bindings, so new sessions favor under-served
credentials and request ratios stay approximately weighted.
Scope settled credits per eligible credential set, capped at
+/-32 pool rounds, with in-flight reservations that commit on
local selection success and release on failure.
Map IsFork metadata to X-Node-Kind: fork when dispatching to
Home so forked sessions keep their lineage kind alongside
explicit kinds such as compaction. Clone dispatch headers
before adding the Home-only header to avoid mutating caller
headers, and cover fork, compaction, and ordinary children
with session hierarchy tests.
- Normalize model state, scheduler shard, and cooldown lookups case-insensitively while preserving stored model key casing.
- Atomically migrate route-alias cooldowns to the resolved upstream model key when OAuth model aliases or credentials are updated.
- Add regression tests covering mixed-case alias targets, pre-existing alias cooldown migration, and concurrent persistence windows.
Closes: #7360
- Add optional credential_scoped metadata and documented routing/cooldown error code constants to pluginabi.Error so plugin executors can report account-wide 429 limits.
- Preserve credential-scoped classification on rpcError across synchronous RPC envelopes and streaming error callbacks while prioritizing credential quota scope over model-only or cooldown-skipping error codes.
- Recognize credential_quota error codes in core auth cooldown classification and cover whole-credential cooldown propagation and error events with regression tests.
Closes: #7359
- Add the "never" option for routing.session-affinity-rebind-on to preserve established session bindings across all credential failures and refuse cross-credential failover across primary, fallback-key, and Merkle LCP paths.
- Scope retry rounds and Antigravity credits fallback to the bound credential under "never" mode, returning 503 session_auth_retry on transient unavailability and 429 or upstream errors on quota/auth blocks.
- Add unit and end-to-end regression tests covering selector refusal, retry rounds, empty candidate sets, Antigravity credits fallback, and runtime config reload.
Closes: #7348
Preserve unknown refresh recovery state without inventing an access-token rejection. Evaluate availability for the requested partition and block missing tokens before model-level selection in both auth guards.
Cover partial refresh and later inference through real OAuth HTTP responses, CodexExecutor, and Manager execution. Auth, executor, integration, race, and build checks pass. The full suite encounters an existing WebSocket temporary-log cleanup race, reproduced on clean dev.
- Raise positive integer max_output_tokens below 16 to the Codex minimum on the translated payload across HTTP and WebSocket paths, before user payload rules.
- Send inference verification with a 16-token budget so healthy Codex OAuth credentials are no longer rejected by the upstream minimum.
- Add regression coverage for VerifyInference and small budgets from every Codex source format.
Closes: #7304
- Preserve refresh failure stages and prevent immediate or later grant replay.
- Coordinate durable claims and recovery receipts across file, PostgreSQL, Git, and S3 stores.
- Add regression coverage for retries, concurrency, persistence, and recovery.
Closes: #7289
Treat preserved terminal responses as request-scoped unless the executor
marks a credential-specific rejection. Reuse the existing request error
policy to stop credential retries, unauthorized refresh, and cooldown
without changing explicit continue rules or ordinary failover.
End stopped Home stream selections without waiting for a redispatch
release acknowledgement that could replace the original response.
Cover local and Home execute, count, stream and bootstrap paths, exact
response preservation, missing release acknowledgements, and terminal
401 refresh suppression.
Refs: router-for-me/CLIProxyAPIHome#178
- Classify HTTP 501 and typed unsupported count_tokens errors as availability-neutral in isCountTokensEndpointNotFoundError while preserving explicit model-not-found, auth, and quota cooldowns.
- Expose ErrorCode() on plugin RPC and auth error types so resultErrorFromError retains structured plugin error codes during count_tokens execution.
- Add regression tests verifying that repeated count_tokens 501 responses neither suspend inference availability nor extend active model cooldowns.
Closes: #7271
- Zero the dequeued queueItem slot in Manager.run before reslicing the queue so the backing array does not retain references to consumed request contexts and usage records while idle.
- Add a weak-pointer garbage collection regression test verifying that consumed request context payloads and record reference fields are reclaimed when the manager is idle.
Closes: #7267
- Forward terminal 429 quota and model-cooldown errors with trusted Retry-After headers when websocket credential failover is exhausted.
- Suppress 1012 HTTP replay on pinned continuation 429 failures when no alternative local or Home credential is eligible.
- Add regression tests covering multi-credential rotation, single-credential exhaustion, expired alternatives, and Home failover.
Closes: #7256
- Add `kvstore` package supporting local bbolt-backed key-value storage with automatic path normalization and lifecycle management.
- Implement controller routing order in `CurrentKVClient` to prioritize active Home KV over local bbolt storage and fall back to in-memory mode.
- Refactor home key-value helpers to delegate shared logic to the new `kvstore` package.
- Move Antigravity model discovery HTTP probing and response decoding to sdk/auth
- Add AntigravityModelCapabilityHints and persisted metadata serialization in sdk/auth
- Keep lifecycle coordination, deduplication, and registry registration in sdk/cliproxy
- Add unit tests for Antigravity model normalization, hint parsing, persistence, and probing