Commit Graph

379 Commits

Author SHA1 Message Date
hkfires
5aa44948bd perf(executor): optimize payload user text replacement
Compute replacements during a single ForEach traversal and collect
only changed values before mutating the document, avoiding array
allocations and second lookups for unchanged text. Stop scanning
after the last targeted user position.
2026-11-16 15:03:59 +08:00
hkfires
f00a3d3910 feat(payload): add user text replacement payload rules
Add ordered literal replace rules that rewrite existing user
text at selected one-based positions, or all users, in the final
upstream payload after overrides and before filters.

Support OpenAI Chat, Claude, Responses/Codex, Gemini, and
Antigravity layouts while leaving system prompts, tools, images,
and thinking untouched. Validate and sanitize rule config,
preserve it through YAML/JSON and runtime cloning, surface it
in config diffs and SDK types, and document it in the example
config.
2026-11-16 13:36:40 +08:00
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Dylan
d1e5cc607a fix(codex): reject unsupported hosted image requests 2026-11-06 18:38:00 +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
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
196ca839aa Merge pull request #7231 from sususu98/feat/usage-cached-modality-tokens
feat(usage): extract cached image/audio and interactions modality tokens
2026-11-04 09:26:19 +08:00
Luis Pater
606e667a8e fix(codex): sanitize invalid characters in Codex input item IDs
- Replace characters outside `[a-zA-Z0-9_-]` with underscores during Codex input item ID normalization and prefix truncation.
- Preserve pre-sanitized prefix-normalized IDs as collision hash seeds so distinct IDs differing only in invalid characters do not collide.

Closes: #7233
2026-11-04 02:58:57 +08:00
sususu98
6d7e6a3bb9 feat(usage): extract cached image/audio and interactions modality tokens 2026-11-03 22:44:16 +08:00
Luis Pater
6d4102f33f feat(config): support native-entrypoints configuration for Claude Code clients
- Add native-entrypoints to ClaudeHeaderDefaults to allow custom entrypoints to be treated as native Claude Code clients.
- Update Claude client detection, device profile scoping, and helper request matching to respect configured native entrypoints.

Closes: #7224
2026-11-03 12:51:28 +08:00
Luis Pater
9acf81d3a6 fix(claude): drop replayed web search citations when search results are missing
- Attach request-scoped web search result cache lookup before Responses to Claude request translation so cached search hits are restored before evaluating turn citations.
- Strip web_search_result_location citations from assistant text blocks whenever a web_search_tool_result in the same assistant turn ends up without content while preserving the response text.

Closes: #7213
2026-11-03 11:21:33 +08:00
Luis Pater
e25b7dafa0 fix(devin): sanitize embedded exec tool phrases and stop retrying request-caused 403 errors
- Rewrite embedded exec_command and write_stdin phrases across all Devin tool descriptions regardless of tool name or mixed occurrences so Codex code-mode exec tools are not rejected.
- Classify Devin MCP configuration and content-policy 403 permission_denied errors as request faults in clienterror.IsRequestFault so the conductor neither retries nor cools down credentials.

Closes: #7198
2026-11-03 08:40:02 +08:00
Luis Pater
0130d6f38c fix(claude): keep Fable-only 429 rejections model-scoped when 5h headers are omitted
- Treat a rejected overage or 7d_oi response with an allowed 7d window and omitted 5h headers as model-scoped while keeping present malformed or exhausted 5h utilization credential-scoped.
- Add unit and executor regression tests verifying that Fable weekly rejections without 5h headers do not cool the credential or block sibling Opus requests.

Closes: #7197
2026-11-03 08:17:15 +08:00
Luis Pater
6e6afab99a refactor: migrate gjson, sjson, and base64 to MoeForge/moego
- 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
2026-11-03 03:05:04 +08:00
sususu
8a82bed582 fix(helps): release TransportCache mutex on builder panic and retire purged entries
Ensure TransportCache.Get and detachMatching always release c.mu via defer
when a caller-supplied callback panics, preventing the cache mutex from being
permanently wedged after recovery. Also mark entries as retired in Purge() to
match evictLocked, CloseKey, and detachMatching.

Fixes #7162
2026-11-01 20:07:46 +08:00
Luis Pater
ecbaa6c710 fix(devin): route compound fast thinking levels to upstream fast variants
- Resolve strict "<level>-fast" requests (parenthesis suffix or body thinking_level) to "<base>-<clamped-level>-fast" in ResolveDevinChatModelUID instead of silently falling back to the default effort.
- Treat a bare "fast" request as the default-effort fast variant so "(fast)" no longer resolves to the plain default UID; private aliases, special families, and the lightning tier keep their existing handling.
- Add regression coverage for the fast suffix and body-level forms plus pinning cases for private aliases and lightning models.

Closes: #7144
2026-11-01 14:27:46 +08:00
HunterSThompson
bb6e1aa8c0 fix(meta): include Muse namespace in tool-bearing requests 2026-11-01 14:27:45 +08:00
sususu
fd02b720e6 fix(proxy): stamp keepalive on uTLS dialers, rebind stale compat executors, and close retired pools outside fence lock 2026-11-01 14:20:38 +08:00