Commit Graph

1278 Commits

Author SHA1 Message Date
Luis Pater
c2dfec28d5 fix(claude): map model_context_window_exceeded to length in chat completions
- Map Claude model_context_window_exceeded stop reason to finish_reason length in OpenAI Chat Completions and remove the synthetic context_length_exceeded HTTP 400 error path so generated content, tool calls, and usage are preserved.
- Preserve finish_reason length when non-streaming Chat Completions responses are truncated inside a tool call by max_tokens or model_context_window_exceeded.

Closes: #6861
2026-10-22 17:21:21 +08:00
Luis Pater
9e79552fb7 fix(codex): hold response.metadata during stream bootstrap buffering
- Add response.metadata to isCodexBootstrapBufferableEvent so prompt-moderation metadata frames do not prematurely release uncommitted Codex streams before server_is_overloaded rejections.
- Add unit tests covering response.metadata classification and bootstrap overload failover across SSE and WebSocket transports.

Closes: #6856
2026-10-22 11:55:16 +08:00
Luis Pater
b9bb031dcb fix(openai): reauthorize responses websocket turns and support denied status
- Re-run AccessManager authentication before each responses websocket turn and duplex continuation using a cloned POST request with handshake headers stripped.
- Add AuthErrorCodeDenied and NewDeniedError in sdk/access so terminal provider refusals preserve their HTTP status and stop the provider chain.
- Add DenyStatusCode and DenyMessage to pluginapi.FrontendAuthResponse and map explicit plugin denials in accessAdapter.Authenticate.

Closes: #6843
2026-10-22 03:41:06 +08:00
Luis Pater
0db1902557 fix(codex): use original oauth credentials for alpha search
- Select the original OAuth partition for ChatGPT Alpha Search without changing SIWC Responses behavior.
- Reject missing original OAuth tokens before sending and preserve existing API-key and custom-header behavior.
- Add real-executor transport and API regression coverage for credential partition isolation.

Closes: #6830
2026-10-21 23:04:23 +08:00
Luis Pater
009f8d7ae3 fix(thinking): preserve standalone Claude effort on Codex requests
- Honor explicit output_config.effort without thinking in Claude parsing and Codex translation.
- Preserve native Claude thinking defaults and existing budget, suffix, and payload rule priorities.
- Add regression coverage for standalone effort and finalized streaming and non-streaming requests.

Closes: #6827
2026-10-21 20:19:05 +08:00
Luis Pater
80aa2b1d17 fix(antigravity): preserve tool call replay continuity and caller isolation
- Keep stream tool indices unique and retain tool declarations when tool choice is none.
- Decouple OpenAI replay history from current tool policy while preserving context checks and caller isolation.
- Add two-turn regression coverage for signature replay, session aliases, and final payload rules.

Closes: #6825
2026-10-21 18:16:58 +08:00
Luis Pater
b12db8c3d8 fix(gemini): preserve usage after terminal stream cancellation
- Treat cancellation after an emitted terminal event as successful completion while retaining observed token usage.
- Preserve buffered usage on genuine stream failures and share terminal detection with Vertex.
- Add regression coverage for terminal disconnects, EOF, usage tails, and read errors.

Closes: #6821
2026-10-21 10:33:05 +08:00
Luis Pater
df07b1e598 fix(claude): drop empty text blocks and skip them during cache_control injection
- Filter out empty and whitespace-only text parts in OpenAI Responses and Chat Completions to Claude request translators while preserving preceding block cache_control ordering.
- Ensure automatic and message-level cache_control injection skips empty or whitespace-only text blocks and stamps the last eligible non-empty block.

Closes: #6820
2026-10-21 08:44:10 +08:00
Luis Pater
06fd5b8bc2 feat(management): add read-only SIWC credential status endpoint
- Persist the real SIWC token expiration time from expires_in and evaluate local SIWC status using real expiration (or JWT exp) and upstream 401 rejection state without triggering network requests.
- Track SIWC token rejections independently from outer Codex OAuth refreshes, execution retries, and use_siwc toggles until the SIWC token is replaced.
- Expose the read-only v8 management SIWC status endpoint and summary field for Codex credentials.

