Commit Graph

1413 Commits

Author SHA1 Message Date
Luis Pater
f77a3c104b fix(meta): pass through explicit client prompt_cache_retention
- Preserve explicit non-empty string prompt_cache_retention values from client payloads across Meta request translation while leaving omitted, null, blank, and non-string values unset without injecting 24h by default.
- Synchronize prompt_cache_retention onto the translated original request document so payload default, override, and filter rules remain the final semantic barrier.
- Document the meta protocol option and opt-in prompt_cache_retention default rule in config.example.yaml and add regression tests.

Closes: #7424
Co-authored-by: Dylan <1990016@gmail.com>
Co-authored-by: lzt404 <2596933790@qq.com>
2026-11-11 08:46:36 +08:00
Luis Pater
ece3f52a41 fix(logging): preserve bounded upstream responses in error logs
- 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>
2026-11-11 03:31:39 +08:00
Luis Pater
949b43b330 fix(xai): classify non-stream terminal SSE errors and empty or incomplete streams
- Surface upstream SSE error, response.failed, and raw JSON failure payloads through xaiStatusErr with mapped HTTP status codes instead of 408 request_timeout.
- Return request-scoped 502 errors for empty and unclosed 2xx streams without triggering transient credential cooldown.
- Avoid misclassifying empty or unclosed non-stream responses as apply_patch argument errors when no custom apply_patch activity occurred.

Closes: #7419
Co-authored-by: Dylan <1990016@gmail.com>
Co-authored-by: lzt404 <2596933790@qq.com>
2026-11-11 02:51:36 +08:00
sususu98
905637daa3 Merge pull request #7413 from sususu98/feat/codex-compat-compaction-7406
fix(codex): support local compaction for compatible Responses endpoints
2026-11-10 19:35:43 +08:00
Luis Pater
6876a2eb41 fix(claude): treat cli-bg x-app header as native claude code client
- Accept both cli and cli-bg in the native X-App header check so Claude Code background sessions preserve their native request identity instead of receiving the pinned device profile rewrite.
- Add unit and executor regression tests verifying native detection and passthrough for X-App: cli-bg across messages, streaming, count_tokens, and measured helper requests.

Closes: #7412
Co-authored-by: Dylan <1990016@gmail.com>
Co-authored-by: lzt404 <2596933790@qq.com>
2026-11-10 19:33:26 +08:00
sususu98
d576416a0d fix(compaction): strip text format constraints and configuration_update from summary requests
Clear top-level text format constraints and filter configuration_update control items when preparing local compaction summary payloads so structured JSON schemas do not overwrite the summary output.
2026-11-10 19:22:38 +08:00
sususu98
61f1ad5e3e fix(codex): support local compaction for compatible Responses endpoints
Handle compaction triggers and capsule replay locally for is-compat models while preserving native Codex behavior. Harden duplex cancellation, event ordering, response ownership, settings inheritance, model aliases, and credential failure classification.

Add HTTP, streaming, duplex, handler, usage, and deterministic concurrency regression coverage.

Fixes #7406
2026-11-10 19:22:38 +08:00
Luis Pater
f0c9c2d018 fix(claude): embed tool schemas with rejected property names in descriptions
- Detect input_schema property keys outside Claude's ^[a-zA-Z0-9_.-]{1,64}$ pattern by walking JSON Schema subschema positions in tools[] and inline tool_addition definitions.
- Replace affected schemas with an open object and embed the original schema in the tool description before payload rules, so parameters keep their exact names without request or response rewriting.
- Apply the fallback on execute, stream and count_tokens paths with regression tests for Responses and native Claude sources, MCP aliasing and payload-rule ordering.

Closes: #7389
Co-authored-by: Dylan <1990016@gmail.com>
Co-authored-by: lzt404 <2596933790@qq.com>
2026-11-10 18:51:42 +08:00
Luis Pater
0e0cab0de6 fix(openai): inject placeholder reasoning_content for compat Claude tool calls
- Add a single-space reasoning_content placeholder on assistant tool-call turns without replayable thinking text when is-compat and request reasoning are active.
- Reconcile tool-call placeholder reasoning after canonical thinking resolution so model suffixes and capability normalization govern final inclusion before payload rules.
- Add unit and executor regression tests covering absent/whitespace thinking, disabled thinking, suffix overrides, and final payload overrides/filters.

