Commit Graph

1433 Commits

Author SHA1 Message Date
Luis Pater
508f8708d0 chore: replace standard JSON package with moego JSON throughout the project 2026-11-16 09:58:12 +08:00
Luis Pater
b4fdfdece3 chore: replace standard regexp with moego regexp throughout the project 2026-11-16 03:02:43 +08:00
Luis Pater
43806c865d fix(translator): map Claude json_schema format to output_config.format
- Route OpenAI Chat Completions response_format and Responses text.format json_schema payloads to Claude output_config.format via ojson.Doc while keeping system-prompt fallback for legacy Claude models and non-schema formats.
- Preserve optional schema name and description in a short system instruction without repeating the JSON schema body.
- Include output_config.format.schema in local Claude input token estimation and add translator and executor regression tests.

Closes: #7576
2026-11-15 22:32:47 +08:00
Luis Pater
7e82d0d1ca fix(executor): skip credential cooldown on Gemini zero-output 502 errors
- 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
2026-11-15 22:00:34 +08:00
Luis Pater
ed1c23f9ac fix(gemini): honor 429 Retry-After and RetryInfo hints in cooldown
- Extract positive HTTP 429 retry delays from Google RPC RetryInfo/ErrorInfo details, Retry-After headers, and human-readable error messages while preserving zero-delay semantics in ParseRetryDelay.
- Propagate parsed retryAfter hints on non-2xx status errors across Gemini and Vertex executors, including Gemini Interactions non-stream and stream paths.
- Add deterministic regression tests covering cooldown scheduling, Retry-After header and message parsing edge cases, and Antigravity zero-delay compatibility.

Closes: #7565
2026-11-15 16:30:38 +08:00
Luis Pater
3d1a0e0d10 fix(thinking,registry): preserve native Gemini thinkingLevel and isolate provider lookups
- Preserve ModeLevel in normalizeUserDefinedConfig for native Gemini/Interactions requests and user-defined models with explicit thinking levels.
- Enforce strict provider scoping in ModelRegistry.GetModelInfo and prioritize channel-specific static catalog fallback in LookupModelInfo.
- Add unit and Vertex executor regression tests covering user-defined Gemini thinkingLevel preservation and cross-provider shadowing.

Closes: #7558
2026-11-15 15:07:18 +08:00
Luis Pater
e96d4c4818 fix(antigravity): disable pool-wide TOS pause by default
- Only enable the protective pause when a positive duration is explicitly configured.
- Treat unset, invalid, and nonpositive windows as disabled.
2026-11-15 03:40:53 +08:00
Luis Pater
1d39a9de84 fix(translator): translate gemini response format and builtin tools for interactions
- Convert generationConfig responseModalities, imageConfig, responseMimeType, and responseSchema fields into top-level response_format entries while stripping unsupported nested fields from generation_config.
- Flatten urlContext, codeExecution, and googleSearch builtin tool options onto the tool object top level and convert searchTypes objects into snake_case search_types arrays.
- Update builtin tool tests and add translator and Gemini executor regression tests for Issue #7544.

Closes: #7544
2026-11-14 19:13:54 +08:00
Luis Pater
905e70c48b feat(executor): add Go RE2 sensitive-patterns-replace support for Antigravity, Devin, and Claude
- Add sensitive-patterns-replace configuration rules with load-time RE2 validation, comment-preserving YAML persistence, config diffing, and bounded matcher caching across Antigravity, Devin, and Claude cloak paths.
- Apply ordered non-cascading regex replacements against original text boundaries while preserving Devin original-line drop ownership and existing sensitive-words-replace semantics.

Closes: #7540
2026-11-14 16:33:48 +08:00
Luis Pater
f2efe2c413 fix(antigravity): fail signature-only zero-output streams without finishReason before HTTP 200 commit
- Stop counting signature-only empty-text parts as thought output in InspectGeminiZeroOutputPayload so leading signature-only frames stay buffered until real content arrives.
- Fail buffered candidate-bearing zero-output streams with a retryable 502 on EOF in GeminiZeroOutputStreamGuard.Finalize and harden Antigravity OpenAI streaming translation against all-null delta emission.
- Add unit, executor, and HTTP failover regression tests covering signature-only zero-output streams across downstream formats and credential rotation.

Closes: #7536
2026-11-14 14:30:19 +08:00
Luis Pater
5a351d9570 feat(antigravity): deactivate credentials on TOS_VIOLATION and add optional pool-wide protective pause
- 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
2026-11-14 04:49:56 +08:00
Luis Pater
cf07c78abd fix(gemini/antigravity): fail zero-output abnormal terminations before HTTP 200 commit
- 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>
2026-11-14 00:50:21 +08:00
Luis Pater
91aca317b0 fix(gemini): preserve thought signatures across tool-call round trips
- Restore Claude signature carriers onto their original Gemini parts with message and semantic boundaries.
- Return Gemini tool signatures in streaming and non-streaming Chat Completions responses without weakening provider compatibility.
- Cover delayed signatures, metadata, unsupported payloads, and payload-rule precedence with regression tests.