Closes: #6819
2026-10-21 08:07:38 +08:00
Luis Pater
d44f8682bc feat(vertex): support per-model and per-credential openapi routing settings
- Add per-model and per-credential openapi and openapi-location settings across Vertex API-key configs, OAuth model aliases/settings, and service-account auth files with precedence over automatic publisher detection.
- Preserve alias-specific OpenAPI overrides across credential prefixes, thinking suffixes, and mixed model arrays while synchronizing explicit OpenAPI location overrides in full and short base URLs.
- Populate publisher ownership and default reasoning levels for Vertex OpenAPI models registered via vertex-api-key configurations.

Closes: #6763
2026-10-21 02:19:42 +08:00
Luis Pater
20c9095cac fix(claude): treat sdk-ts as native Claude Code and preserve caller headers under cloak_mode never
- Allowlist the sdk-ts Agent SDK entrypoint and recognize its measured Haiku 5.5 helper requests so genuine Claude Code traffic passes through uncloaked.
- Preserve plausible newer Stainless SDK and runtime versions for confirmed clients and retain confirmed-shape caller headers when cloak_mode is never.
- Recognize the Agent SDK CLI identity prompt block alongside existing Claude Code identity strings.

Closes: #6812
2026-10-21 01:11:27 +08:00
Luis Pater
3870639096 fix(translator): preserve gemini thought signatures across openai chat translations
- Map Gemini functionCall thoughtSignature fields to OpenAI tool_calls extra_content.google.thought_signature when translating Gemini requests to OpenAI chat completions.
- Restore OpenAI tool_calls thought signatures onto Gemini functionCall parts across both non-streaming and streaming response translations while preserving deterministic tool call ordering.

Closes: #6807
2026-10-21 00:29:47 +08:00
Luis Pater
cddc9bb814 fix(claude): scope web search result cache by upstream credential
- Include a hash of the selected upstream credential identity in claudeWebSearchResultCacheScope so cached encrypted_content is only restored for the credential that produced it.
- Pass auth into web search result cache scope resolution across Execute, ExecuteStream, and CountTokens paths and add regression coverage for credential switching.

Closes: #6810
2026-10-21 00:23:55 +08:00
Luis Pater
aadb34f916 fix(claude): map refusal, context window and pause_turn stop reasons; honor parallel_tool_calls
- Map Claude refusal, model_context_window_exceeded, and pause_turn stop reasons across OpenAI Responses and Chat Completions translators, executors, and streaming handlers.
- Preserve paused server-side web search turns on continuation and map OpenAI Responses parallel_tool_calls=false to Claude tool_choice.disable_parallel_tool_use=true.

Closes: #6800
2026-10-20 23:42:36 +08:00
Dylan
02e9e85204 fix(antigravity): align Hub requests and invalidate versioned model caches
Include the captured client User-Agent in model capability cache and backoff
keys, discard obsolete publications, and cancel stale probes on refresh.

Use release-specific Hub changelists and the daily loadCodeAssist endpoint
for project discovery and credits queries.

Refs #6619
2026-10-20 18:46:02 +08:00
Dylan
c6447551e7 Merge pull request #6794 from router-for-me/fix/meta-stream-ttft
fix(meta): measure streaming TTFT on effective token frames
2026-10-20 17:35:33 +08:00
Dylan
f434192a68 fix(executor): count completed reasoning items toward TTFT
Responses reasoning emitted only in response.output_item.done was ignored
until a later token or terminal event. Count non-empty summary and content
text in the shared classifier while excluding empty and encrypted-only
items.

Add deterministic coverage for Meta Responses and Claude downstreams,
classification boundaries, and preservation of an earlier token time.
Refresh the bootstrap-buffering comment to match the shared helper.

Refs #6664
2026-10-20 17:17:41 +08:00
Luis Pater
5026f36531 feat(executor): pass through downstream User-Agent and set default xAI User-Agent
- Forward downstream User-Agent headers in xAI non-CLI-proxy and WebSocket requests with fallback to the Grok workspace User-Agent instead of Go's default HTTP client User-Agent.
- Forward downstream User-Agent headers in OpenAI-compatible requests while retaining cli-proxy-openai-compat as the fallback and preserving custom header overrides.

