303 Commits

Author SHA1 Message Date
Luis Pater
aa4130e64c fix(gemini): keep truncated HTTP 200 streams out of credential cooldown and failover
- Tag locally synthesized missing-finishReason failures as stream-truncated in the Gemini and Vertex executors, and carry that classification through the auth manager so it skips credential cooldown and stops cross-credential replay while the public 502 and partial usage are preserved.
- Carry the truncation classification through usage reporting and the Home queue payload so Home-side schedulers also skip the spurious cooldown, and add regression coverage for both the manager and usage paths.

Closes: #7005
2026-10-26 21:07:08 +08:00
Luis Pater
1d45a5f332 fix(claude): handle forced tool restrictions in claude 5.5
- Fall back to schema prompts for Antigravity Claude 5.5 while preserving unrelated request settings.
- Normalize unsupported forced tool choices before thinking preparation in direct Claude execution and token-count paths.
- Add regression coverage for schema integrity, model boundaries, retries, and final payload rule precedence.

Closes: #7000
2026-10-26 20:36:51 +08:00
Luis Pater
064e008b07 feat(codex): add full-chain compression for Codex upstream and downstream traffic
- Compress finalized Codex OAuth request bodies with zstd on the verified ChatGPT backend path, with size/benefit gating, header-body alignment, and one uncompressed retry on 400/415 rejection.
- Negotiate downstream HTTP response compression under server.response-compression (zstd/gzip with q-values, SSE-safe flushing, commit-time Vary merging) and enable negotiated permessage-deflate on Codex and downstream WebSockets.
- Advertise Accept-Encoding to Codex upstreams and decode gzip/deflate/br/zstd upstream responses through a shared decoder before parsing or relaying.

Closes: #6905
2026-10-26 10:09:56 +08:00
Luis Pater
e5321f535c fix(auth,pluginapi,usage): share per-selection ID between Scheduler.Pick and UsageRecord
- generate a unique selection_id for each handled Scheduler.Pick decision and freeze it into the execution context and UsageReporter
- propagate SelectionID through core usage records and pluginapi.UsageRecord while clearing stale IDs on unhandled, rejected, Home, and credits fallback paths

Closes: #6988
2026-10-26 03:25:42 +08:00
Luis Pater
3dae075de2 feat(devin): aggregate swe-2 lightning UIDs into swe-2-lightning model
- Aggregate -{level}-lightning compound suffixes into a single swe-2-lightning catalog entry and preserve the Lightning display name suffix across registry and fetch_devin_models.
- Resolve -lightning base models into stem-{effort}-lightning UIDs while passing through complete upstream lightning UIDs and regenerating the embedded Devin catalog.

Closes: #6975
2026-10-25 22:17:43 +08:00
Supra4E8C
ba06ec58a1 fix(vertex): default credential location to global 2026-10-25 21:36:40 +08:00
Luis Pater
c9af5290a6 fix(pluginhost): run canonical thinking pipeline before plugin execution
- Apply canonical thinking normalization, suffix stripping, and plugin model metadata fallback in prepareExecutorCall across Execute, ExecuteStream, and CountTokens.
- Resolve plugin-registered ThinkingApplier by provider key before format fallback and validate unknown thinking suffixes on non-native-Responses models.
- Run thinking normalization before NewPayloadFinalizer so user payload rules act as the final host-side mutation.

Closes: #6940
2026-10-24 21:38:42 +08:00
Luis Pater
8289ec4c71 fix(usage): preserve interactions token semantics when merging stream usage
- Preserve separate-reasoning and subset token breakdown semantics in MergeStreamUsageDetail instead of unconditionally rebuilding merged stream usage with independent cache and inclusive reasoning rules.
- Add regression tests covering cumulative, identical, and partial Interactions stream usage merges as well as end-to-end plugin executor stream usage reporting.

Closes: #6925
2026-10-24 02:18:56 +08:00
Luis Pater
b90190dbaa fix(usage): propagate claude usage.speed into response service tier
- Populate Detail.ResponseServiceTier from usage.speed in parseClaudeUsageNode so non-streaming and streaming Claude usage records carry the billed response speed tier.
- Add regression tests verifying non-streaming usage.speed extraction and retention across message_start and message_delta stream events.