Closes: #7398
Co-authored-by: Dylan <1990016@gmail.com>
2026-11-10 16:39:16 +08:00
sususu98
18883a57b4 fix(usage,auth): propagate request-scoped error rule classification to usage fail.code 2026-11-10 14:17:12 +08:00
Luis Pater
13fdcc5e09 fix(thinking): recognize claude thinking.display updates in summary pipeline
- Treat thinking.display="updates" as an enabled reasoning summary mode when extracting Claude summary configuration so translated requests emit target visibility controls such as Antigravity includeThoughts.
- Preserve an existing "updates" display mode when applying enabled summary configuration back onto Claude request documents instead of overwriting it with "summarized".
- Add unit and cross-protocol translation regression tests for Claude thinking.display="updates".

Closes: #7393
Co-authored-by: Dylan <1990016@gmail.com>
2026-11-10 10:56:32 +08:00
Luis Pater
6db7d4b839 fix(claude): extend preserved thinking and per-turn timing gates to Claude Fable 5.2
- Include claude-fable-5-2 in preserved-thinking block binding so replayed signed thinking blocks default to drop_block on prefix mismatch.
- Consolidate 2.1.321 per-turn effort and timing model capability checks to cover Fable 5.2, Sonnet 5.5, and Mythos 5.2 while keeping Haiku 5.5 excluded from timing.
- Update the baseline software profile test failure message to match 0.128.0/v26.12.1 and add regression tests for 2.1.321 timing and preserved thinking.

Closes: #7386
Co-authored-by: Dylan <1990016@gmail.com>
2026-11-10 08:28:13 +08:00
Luis Pater
1649a002aa Merge pull request #7392 from adamentwistle/fix/claude-cli-baseline-2.1.321
fix(claude): bump Claude Code CLI fingerprint baseline to 2.1.321
2026-11-10 08:20:59 +08:00
Adam
b4e7dbd2c9 fix(claude): bump Claude Code CLI fingerprint baseline to 2.1.321
Anthropic now rejects claude-fable-5-2 from Claude Code versions older than
2.1.290, so every cloaked (non-Claude-Code) request for the model failed with
400 "Claude Code 2.1.280 does not support this model".

Update the emulated CLI baseline to the measured 2.1.321 release:
- User-Agent claude-cli/2.1.321, Stainless package 0.128.0, runtime v26.12.1,
  billing cc_version and default fallback version.
- Rebuild Anthropic-Beta assembly from native 2.1.321 captures:
  thinking-token-count moves after advisor-tool, effort precedes
  dangerous-tool-use, message-threads is added when the body carries a thread
  object, mid-conversation-system is only sent when requested, and the quota
  probe omits the claude-code beta.
- Recognize Fable 5.2 and Haiku 5.5 for progress display, per-turn control and
  effort handling, matching the observed client.
- Add a regression test that reproduces each captured 2.1.321 beta header and
  the billing fingerprint.

Fixes #7386
2026-11-10 00:03:55 +00:00
Luis Pater
714f052618 fix(codex): allow hosted image_generation injection on standard Responses without reasoning
- gate automatic image_generation tool injection for use_responses_lite catalog models on actual Responses-Lite routing (including credential and model header overrides) or presence of reasoning effort
- retract untouched auto-injected image_generation tools during single-pass payload finalization when user payload rules configure reasoning effort or switch to an incompatible route
- update Codex executor and payload barrier regression tests across HTTP and WebSocket streaming and non-streaming paths

Closes: #7384
Co-authored-by: Dylan <1990016@gmail.com>
2026-11-10 04:00:28 +08:00
Luis Pater
8de6e3fe3e Merge pull request #7378 from ngvoicu/fix/devin-usage-cache-write
fix(devin): count cache-write tokens in total input
2026-11-10 02:55:57 +08:00
Luis Pater
2c4322c7f0 Merge pull request #7380 from router-for-me/auth
feat(auth): account for pinned and reused traffic in weighted routing
2026-11-09 23:05:55 +08:00
Luis Pater
23e31fe288 fix(executor): stabilize Codex refresh and websocket tests under CPU contention
- 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>
2026-11-09 22:44:41 +08:00
Luis Pater
beb4335954 fix(claude): materialize top-level cache_control in cloaked requests
- Move top-level automatic prompt caching markers onto the last cacheable block and remove the top-level field during ensureCacheControl so cloaked requests avoid TTL mismatches and duplicate breakpoints.
- Extend the Claude cache_control stream scanner and helper routines to account for top-level cache_control when counting, enforcing the 4-block limit, and normalizing or upgrading TTLs.