Closes: #6791
2026-10-20 17:05:03 +08:00
Dylan
9d463e39f0 fix(meta): measure streaming TTFT on effective token frames
Meta streaming armed protocol-aware TTFT tracking but never observed token
events, so usage records kept the first-body-byte fallback even when
substantive output arrived later. Observe Responses events before failure
publication and translation using the existing shared helper.

Add deterministic virtual-clock coverage for content, terminal events,
error fallbacks, downstream translation, and non-streaming timing.

Fixes #6664
2026-10-20 16:57:14 +08:00
sususu
e198f3cd4c fix(usage): parse flat reasoning_tokens dialect in OpenAI-compat usage (SGLang)
SGLang's OpenAI-compatible server emits reasoning tokens flat on the
usage object instead of nesting them in completion_tokens_details /
output_tokens_details, so the keeper recorded reasoning_tokens=0 for
affected upstreams. Add a third fallback plus bucket detection for the
flat key; regression included.

Fixes #6792
2026-10-20 12:25:57 +08:00
Luis Pater
344e0ef929 feat(executor): support Codex remote-compaction v2 on Kimi and Meta Responses routes
- Intercept compaction_trigger items on Kimi and Meta OpenAI Responses execution paths to synthesize sealed CPA compaction capsules and reject incomplete upstream summaries.
- Expand replayed CPA compaction capsules into developer context messages and drop foreign compaction items across Kimi and Meta execution and token-counting paths.

Closes: #6781
2026-10-19 22:07:14 +08:00
Luis Pater
ab9c06b42e feat(cache): add Home KV support to Claude web search result cache
- Store and retrieve cached Claude web search results via Home KV with sliding TTL expiration when Home mode is enabled.
- Propagate request context through Claude web search result recording and restoration helpers in execution and token-counting paths.

Closes: #6780
2026-10-19 21:57:53 +08:00
Luis Pater
e7d4c7316f fix(codex): reconcile replayed web_search_call history with tool declarations
- Inject a web_search tool declaration for standard Codex requests when input replays web_search_call items without a web_search tool so upstream response protection remains available during compaction.
- Strip replayed web_search_call items from Responses Lite requests where top-level hosted tool declarations are omitted.

Closes: #6770
2026-10-19 19:00:41 +08:00
Luis Pater
084b9ca717 feat(claude): strip Claude Code identity on API keys with cloak mode never or uncloak
- Strip incoming Claude Code billing attribution, CLI identity system blocks, metadata user IDs, and diagnostics when a non-CLI API key explicitly configures cloak mode as never or uncloak.
- Remove Claude Code CLI headers, beta flags, and user-agent strings on uncloaked API key requests while preserving capability betas and credential header overrides.
- Keep global disable-claude-cloak-mode passthrough behavior unchanged for credentials without explicit per-key cloak configuration.

Closes: #6762
2026-10-19 12:59:13 +08:00
Luis Pater
d9451cb65d feat(vertex): support partner and open models via endpoints/openapi route
- Route Vertex partner/open MaaS models and explicit openapi-enabled credentials through the OpenAI-compatible endpoints/openapi endpoint while reusing service-account OAuth token acquisition and supporting openapi_location overrides.
- Register Vertex service-account MaaS models and aliases from credential metadata and OAuth alias rules so partner models are discoverable and routable.
- Normalize Vertex OpenAPI model identifiers and reject static API keys against official Google Vertex OpenAPI hosts that require OAuth tokens.

Closes: #6763
2026-10-19 12:56:25 +08:00
Luis Pater
9d453bc0db feat(cache): add Claude web search result caching and restoration for sessions
- Implement LRU cache and helpers for Claude native web search tool results.
- Record search results from stream events and responses, and restore them in subsequent requests.
- Add configuration options and test coverage for Claude web search result caching.

