- Exclude known credential quota and cooldown errors from recoverable duplex error preservation in forwardResponsesWebsocket so opts.suppressError and terminal error handling still apply after response.created.
- Add regression tests verifying usage_limit_reached and model_cooldown consult the replay guard while request and client rate-limit errors stay on the duplex path.
Closes: #7586
- 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
- Tag Gemini-family zero-output HTTP 502 errors and translated Claude MALFORMED_FUNCTION_CALL error payloads with ErrorCodeTransientTransport across Antigravity, Gemini, Vertex, and AI Studio executors so Conductor skips credential cooldown while preserving per-request rotation and cross-provider failover.
- Update existing Claude MALFORMED_FUNCTION_CALL conductor tests to assert failed execution results and failed usage metrics without placing credentials into cooldown.
- Add unit and HTTP handler regression tests verifying uncooled rotation, cross-provider failover, and groundingChunks-only Claude fallback paths across Gemini-family executors.
Closes: #7571
- 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
- Build interceptor metadata in WriteModelListResponse from the authenticated gin context (caller_scope, access_provider, frontend_auth_metadata) instead of always passing nil.
- Reuse requestCallerScope so model-list requests share the same irreversible caller handle as execution paths, enabling per-key catalog filtering including ?key= credentials.
- Forward the same metadata to the request lifecycle tracker and add regression tests for identity forwarding, metadata isolation, and unauthenticated nil metadata.
Closes: #7524
- 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>
- Capture bounded per-attempt upstream status, masked headers, response chunks, and transport or stream errors when request-log is false.
- Bind synchronized deferred capture to the HTTP request context and preserve partial HTTP bodies and WebSocket dial or reconnect failures.
- Mask Cookie headers alongside Set-Cookie so forced error logs do not expose session credentials.
Closes: #7420
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>
- Start a connection-scoped downstream Ping keepalive loop immediately after upgrading the Responses WebSocket connection instead of waiting for stream forwarding to begin.
- Guard background Ping writes with non-blocking mutex acquisition so active data writes are not contended while blocked Ping writes are still interrupted on terminal close.
- Preserve the socket cancellation cause in response forwarding and add regression coverage for post-upgrade, upstream-bootstrap, and blocked-Ping close paths.
Closes: #7407
Co-authored-by: Dylan <1990016@gmail.com>
Co-authored-by: lzt404 <2596933790@qq.com>
- Hijack mock CONNECT proxy connections before writing 200 OK and forward buffered client bytes so TLS ClientHello records are not truncated under CPU contention, while isolating Codex refresh test journals.
- Wait for client request payloads and test completion before closing mock websocket connections in Codex keepalive upload tests.
- Cancel the in-flight HTTP upstream context before writing response.incomplete downstream during local websocket interrupts.
Closes: #7379
Co-authored-by: Dylan <1990016@gmail.com>
- Track SSE event newline boundaries across streamed image chunks and suppress keep-alive comments while inside an incomplete SSE event.
- Reset streaming keep-alive tickers when downstream bytes are written and ensure terminal error events start on a clean SSE boundary.
Closes: #7330
- Skip auto-injecting hosted image_generation tools on Responses-Lite models and strip unsupported complexity fields from declared image_generation tools on ChatGPT Codex /responses requests.
- Route forced hosted image_generation turns on Responses-Lite models to the compatible GPT-Image-2 base model (default gpt-5.4-mini) with normalized reasoning configuration.
- Map upstream image_generation_user_error terminal events to HTTP 400 Bad Request with actionable remediation guidance for unsupported complexity errors.
Closes: #7270
- 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
- Start TTFT timing before invoking direct plugin executors in both non-streaming and streaming handler paths.
- Record first-packet arrival for non-streaming responses and observe protocol-aware stream chunk TTFT events before publishing usage.
Closes: #7253
- Unify Gemini filter blocks and Claude policy/cyber stop_details refusals under internal/clienterror as HTTP 400 request faults so single-prompt triggers do not cool down credentials.
- Detect Gemini mid-stream filter blocks across Antigravity, Gemini, and Gemini Vertex executors and Claude cyber policy refusals in Claude streaming diagnostics.
- Record LoggingAPIResponseError across streaming/WebSocket terminal error paths even when request-log is disabled.
- Override streaming response log status with actionable API_RESPONSE_ERROR status and prefix error-*.log files in both request-log modes.
- Replace tidwall/gjson and tidwall/sjson with github.com/MoeForge/moego/ojson
and encoding/base64 with github.com/MoeForge/moego/base64 across the main
module and examples
- Introduce cross-method *ojson.Doc request rewriting pipelines across
thinking, signature, client/codex, runtime/executor/helps, pluginhost, and
all provider executors with FinalizePayloadDoc as the final semantic barrier
- Convert all consecutive JSON mutations (>= 2 Set/SetRaw/Delete operations)
to batch edits on ojson.Doc
- Upgrade read-only byte paths to ojson.GetBytesNoCopy,
ojson.GetManyBytesNoCopy, and util.ParseGJSONBytesNoCopy with explicit
strings.Clone ownership protection across streaming and persistent state
- Use base64.StdEncoding.ValidateString for zero-allocation signature checks
and base64.EncodeDataURL for single-allocation data URL construction
- Sanitize only upstream-originated replay copies (transcript merge and tool-call repair cache entries) so another credential cannot reject them as unknown input.
- Match passthrough members by decoded key name across duplicates and escaped spellings, drop objects emptied by removal, and leave client input, downstream payloads, and invalid JSON unchanged.
Closes: #7146
Keep the error-only upstream request capture policy on the connection
context, before model routing and upstream execution begin. Check it before
accessing pooled Gin state so delayed plugin callbacks retain the policy
even after cancellation or Gin context reuse.
Preserve ordinary HTTP error capture, failed upgrade handling, and full
request logging. Cover large repeated requests, late callbacks, real
WebSocket logging, and Codex duplex routing with regression tests.
Related: #6960
Existing request interceptors wrap the full request body in a JSON RPC envelope with Base64 encoding and skip subsequent duplex WebSocket business frames, causing ~3.33x memory and CPU amplification when rewriting small fields such as Codex `<timezone>` and `<current_date>` in large contexts.
- Add schema v8 raw request body patch methods (`request.patch_body_before` and `request.patch_body_after`) and capabilities (`request_interceptor_patch_body_before/after`, `request_body_patcher_before/after`) that pass raw `Body []byte` directly across the C ABI without JSON/Base64 request wrapping
- Add `RequestBodyEdit`, `RequestBodyPatchResponse`, and `RequestBodyPatcher` in `sdk/pluginapi` with single-pass host splicing, bounds/overlap validation, `json.Valid` verification, no-op original body reuse, and sequential multi-plugin chaining
- Eliminate redundant full-body slice clones in handler/conductor request interceptor application paths
- Run before-auth and after-auth request interceptors on subsequent duplex WebSocket `response.create`, `response.append`, and `response.steer` messages
Closes: #7072
- Track the running response identity in the Codex websocket session and reject interrupts that do not target it, so an interrupt after response.completed is never forwarded upstream while turn teardown is pending.
- Gate the handler's local interrupt path by explicit turn ownership and close it before terminal payloads are written downstream, preventing fabricated response.incomplete events and silently dropped claimed frames.
- Add deterministic regression tests covering late and unknown interrupts across completion, failure, queued rejection, upstream loss, and HTTP fallback turns.
Closes: #7065
- Filter out internal metadata events such as moderation data for standard clients in OpenAI responses API and websocket streams.
- Enhance `responsesSSEFramer` and frame accumulator to robustly handle fragmented JSON payloads, empty data fields, and recovery of split SSE fields.
- Add comprehensive unit tests covering SSE metadata filtering, fragmented frame recovery, and websocket message handling.
When an upstream Codex WebSocket returns an early 429 usage_limit_reached (via an error or response.failed frame) before any downstream payload chunk is emitted, notifying UpstreamDisconnectChan caused the Responses WebSocket handler to close the client connection and cancel the request context before the conductor could fail over to another eligible credential.
Suppress downstream disconnect notification on pre-output upstream WebSocket errors and treat bootstrap usage-limit terminal failures as failover-eligible while bootstrap buffering is active, allowing the conductor to retry another credential on the same downstream WebSocket connection.
Fixes#7051
- Build un-defaulted original request payloads for xAI image generation and edit handlers and propagate them via execution context so payload default rules can distinguish omitted client fields from built-in defaults.
- Pass normalized original requests into the xAI image executor payload finalizer and report finalized response_format values back to handlers via metadata callbacks across streaming and non-streaming responses.
- Add unit and handler regression tests covering payload default, default-raw, and override rules for xAI image endpoints.
Closes: #7048
Keep the client's /v1/responses websocket open when an upstream Codex websocket drops during or between turns, report correlated non-closing error frames without replaying in-flight turns, fence pre-loss queued input across handler and executor boundaries, and preserve pinned credential affinity across Home turn releases.
Closes: #7028
- Classify Codex turn-rate and model-capacity 429s as transient per-model rate limits via a new executor contract, honour upstream Retry-After headers behind quota resets, and cool only the reporting model without quota labelling or exponential backoff.
- Carry the trusted retry deadline to terminal clients and retry scheduling across direct, streaming, bootstrap, and Home paths, keeping Home aggregated deadlines authoritative over per-attempt hints.
Closes: #7017
- Compress finalized Codex OAuth request bodies with zstd on the verified ChatGPT backend path, with size/benefit gating, header-body alignment, and one uncompressed retry on 400/415 rejection.
- Negotiate downstream HTTP response compression under server.response-compression (zstd/gzip with q-values, SSE-safe flushing, commit-time Vary merging) and enable negotiated permessage-deflate on Codex and downstream WebSockets.
- Advertise Accept-Encoding to Codex upstreams and decode gzip/deflate/br/zstd upstream responses through a shared decoder before parsing or relaying.
Closes: #6905
- Route the initial stream bootstrap read in readInitialStreamChunks through nextStreamChunk so a channel closed alongside context cancellation is reported as canceled rather than normal stream EOF.
- Add a regression test exercising ExecuteModelStream cancellation before the first deliverable chunk to verify the request lifecycle completes as canceled.
Closes: #6987
- Check whether the request context is already canceled when the stream chunk channel closes in nextStreamChunk so select randomization does not report a canceled stream as EOF.
- Add unit tests verifying that a closed stream channel with a canceled context deterministically reports cancellation while a live context reports normal stream completion.
Closes: #6979
- Drain any pending buffered error from errs via handlers.PendingStreamError before treating a closed data channel as a duplex socket close or incomplete stream timeout.
- Add regression test covering both standard and duplex websocket forwarding when errs holds a buffered error and both channels are closed.
Closes: #6981
The Codex backend now sends a response.metadata event with prompt-moderation flags.
It is not a public Responses event, and clients that parse a closed event list
(Grok Build 1.0.60 and 1.0.70: "unknown variant response.metadata") fail the
whole turn on it. Filter it for standard Responses clients like the other private
Codex events; official Codex clients still receive it.