Closes: #7484
Co-authored-by: Dylan <1990016@gmail.com>
Co-authored-by: lzt404 <2596933790@qq.com>
2026-11-13 00:33:01 +08:00
Luis Pater
02ec93d004 fix(claude): preserve beta profiles across thread turns
- 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>
2026-11-12 21:07:10 +08:00
Luis Pater
f03f4cd8b0 fix(thinking): validate native responses reasoning efforts
- Normalize native Responses baseline and configuration updates against model capabilities without flattening the update timeline.
- Preserve supported efforts, suffix overrides, and final user payload rules across Codex SIWC transports.

Closes: #7478
Co-authored-by: Dylan <1990016@gmail.com>
Co-authored-by: lzt404 <2596933790@qq.com>
2026-11-12 18:09:32 +08:00
Luis Pater
a9e3ddcf02 fix(devin): fail over on empty completions and stop fake completion on canceled streams
- Classify clean-EOS zero-output completions and pre-output stream drops as HTTP 502 transient transport errors so Conductor rotates across credentials and fallback layers without cooling healthy Devin credentials, while marking mid-generation drops as stream-truncated.
- Record failed usage with any partial token details and upstream response summaries whenever unfinished Devin streams are canceled before completion instead of synthesizing fake interaction.completed events.
- Gate apply_patch error wrapping on observed patch tool-call activity and preserve stream-truncation and partial usage metadata across streaming and non-streaming failure paths.

Closes: #7442
Co-authored-by: Dylan <1990016@gmail.com>
Co-authored-by: lzt404 <2596933790@qq.com>
2026-11-11 18:02:32 +08:00
Luis Pater
1f5bf2a569 fix(codex): release refresh claims on pre-send errors and defer macOS wakes
- Classify request creation and pre-handoff connection failures separately from ambiguous post-connection errors so unsubmitted refresh grants release their journal claim and remain retryable.
- Implement owner-bound, single-attempt claim release across memory, file, PostgreSQL, Git, and S3 refresh journals while preserving replay protection for completed or uncertain exchanges.
- Apply macOS power-state readiness deferral to ordinary Codex refreshes and preserve a positive reschedule backoff in the auto-refresh manager.

Closes: #7450
Co-authored-by: Dylan <1990016@gmail.com>
Co-authored-by: lzt404 <2596933790@qq.com>
2026-11-11 17:49:05 +08:00
Luis Pater
fa11a573b2 fix(claude): make server-side fallback opt-in and surface serving models
- Gate cloaked Claude server-side fallback injection behind an opt-in upstream.claude.server-side-fallback flag (default false) while preserving explicit caller fallbacks and payload filter precedence.
- Propagate authoritative upstream serving models and ordered fallback boundary metadata across OpenAI Chat Completions and Responses streaming and non-streaming translations.
- Track mid-stream fallback transitions in Claude response-model and usage observers and add regression coverage for single-hop, multi-hop, sticky default, and refusal paths.

Closes: #7440
Co-authored-by: Dylan <1990016@gmail.com>
Co-authored-by: lzt404 <2596933790@qq.com>
2026-11-11 11:37:35 +08:00
Luis Pater
65de937cf1 feat(claude): consume Home credential_options cloak settings
- Extract Home credential_options.cloak and slice-valued cloak_sensitive_words under claudeDevicePoolMu without JSON round-tripping.
- Preserve shared DisableClaudeCloakMode defaults when cloak.mode is omitted and avoid splitting comma-containing sensitive-words.
- Report Claude cloak block additions, removals, and sensitive-words content updates in config change details.

Co-authored-by: lzt404 <2596933790@qq.com>
2026-11-11 10:15:31 +08:00
Luis Pater
9a7e1e6b41 feat(executor): add sensitive-words-replace and harden Antigravity obfuscation
- Add sensitive-words-replace map support across Antigravity, Claude cloak, and Devin configurations, runtime cloning, comment-preserving YAML persistence, v8 management endpoints, and config diffing.
- Apply single-pass longest-match-first literal replacements alongside sensitive-word obfuscation across Antigravity, Claude, and Devin executors without cascading re-scans.
- Switch Antigravity system-instruction sensitive-word obfuscation from U+200B to per-subword U+034F (CGJ) while preserving non-matching instructions, tool definitions, and conversation messages.

Closes: #7428
Co-authored-by: Dylan <1990016@gmail.com>
Co-authored-by: lzt404 <2596933790@qq.com>
2026-11-11 08:58:13 +08:00
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