Closes: #6753
2026-10-19 09:51:36 +08:00
Luis Pater
904ec71007 feat(auth): enable expired antigravity AI credits negative hint recovery and retry logic
- Add freshness validation helper for antigravity credits hints and synchronize the refresh interval constant.
- Allow expired negative credits hints to trigger re-validation and clear permanent failure state upon successful recovery.
- Include `INSUFFICIENT_G1_CREDITS_BALANCE` in full quota exhaustion decisions and ensure candidates with expired negative hints are re-queried.

Closes: #6745
2026-10-19 02:35:21 +08:00
Luis Pater
feb6398456 feat(auth): increase Codex proactive refresh lead to 96 hours and improve rejected token handling
- Update Codex outer refresh lead time to 96 hours to prevent upstream token invalidation.
- Ensure proper token refreshing and background recovery for rejected unexpired JWTs and in-stream 401 errors.

Closes: #6742
2026-10-19 01:41:19 +08:00
sususu
a68c7d8ed7 fix(signature): strip OpenRouter private RouterSuffix on official and non-OpenRouter upstreams
- Only preserve OpenRouter dot-delimited router suffixes when the upstream baseURL is openrouter.ai / *.openrouter.ai
- Strip RouterSuffix down to the native GPT/Grok/Meta envelope when forwarding to official tokens (chatgpt.com, api.openai.com, api.x.ai) or non-OpenRouter third-party providers (while keeping native api.meta.ai fail-closed against cross-caller envelopes)
- Strip RouterSuffix before storing GPT signatures in the Codex reasoning replay cache
2026-10-18 20:57:01 +08:00
sususu
be9fbd9429 feat(signature): support router-suffixed GPT/Grok envelopes and multi-family Responses targets
- Allow optional dot-delimited alphanumeric router suffixes (such as OpenRouter endpoint_slug metadata) in InspectGPTReasoningSignature and InspectGrokEncryptedContent
- Preserve matching target-family signatures (Grok, Gemini, Claude, Kimi, SWE) in sanitizeOpenAIResponsesReasoningEncryptedContentWithCompatModel when served through Responses routers
2026-10-18 13:03:50 +08:00
sususu
674dbe8fd1 fix(signature): support Meta Muse signatures across third-party Responses providers
- Gate MetaExecutor signature sanitization by baseURL so custom/third-party meta-api-key endpoints replay router-suffixed Meta Muse envelopes while native api.meta.ai stays native-only
- Pass resolved target model (with requested-model fallback for aliased deployments) through Codex, Codex WebSocket, and OpenAI-compat Responses sanitization paths
- Broaden Meta Muse model-id boundary matching (muse, meta/muse, muse_*, meta-muse-*) and allow Meta envelopes in the Codex reasoning replay cache
- Reuse CodexReplaySignatureForTarget in Claude-to-Codex request translation and avoid duplicating streamed thought summaries on Interactions reasoning done events
2026-10-18 13:03:50 +08:00
sususu
cc5682c563 fix(signature): replay OpenRouter router-suffixed Meta Muse signatures
OpenRouter serves meta/muse-* through its Responses API and returns
encrypted_content as the native Meta envelope plus "." and a 67-char
alphanumeric routing suffix. The strict Meta inspector rejected that form,
so it was classified unknown and stripped on every path, including the
compat Meta-target path that previously kept unknown blobs.

- Accept an optional "."+[A-Za-z0-9]{1,128} router suffix after a valid
  native envelope and expose it as RouterSuffix; replay stays verbatim
- Replace the keepMeta flag with a Meta policy: Meta-family targets on the
  Codex executor allow routed envelopes regardless of is-compat, while the
  native Meta executor stays native-only (suffix acceptance by api.meta.ai
  is unverified)