Closes: #6884
2026-10-23 01:07:20 +08:00
Luis Pater
07b5a7a1ca feat(usage): report effective outbound service tier after payload rules
- Capture the post-translation, post-payload-rule service tier on UsageReporter and propagate EffectiveServiceTier through SDK usage records, plugin usage adapters, and Redis usage queue payloads.
- Ensure executors record translated request metadata after final payload configuration rules so server-side service_tier overrides are accurately reported alongside client and response tiers.

Closes: #6873
2026-10-22 21:05:27 +08:00
Luis Pater
88732ad574 fix(vertex): use regional endpoint hosts for multi-region us and eu locations
- Route multi-region locations us and eu to https://aiplatform.{us,eu}.rep.googleapis.com in both native Gemini and OpenAPI Vertex host builders.
- Recognize official Vertex REP domains in IsGoogleVertexHost so location rewriting and credential checks handle REP base URLs accurately.

Closes: #6867
2026-10-22 19:26:31 +08:00
Luis Pater
d2e61d19b5 fix(claude): validate cloak_mode never headers against configured defaults
- Pass the active configuration to ApplyClaudeLegacyDeviceHeaders under cloak_mode never while allowing plausible newer SDK and runtime versions for confirmed clients.
- Document that cloak_mode never preserves confirmed caller headers ahead of stabilize-device-profile pinning and add regression coverage.

Closes: #6863
2026-10-22 18:33:39 +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
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
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
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
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
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
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
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
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
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
b3dc6c3fe5 refactor(config): move tls-handshake-timeout-seconds to root request configuration
- Relocate `tls-handshake-timeout-seconds` from `upstream.claude` to root-level request settings.
- Update configuration structures, validation logic, and tests accordingly.

Closes: #6615
2026-10-14 20:59:02 +08:00
Luis Pater
345cc9d5a8 feat(claude): add timeout and retry logic for silent TLS handshakes
Closes: #6615
2026-10-14 20:23:35 +08:00
Luis Pater
7f2f17d76f feat(gemini): treat MALFORMED_FUNCTION_CALL as retryable API error in Claude translation
- Translate Gemini `MALFORMED_FUNCTION_CALL` responses into Claude API error payloads instead of refusal stop reasons.
- Capture translated stream errors in Gemini and Vertex executors to ensure proper error propagation, usage reporting, and state management.

Closes: #6606
2026-10-14 12:08:35 +08:00
Luis Pater
57d005fe6c fix(codex): strip out-of-range int64 numeric bounds from tool schemas
Closes: #6579
2026-10-14 03:45:14 +08:00
Luis Pater
7795de19ca feat(sse): implement CodexSSEScanner for improved event data handling
Closes: #6575
2026-10-14 02:54:02 +08:00
Luis Pater
51952a7b2f feat(httptransport): add request-scoped HTTP transport decorator
- Introduce `sdk/httptransport` package with `Decorator`, `WithDecorator`, `WithoutDecorator`, `InheritDecorator`, and `Decorate` functions.
- Propagate transport decorators from incoming HTTP request contexts in `BaseAPIHandler.GetContextWithCancel`.
- Apply transport decoration after client transport selection across proxy-aware, Devin, uTLS, and Antigravity HTTP clients.

Closes: #5616
2026-10-13 13:01:12 +08:00
Luis Pater
a27183143e fix(antigravity): drop trailing thought-only model turns
Closes: #6530
2026-10-11 20:45:18 +08:00
Luis Pater
15d2148bc2 fix(gemini): ensure trailing user turn for function response with media
Closes: #6524
2026-10-11 17:58:34 +08:00
Luis Pater
29bd0415b9 fix(claude): pin upstream.claude.tool-search per request 2026-10-11 14:21:00 +08:00
Luis Pater
48ad3487b2 feat(executor): add Responses tool_search strip and legacy model helpers 2026-10-11 11:01:28 +08:00
Luis Pater
37fe2608ee feat(usage): propagate access provider and native key metadata to usage records
- Inject API key, access provider, and native key flags into the request context during authentication
- Add `IsNativeKey` and `AccessProvider` fields to usage records, plugin API types, and redis queue payloads
- Provide context helper functions and automatic fallback resolution in the usage manager and reporter

Closes: #6509
2026-10-10 22:16:00 +08:00
Luis Pater
e9c8769a7a fix(executor): normalize and restore non-portable tool call IDs
- Normalize tool use and tool result IDs in Claude message payloads to adhere to character constraints
- Encode non-portable tool call IDs in Devin executor responses and restore original IDs before request construction

