Commit Graph

1386 Commits

Author SHA1 Message Date
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
sususu98
03a8743c3c fix(executor): classify non-stream Claude policy refusals as 400 request faults 2026-11-04 18:59:04 +08:00
sususu98
0a94b2aefb fix(logging,executor): preserve Claude Fast classified error status and cap deferred body buffering 2026-11-04 18:26:51 +08:00
sususu98
c3938b72bd fix(logging,clienterror): classify mid-stream cyber blocks as 400 and persist error logs
- 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.
2026-11-04 18:14:30 +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
Luis Pater
061ffe6fbc fix(devin): honor Claude mid-conversation effort directives when selecting model variants
- Override the translated top-level placeholder thinking level with thinking.ClaudeEffortDirective in DevinExecutor for Claude-sourced requests.
- Preserve model suffix precedence and disabled thinking handling when resolving the Devin upstream chat model UID.

Closes: #7235
2026-11-04 02:47:20 +08:00
sususu98
6d7e6a3bb9 feat(usage): extract cached image/audio and interactions modality tokens 2026-11-03 22:44:16 +08:00
Luis Pater
01b24f1f95 fix(codex): preserve and forward max_output_tokens across request translators
- Update Codex request translators for OpenAI, Claude, Gemini, Interactions, and OpenAI Responses to correctly extract and preserve `max_output_tokens` or equivalent token limit fields.
- Remove automatic deletion of `max_output_tokens` during request cleanup to ensure token limits are respected across execution paths.

Closes: #7230
2026-11-03 20:24:19 +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
sususu98
32e3fd550d Merge pull request #7164 from sususu98/fix/transport-cache-panic-unlock-7162
fix(helps): release TransportCache mutex on builder panic and retire purged entries
2026-11-02 17:52:55 +08:00
Luis Pater
00b7677102 fix(translator): preserve developer roles in responses to chat completions
- Preserve original developer message roles, content, and relative positions when converting OpenAI Responses input items to Chat Completions messages while keeping unsupported attachment refusal scoped to user turns.
- Add translator and openai-compat executor regression tests covering system, developer, user, assistant, and tool-call message ordering across streaming and non-streaming requests.

Closes: #7174
2026-11-02 01:03:01 +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
a96e640d88 fix(auth): keep sign-in-required Codex credentials quarantined across manual refresh
- Fail forced refreshes when rejected refresh tokens remain unchanged without disk rotation and preserve rejected access token markers across no-op refreshes.
- Require a valid active access token when sign-in is required before restoring active routing status during refresh and lifecycle updates.
- Return the redacted credential entry view from the v8 management credential refresh endpoint.

Closes: #7135
2026-11-01 14:27:47 +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
HunterSThompson
5d8fddd338 chore(meta): match Muse Code 1.4.14 client headers
Subscription keys return HTTP 403 client_attestation_denied when the
request still looks like muse-build/1.3.0. Stamp the headers captured
from Muse Code 1.4.14-R7309.1: muse-build/1.4.14, X-Client-Id tbh:exec,
and a fresh session id set.
2026-11-01 14:27:43 +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
sususu
893958e401 fix(proxy): decline pooling when http.DefaultTransport is not *http.Transport 2026-11-01 14:14:16 +08:00
sususu
6c231c2332 fix(proxy): lazily allocate uTLS pools and close fenced transports 2026-11-01 14:14:16 +08:00
sususu
638f5f55e0 fix(proxy): honour per-key pool opt-in and isolate pools per runtime
- Keep an empty connection-pool block as an opt-in. Synthesising it to nil
  silently disabled pooling for `connection-pool: {}` and for keys inheriting
  an empty group block.
- Fold the transport kind into the pool key and pool the Claude Code uTLS
  transport per credential. Anthropic upstreams previously shared one
  transport across keys and ignored the key's pool settings.
- Fence generations per publisher instead of process-wide. Building or
  reloading one service no longer retires the pools another service is
  still serving, which degraded it to one transport per request.
2026-11-01 14:14:16 +08:00
sususu
34a01b7602 feat(proxy): pool upstream transports per api key
Give the generic proxy-aware clients a reusable transport per api-key
credential, driven by the `connection-pool` block added in the previous commit.

- Pools are keyed by credential scope (auth ID, then path/source, then a digest
  of refresh/access/API-key material, then anonymous), normalized proxy target
  (authenticated proxies fold a SHA-256 digest of user:pass into the key so each
  proxy identity or sticky-session username keeps its own pool without storing
  plaintext secrets in the cache key or logs), and the resolved settings. Two
  keys therefore never share a TCP/TLS connection regardless of whether the
  proxy is unauthenticated, authenticated, direct, or inherited.
- Capacity is a 512-entry LRU: one key keeps a warm pool, 100 keys keep one each,
  and 100000 keys fall back to the historical one-transport-per-request behavior
  when the cache is full. Each transport is bounded to MaxIdleConnsPerHost
  instead of the cloned default of 100 idle sockets, so idle sockets stay at
  capacity*max no matter how many keys exist.
- Dead peers are detected without request timeouts: 30s TCP keepalive on every
  dialed connection (including SOCKS5, which used proxy.Direct before) plus the
  idle timeout, 300s by default. Measured against ollama.com, an idle pooled
  connection was still reusable after 600s; the 90s that used to bound this path
  was net/http's own IdleConnTimeout, not an upstream limit.
- Explicit 0 or negative values disable keep-alives (including when proxy-url is
  empty), invalid durations are parsed once per pool instead of warning per
  request, and pooling works with or without an explicit proxy-url while keeping
  priority for context-injected RoundTrippers when proxy-url is empty.
- Config snapshots carry a generation so a request holding an obsolete snapshot
  cannot repopulate the cache after a reload. Generation 0 means the config never
  passed the fence and stays poolable, so callers that build their own config are
  not silently downgraded.
2026-11-01 14:14:16 +08:00
Luis Pater
b63322b9c3 fix(registry): preserve explicit thinkingLevel on Antigravity Claude 5.5 models
- Add supported thinking levels (`low`, `medium`, `high`) to the Antigravity `claude-opus-5-5-high` and `claude-sonnet-5-5-high` model definitions so hybrid capability validation preserves explicit `thinkingLevel` settings instead of converting them to `thinkingBudget`.
- Add regression tests covering `ApplyRequestThinking` and streaming/non-streaming Antigravity executor requests for both Claude 5.5 models.

Closes: #7133
2026-11-01 13:45:03 +08:00
Luis Pater
cc4b9949e7 feat(claude): add opt-in visible Codex commentary with preserved replay
- Add `client.claude.show-codex-commentary` config and propagate the request-scoped display policy through HTTP and WebSocket Codex executors.
- Mirror public Codex `commentary` messages into visible Claude text blocks alongside the `cpa:commentary:v1` thinking marker in streaming and non-streaming responses without altering genuine reasoning or token accounting.
- Deduplicate only the exact adjacent mirrored commentary text block during Claude-to-Codex request replay when enabled.

Closes: #7129
2026-10-31 10:04:12 +08:00