- Live-checked on OpenRouter: native part matches the api.meta.ai header
  and bucket shape (5/5), suffixed, native-only and suffix-tampered replays
  are consumed, native-body tamper is silently dropped

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-10-18 13:03:50 +08:00
sususu
7a0b7563e9 feat(signature): recognize Meta Muse reasoning envelopes and gate replay by target
- Add InspectMetaReasoningSignature transport-shape validation (canonical unpadded base64url, observed 43e3da0e01 header, 45 + 1024*2^k decoded buckets) and SignatureProviderMeta detection/compatibility wiring
- Make Meta Responses sanitization native-only so GPT, foreign, and unknown signatures never replay to Meta, while compat paths preserve Meta envelopes only for Meta-family target models
- Preserve recognized Meta signatures through Claude-protocol request translation for muse-* targets and drop them for other targets; never supplement them as Devin sealed signatures
- Cover with synthetic-fixture unit tests only; verified same-model, cross-model, and Claude-ingress live replay plus wrong-upstream stripping on an isolated debug CPA
2026-10-18 13:03:50 +08:00
Luis Pater
db1bab011d feat(runtime): narrow Claude per-minute rate-limit cooldown when short Retry-After is present
- Add `ParseClaudeRateLimitResetForError` to inspect response bodies and avoid inheriting hours-long unclassified unified resets for explicit per-minute rate limits.
- Update Claude standard and fast-direct executors to use the body-aware rate-limit parser when handling upstream error responses.

Closes: #6719
2026-10-18 10:50:40 +08:00
Luis Pater
3a0722984a feat(meta): filter subscription usage telemetry from SSE streams and responses
- Filter `response.subscription_usage` events and associated metadata across Meta streaming and non-streaming executors.
- Ensure subscription telemetry is stripped from OpenAI Responses SSE streams and WebSocket forwarders.
2026-10-18 03:20:24 +08:00
Luis Pater
b8d4e14a8e feat(runtime): optimize antigravity schema sanitization to scale linearly with declarations
- Refactor antigravity tool schema sanitization to process declarations and elements in a single pass.
- Avoid quadratic whole-document rewrites for payloads with many function declarations.
- Preserve original array whitespace and untouched elements during byte splicing.

Closes: #6714
2026-10-18 02:50:03 +08:00
Luis Pater
4f2e52709d feat(runtime): detect upstream stream truncation across executors and proxy handlers
- Track finish signals and message stops in stream executors to handle premature upstream closures.
- Enhance Claude SSE state observation and error injection for truncated stream connections.

Closes: #6707
2026-10-17 20:42:18 +08:00
Luis Pater
ad9e456d4a feat(claude): support between_tools thinking disable type and adaptive fallbacks
- Add `DisableType` support to plugin host adapters and registry mappings.
- Route disabled thinking to `between_tools` for models like Claude Sonnet 5.5.
- Fall back to low-effort adaptive thinking for models that reject disabled states.

Closes: #6698
2026-10-17 13:56:34 +08:00
Luis Pater
e13bc9a1f0 feat(claude): synthesize adaptive thinking block binding for preserved-thinking models
- Synthesize an adaptive thinking object and inject `drop_block` prefix mismatch behavior for preserved-thinking models when thinking is omitted but signed thinking blocks are present.
- Prevent thinking object and block binding injection when tool choice forces tool use.
- Update tests to cover omitted thinking and forced tool choice behaviors for preserved-thinking models.

Closes: #6697
2026-10-17 11:32:46 +08:00
Luis Pater
911f49cbd4 feat(claude): add automatic thinking block binding and beta policy for preserved-thinking models
- Automatically inject `drop_block` prefix mismatch behavior for preserved-thinking models when replaying signed thinking blocks.
- Append the required thinking-binding-controls beta header whenever requests carry `thinking.block_binding`.
- Expand Haiku 5.5 and related model detection to correctly support assistant prefill drops and token validations.

Closes: #6692
2026-10-17 02:56:09 +08:00
Luis Pater
b946d54e4b feat(devin): add account-wide quota exhaustion tracking and credential cooldown refresh
- Introduce Devin quota exhaustion detection for daily and weekly usage windows with reset timestamp parsing.
- Apply credential-scoped 429 status errors with reset-based Retry-After for Devin quota limits.
- Support automatic quota revalidation and early credential cooldown release upon confirmed usage recovery.