Closes: #7366
Co-authored-by: Dylan <1990016@gmail.com>
2026-11-09 22:44:37 +08:00
hkfires
216f2947fc feat(home): report reused dispatch turns in usage
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.
2026-11-09 22:31:47 +08:00
sususu98
bce665d7c9 Merge pull request #7374 from sususu98/feat/asymmetric-signature-replay
feat(gemini): support asymmetric thoughtSignature replay KV across Gemini executors and eliminate KV double base64 encoding
2026-11-09 18:57:59 +08:00
sususu98
cc95661ce4 feat(gemini): support asymmetric thoughtSignature replay KV across Gemini executors 2026-11-09 18:54:46 +08:00
Dylan
5930433014 fix(claude): retain request fields with stabilized client profiles 2026-11-09 18:02:40 +08:00
Dylan
542a525fcf fix(claude): recognize native client user-agent extensions 2026-11-09 18:02:40 +08:00
Gabriel Voicu
eb6e25abe6 fix(devin): count cache-write tokens in total input
Devin reports the prompt in three disjoint parts: uncached (field 2), cache
write (field 4) and cache read (field 5). The executor summed only uncached +
cache read, so a cache miss on the GPT route (almost all cache write)
reported ~3 input tokens for a full prompt, and the Claude route lost the
written part on every first request. CPA's own token accounting expects the
total to include writes and marked those responses inconsistent; the
Claude-format translator already subtracts read + write from the total.

Live: GPT-6.1 Sol miss was 3 uncached + 6103 written, reported as 3 input;
the next request read 6103 of 6106. Updates the #5910 regression test.
2026-11-09 11:32:35 +02:00
sususu98
f36b195e7e perf(antigravity): skip reasoning replay KV for symmetric gemini/interactions protocols 2026-11-09 09:57:21 +08:00
Luis Pater
2c5b01f439 fix(claude): disable default upstream connection reuse and revert post-stream draining
- Revert post-message_stop response body draining and detachable request context from Claude streaming execution so completed streams close immediately instead of returning connections to the idle pool.
- Set MaxIdleConnsPerHost to -1 on the default Claude Code uTLS transport to disable idle connection reuse for OAuth and unpooled credentials while preserving the Connection: keep-alive wire header and explicit connection-pool opt-in.
- Add regression tests verifying short-lived default Claude Code connections, explicit per-key pool reuse, and non-reused streaming connections.

Closes: #7357
2026-11-09 02:46:14 +08:00
Luis Pater
09b3a57981 fix(codex): harden SIWC refresh deferral and expires_in parsing
- Parse expires_in with finite/range checks to prevent duration overflow.
- Introduce ErrSIWCRefreshDeferred sentinel and add macOS pmset deferral diagnostics.
- Expand regression tests and reduce SIWC renewal completion log noise.
2026-11-08 05:06:59 +08:00
Luis Pater
466b28dabc Merge branch 'codex/pr-7311' into dev 2026-11-08 04:48:23 +08:00
Luis Pater
e6931d51e3 fix(translator): preserve standalone Claude output_config.effort on OpenAI requests
- Map explicit output_config.effort to reasoning_effort in ConvertClaudeRequestToOpenAI when the thinking object is omitted.
- Preserve existing budget_tokens, disabled thinking, model suffix, and final payload rule precedence across translation and thinking stages.
- Add regression tests for standalone effort translation, chained thinking normalization, and finalized OpenAICompatExecutor payloads.

Closes: #7327
2026-11-07 23:33:09 +08:00
Luis Pater
ce38c75c62 fix(claude): drain streamed response body after message_stop to reuse upstream connections
- Add NewDetachableContext in executor helpers so upstream requests follow downstream cancellation until message_stop and detach afterward before the handler cancels the request context.
- Close the output stream channel first and then drain up to 64 KiB of the remaining raw upstream response body to EOF so net/http returns completed streaming connections to the idle pool.
- Treat valid message_stop data lines in the translated streaming path as completion before translation so terminal-event cancellation does not abort connection pooling.

Closes: #7326
2026-11-07 21:39:22 +08:00
Luis Pater
277628193f fix(claude): keep mid-session responses system items in place to preserve prompt cache
- Emit mid-session text-only system and developer message items as role=system turns immediately after the next user message while preserving source order for top-level fallbacks.
- Pin system item placement in the Claude executor before translation so legacy models, strict or uncloaked wire policies, mid-system rebuilds, and local token counts retain the top-level path.
- Centralize the legacy system-reminder model allowlist in internal/util for shared lookup across the translator and executor.