Closes: #6478
2026-10-09 19:44:24 +08:00
Luis Pater
2bc236d2fc feat(claude): support responses compaction in claude executor
- Handle compaction trigger requests by generating summaries and sealing antigravity compaction capsules
- Expand replayed compaction capsules into message history before translation and filter foreign compaction items
- Preserve tool definitions with `tool_choice: none` or flatten tool blocks when tool definitions are missing
- Support streaming compaction execution and map cache creation and read token usage

Closes: #6466
2026-10-09 03:24:45 +08:00
Luis Pater
8080967991 fix(claude): ignore overage billing resets in unified rate limit parsing
- Ignore unified reset timestamps matching overage reset boundaries to prevent cooling down credentials until monthly billing reset
- Filter candidate rate limit deadlines exceeding the 7-day window limit
- Treat rejected overage claims with absent or healthy shared utilization as model-scoped rejections

Closes: #6465
2026-10-08 22:14:59 +08:00
Luis Pater
2d5351b3e5 feat(vertex): add support for native gemini interactions api
- Extract shared Gemini Interactions helpers for payload translation, input sanitization, thinking, and SSE streaming
- Add `interactions` configuration option to Vertex credentials
- Support native non-streaming and streaming Interactions API execution in Gemini Vertex executor

Closes: #6445
2026-10-08 12:39:31 +08:00
Luis Pater
0f96f568e4 refactor(translator): update openai and interactions request converters to return errors
- Update OpenAI and OpenAI Responses to Interactions request converters to return `([]byte, error)`
- Register request converters directly in internal translator registry instead of sdktranslator checked requests
2026-10-08 03:00:04 +08:00
Luis Pater
34e73c75a3 fix(xai): add proxy support and semver validation to Grok CLI updater
- Pass configured proxy URL to the npm registry updater client
- Validate fetched versions against strict semver and minimum server version floor (`1.0.13`)
- Update default fallback client version to `1.0.46`
- Manage background updater lifecycle and context via service lifecycle initialization
2026-10-08 02:39:32 +08:00
Luis Pater
298649f677 Merge pull request #6446 from jellyfish-p/feat/grok-cli-dynamic-version
feat(xai): dynamically fetch latest Grok CLI version from npm registry with fallback
2026-10-08 02:30:27 +08:00
Luis Pater
f51624aa35 fix(translator): report unsendable user turn attachments in openai responses to interactions
- Track dropped attachments and reject emptied user turns during OpenAI Responses to Interactions translation
- Register checked request translator for OpenAI Responses to Interactions format conversion
2026-10-08 02:11:20 +08:00
Jellyfish
90654da573 feat(xai): dynamically fetch latest Grok CLI version from npm registry with fallback
- Fetch latest @xai-official/grok client version from npm registry on startup
- Periodically refresh Grok CLI version every 3 hours without multiple retries
- Update hardcoded fallback version to 1.0.50 if npm registry is unreachable
- Dynamically inject active version into x-grok-client-version and User-Agent headers
2026-10-08 00:59:27 +08:00
이대희
3b69068e6c fix(translator): stop dropping attachments and empty turns
An attachment a translator could not represent was dropped without a word, and
a turn whose only content was that attachment went upstream as an empty
messages, parts, or input array. The model then answered as if nothing was
attached, or the upstream rejected a request that never named the attachment.

A base64 document now reaches OpenAI as a file part. A file the target cannot
receive, such as container_upload, an OpenAI file_id, or input_audio sent to
Claude, is reported by name so the route answers 400 instead of forwarding an
empty turn. Text beside it still travels.

One rule, ErrIfNothingLeft, decides when to refuse, and RegisterCheckedRequest
carries the refusal on the request envelope. Every executor that translates
checks it before calling upstream. The exported converters keep their []byte
signature, so no caller or sibling test had to change.
2026-10-07 19:21:32 +09:00
Luis Pater
57bde35179 fix(executor): preserve upstream usage on apply patch failures
- Buffer and publish observed upstream usage when apply patch transformation or translation encounters an error in Meta and xAI executors
- Add stream usage buffer helpers to report failure metrics with captured upstream token usage

Closes: #6427
2026-10-07 09:31:03 +08:00
Luis Pater
0ea4e1dcb4 fix(openai): complete responses stream on clean EOF after finish reason
- Track pending completion state in OpenAI-to-Responses translator when item output is complete and a finish reason is received
- Synthesize terminal `[DONE]` event on clean EOF when response completion is pending instead of failing the stream

Closes: #6381
2026-10-05 15:55:38 +08:00