Closes: #6690
2026-10-17 02:18:41 +08:00
Luis Pater
088e445715 test(meta): handle client disconnect gracefully after terminal stream events
- Track delivery of terminal response events in Meta stream execution.
- Prevent client cancellation errors from being marked as API failures if the terminal event was already delivered.
- Add unit tests for Meta stream client disconnection behavior before and after terminal events.

Closes: #6688
2026-10-16 23:23:33 +08:00
Luis Pater
7604d3df3e feat(claude): add session date pin retention to preserve continuity across credential switches
- Add `session-date-pin-days` configuration option with a 7-day default retention.
- Store session date pins independently of continuity state to prevent re-anchoring on credential switches or idle gaps.
- Strip caller-supplied current date reminders from the first user message to avoid duplication.

Closes: #6682
2026-10-16 22:53:30 +08:00
Luis Pater
355fd10e76 feat(pluginhost): add content-addressed shadow copies for dynamic library loading
Closes: #6672
2026-10-16 12:04:22 +08:00
eli
2d7f5377e4 feat(vertex): honor full /publishers/ prefix in API-key base-url
The API-key vertex executor previously always appended
"/v1/publishers/google/models/{model}:{action}" to whatever base-url the
credential carried, so a base-url that already encoded the resource path
(e.g. "https://aiplatform.googleapis.com/v1/projects/{p}/locations/{l}/publishers/google/models")
would produce a duplicated "/v1" and return 404.

This change teaches the helper to:
  1. detect a base-url that already contains "/publishers/" and use it
     as-is (preserving any projects/locations segment), and
  2. skip inserting "/v1" when the trimmed base already ends in a
     version segment such as "/v1" or "/v1beta1".

Short third-party hosts like "https://zenmux.ai" keep working unchanged;
real Vertex API-key setups can now write the full resource prefix into
base-url to pick a specific project/location (e.g. us-central1 for
gemini-4-argon).

Includes a table-driven unit test covering empty, bare host, /v1,
/publishers/-full-prefix, v1beta1, and countTokens variants.

Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-10-15 18:36:57 +08:00
Luis Pater
207d119dac Merge pull request #6642 from trukhinyuri/fix/xai-web-search-unsupported-args
fix(xai): drop web_search options the Responses API rejects
2026-10-15 12:01:01 +08:00
Yuri Trukhin
bbfd7886ee fix(xai): drop web_search options the Responses API rejects
OpenAI Responses clients can attach search_context_size to the web_search
tool. The xAI Responses API rejects that option with HTTP 400 "Argument not
supported: search_context_size", which fails the whole turn on grok models.

Strip every web_search option xAI rejects (external_web_access and
search_context_size) through one table, and keep forwarding the options it
accepts: filters, user_location and search_content_types.
2026-10-15 05:20:24 +02:00
Luis Pater
ceb4397f1e feat(executor): drop trailing thought-only model turns in Gemini Vertex requests
- Add `DropGeminiTrailingThoughtOnlyContent` calls to Vertex executor request pipelines.
- Prevent Vertex upstream validation rejections caused by trailing model reasoning turns.

Closes: #6630
2026-10-15 08:05:58 +08:00
Luis Pater
4e8a4125ac feat(config): add operator overrides for Claude header defaults and client request ID modes
- Add `anthropic-beta-strip`, `anthropic-beta-append`, `inject-diagnostics`, and `client-request-id` options to `ClaudeHeaderDefaults`.
- Support `on`, `off`, and `passthrough` modes for `client-request-id` header handling in Claude requests.
- Sanitize and normalize configured beta override lists and client request ID configuration values.

Closes: #5093
2026-10-15 00:57:18 +08:00
Luis Pater
9db0729f5f feat(config): add operator overrides for Claude header defaults and client request ID modes
- Add `anthropic-beta-strip`, `anthropic-beta-append`, `inject-diagnostics`, and `client-request-id` options to `ClaudeHeaderDefaults`.
- Support `on`, `off`, and `passthrough` modes for `client-request-id` header handling in Claude requests.
- Sanitize and normalize configured beta override lists and client request ID configuration values.

Closes: #5093
2026-10-15 00:57:02 +08:00