Closes: #7310
2026-11-07 12:19:47 +08:00
Jehuda Rajasa
03c394ee3f test(codex): make SIWC power-state checks deterministic 2026-11-07 01:23:36 +07:00
Jehuda Rajasa
80ee739f33 fix(codex): preserve SIWC rotations and honor renewal windows 2026-11-07 01:23:01 +07:00
Luis Pater
bfac85864c fix(codex): normalize small output budgets for all source formats
- 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
2026-11-07 01:57:53 +08:00
Luis Pater
68cd75724e fix(codex): prevent replay after uncertain refresh outcomes
- 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
2026-11-07 01:44:42 +08:00
Dylan
d1e5cc607a fix(codex): reject unsupported hosted image requests 2026-11-06 18:38:00 +08:00
Luis Pater
fb77445f04 fix(executor): support Codex remote compaction v2 on native Devin route
- Detect compaction_trigger in DevinExecutor Execute/ExecuteStream, generate the summary through the same Devin model, and synthesize a sealed single-item compaction response and SSE stream via the shared helpers.
- Expand replayed CPA compaction capsules into summary context before translation and drop foreign compaction items, so repeated compaction keeps prior context.
- Add a native Devin regression test covering streaming/non-streaming triggers, summary history and tool preservation, payload-rule final barrier, capsule replay, repeated compaction, and OriginalRequest-only triggers.

Closes: #7291
2026-11-06 17:49:19 +08:00
Luis Pater
9be48133ed fix(codex): normalize small claude output budgets
- Raise small Claude output budgets to the Codex minimum before payload rules.
- Cover model selection and budget boundaries across HTTP and WebSocket paths.

Closes: #7282
2026-11-06 09:47:36 +08:00
Luis Pater
55c05f7033 fix(claude): correct gemini tool result and signature translation
- Place Gemini tool results in user messages while preserving call pairing.
- Omit incompatible thought signatures and normalize native Base64 for Go clients.

Closes: #7279
2026-11-06 09:24:42 +08:00
Luis Pater
c2f402b456 fix(meta): send X-Tbh-Contributor-Mode header only for contributor models
- Remove the unconditional X-Tbh-Contributor-Mode header from applyMetaClientIdentity so standard Meta model requests do not send the training opt-in signal.
- Resolve the effective upstream model after payload rules and set X-Tbh-Contributor-Mode: 1 only when the target model ends with -contributor.
- Add regression tests covering standard and -contributor models across Execute, ExecuteStream, and payload model overrides.

Closes: #7272
2026-11-05 19:37:31 +08:00
sususu98
a3c84a37c3 feat(devin): update devin_models.json with swe-2-flash, nemotron-3-5-super, and gpt-6-1-terra 2026-11-05 19:23:39 +08:00
Luis Pater
8fb60326f4 fix(codex): handle Responses-Lite hosted image_generation compatibility
- 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
2026-11-05 18:28:39 +08:00
sususu98
dfe8b182c5 fix(codex,auth): bypass SIWC for OpenAI image requests and route directly to Codex images endpoint 2026-11-05 10:27:44 +08:00
sususu98
6897eebd50 Merge pull request #7242 from sususu98/fix/cyber-block-request-fault-and-error-log
fix(clienterror,logging): classify mid-stream cyber blocks as 400 and persist error logs
2026-11-05 09:53:35 +08:00
sususu98
be69162478 fix(executor,logging): preserve Antigravity usage evidence, sparse Claude refusal identity, and Home stream error logs 2026-11-05 09:51:14 +08:00
赵铕杭
7a7d37ecb5 feat(codex): add support for gpt-image-2.6 models 2026-11-05 08:59:25 +08:00
Luis Pater
e6e5708e67 feat(claude): persist cloaked session date pins in persistent KV store
- Add `IsClaudeSessionDatePinKVActive` and integrate persistent KV store backing for Claude session date pins.
- Ignore `session-date-pin-days` and store pins permanently when local bbolt or Home KV is active.
- Support concurrent CAS-based repair and transient outage recovery for pinned session dates.

Closes: #6799
2026-11-04 23:58:05 +08:00
Luis Pater
d57270f465 fix(executor): support Codex remote compaction v2 on openai-compatible routes
- Synthesize sealed compaction responses and SSE streams in OpenAICompatExecutor when Responses requests carry a compaction_trigger item.
- Expand replayed CPA compaction capsules into developer context messages before Chat Completions translation and strip additional_tools from summary requests.

Closes: #7248
2026-11-04 23:33:59 +08:00
sususu98
508ac2bce0 fix(executor,handlers): require stream-level evidence for Gemini filter blocks and pre-log terminal chunk errors 2026-11-04 19:16:14 +08:00