Commit Graph

254 Commits

Author SHA1 Message Date
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
hkfires
611ebba415 refactor(executor): unify model reporting and replay logs
Replace Codex-specific response model APIs with shared model observation and remove redundant substitution warning throttling. Consolidate repeated Antigravity context-hash rejection messages into a single request-level log while preserving rejection details across index rebuilds.
2026-10-05 11:10:54 +08:00
Luis Pater
cbc4cd5532 feat(interactions): support antigravity session continuation and model detail lookup
- Add `InteractionsSessionCache` to preserve Antigravity interaction continuations across tool call rounds
- Automatically restore and inject `previous_interaction_id` and `environment_id` in Gemini interactions executor
- Normalize Antigravity tool identity mappings in OpenAI responses translator
- Add `/v1/models/*model` endpoint to support retrieving individual model details

Closes: #5190
2026-10-04 04:23:31 +08:00
Luis Pater
868e137f6c feat(payload): introduce payload finalizer for protobuf and multipart requests
- Add `PayloadFinalizer` to apply configuration rules at the final serialization barrier
- Support decoding, modifying, and re-encoding Devin protobuf business fields
- Add multipart form-data payload normalization to JSON for media payload rules

Closes: #5067
2026-10-04 03:01:34 +08:00
Luis Pater
5dbce4f3fb perf(claude): prefilter JSON payloads before diagnostic walks
- Add ASCII pre-filter to skip expensive gjson traversals for title helper and 1h TTL checks
- Check raw bytes for target keywords before initiating full JSON walks
- Fall back to full inspection when printable ASCII Unicode escapes are detected

Closes: #6291
2026-10-03 10:48:07 +08:00
Luis Pater
6d57ac9087 fix(claude): pin session date in cloaked reminder to prevent prompt cache invalidation
- Pin local date to continuity context on the first request of a session
- Reuse pinned session date during cloaked date injection across execute and stream flows
- Prevent midnight calendar date flips from invalidating conversation prompt cache prefixes

Closes: #6282
2026-10-03 00:28:35 +08:00
sususu
d7c3c0aaaa feat(antigravity): trace upstream connection reuse in debug logs 2026-10-02 22:13:24 +08:00
Luis Pater
8fbf152b5b fix(executor): preserve top-level responses token usage when service tier is present
- Fall back to top-level token usage when Codex response usage contains only service tier metadata
- Propagate parsed service tier while retaining top-level token counts
- Avoid early return during stream usage observation for chunks with zero token counts

Closes: #6261
2026-10-02 16:01:23 +08:00
hkfires
cf3102cc03 refactor(executor): optimize translation logic and improve plugin invocation handling 2026-10-02 10:58:36 +08:00
Luis Pater
3ebee06516 fix(interactions): bridge apply_patch tool calls in responses translation
- Handle apply_patch custom tool call streaming deltas and snapshots for Responses API translation
- Track and resolve step indexes, function call identities, and error states across stream events
- Propagate apply_patch tool input errors and upstream failure states in stream and non-stream responses
2026-10-02 03:49:51 +08:00
Luis Pater
97f244b8dd fix(codex): pass target executor to compatibility translation and token counting
- Pass target executor identity during Codex token counting and xAI request translation
- Skip tool integer normalization when target executor is Codex during compatibility translation
- Preserve number types in tool parameter schemas during token counting requests
2026-10-01 03:06:59 +08:00
Luis Pater
67cb32b6d3 fix(codex): determine tool integer normalization by target executor identity
- Base tool integer normalization checks strictly on target executor identity rather than protocol
- Add executor-aware translation helpers to pass target executor identity during request translation
- Ensure non-Codex executors normalize tool integer types for Codex clients regardless of protocol
2026-10-01 02:26:02 +08:00
Luis Pater
a8ffd5a843 fix(codex): skip tool parameter integer normalization for codex executor targets
- Skip normalizing tool parameter number types to integer when the target executor is Codex or Codex WebSocket
- Remove tool integer type normalization from schema cleanup in native Codex execution paths to preserve reserved tool schemas
- Apply tool integer type normalization only for non-Codex upstream targets with Codex client User-Agents

Closes: #6244
2026-10-01 02:04:49 +08:00
Luis Pater
82f8e92b21 fix(executor): support negotiated ALPN protocols in uTLS client
- Select HTTP/2 or HTTP/1.1 transport dynamically based on TLS ALPN negotiation
- Route empty ALPN and HTTP/1.1 requests through a dedicated non-pooled transport reusing the handshaken connection
- Ensure uTLS connections are cleanly closed upon response completion or request failure

Closes: #6223
2026-10-01 00:47:24 +08:00
Luis Pater
e5b5a1cfca fix(kimi): reorder interleaved tool outputs in responses input
- Defer intervening non-tool messages until all batch tool outputs are emitted to keep outputs contiguous
- Apply responses input normalization across standard and streaming executor execution paths

Closes: #6231
2026-09-30 23:39:28 +08:00
Luis Pater
71a5f1f6c5 fix(codex): normalize tool parameter number types to integer for codex clients
- Detect Codex client requests via User-Agent and convert target numeric parameters to integer types
- Support schemas across OpenAI functions, Claude input schema, Gemini declarations, and namespace tools
- Apply normalization during executor payload processing, multi-agent request translation, and WebSocket streaming

Closes: #6237
2026-09-30 22:27:18 +08:00
hkfires
d3cd466ddb fix(codex): use resolved compat for multi-agent v2 2026-09-28 19:03:22 +08:00
hkfires
b9971ee3df feat(sdk): add Home credential capabilities and quota APIs
Use Home credential options as authoritative model capability
configuration for compat handling and prompt cache behavior.

Expose quota provider operations through the public plugin host API.
2026-09-28 19:03:21 +08:00
Luis Pater
2c27e61fe7 fix(meta): strip unsupported search_content_types from web search tools
- Add `SanitizeMetaWebSearchTools` to remove `search_content_types` from `web_search` tool definitions
- Support sanitizing nested tools within `namespace` tool definitions
- Apply web search tool sanitization during Meta request preparation

Closes: #6156
2026-09-27 22:54:19 +08:00
Luis Pater
31f4cfab3f feat: migrate CLIProxyAPI to version 8 2026-09-27 14:42:26 +08:00
hkfires
d9922f0589 feat(config): add v8 configuration API
Introduce the v8 management configuration tree with migration-aware reads and
writes, grouped upstream API-key providers, and independent v8 operational
routes.

Preserve legacy configuration compatibility while ensuring successful v8 writes
migrate layouts, redact JSON TURN secrets, and keep OAuth-only provider
settings from affecting API-key credentials.
2026-09-27 14:16:27 +08:00
Luis Pater
6dea3dfa13 fix(antigravity): extract and apply reasoning summary config for OpenAI responses
- Use `ExtractSummaryConfig` to parse summary configuration from OpenAI response payloads
- Default to enabled auto summaries when reasoning effort is set without explicit summary visibility
- Apply the resolved summary configuration directly to Antigravity translations

Closes: #6143
2026-09-27 02:35:18 +08:00
Luis Pater
fc2c98d1ca feat(runtime): enhance Devin model aggregation and UID normalization
- Implement `splitDevinUID` for consistent UID splitting and effort extraction.
- Update model aggregation to handle thinking levels and merge variants.
- Refine display name cleaning logic to remove redundant suffixes.
- Adjust Devin catalog integration to exclude exposed thinking variants.
- Normalize and sort thinking levels with an extended rank scheme.

Closes: #6141
2026-09-27 02:03:55 +08:00
Luis Pater
3b2882b72e fix(codex): strip non-standard multi-agent metadata for compat models
- Pass compat mode flag to multi-agent v2 input rewriting
- Proactively remove `author`, `recipient`, and internal passthrough metadata for compat models
- Allow stripping non-standard metadata even when multi-agent v2 optimization is disabled

Closes: #6136
2026-09-26 22:51:47 +08:00
Luis Pater
ed980be34b fix(auth): preserve resolved model capabilities and configuration update support
- Attach resolved execution model info during execution and token counting even when restoring execution models
- Propagate configuration update support to resolved Home dispatch model info
- Track modifications to configuration updates across plugin normalizers in the translation pipeline
- Mark configuration update support for eligible Codex models in the registry
2026-09-26 13:57:06 +08:00
Luis Pater
4332048dda fix(claude): apply cloaking by default for direct Messages OAuth requests
- Remove direct Messages passthrough bypass for unconfirmed OAuth credentials
- Ensure standard cache control handling and CLI fingerprinting apply upstream
- Support detection for Claude Code 2.1.280 title helper payload shape

Closes: #6120
2026-09-25 12:38:18 +08:00
sususu98
f7c738dad3 fix(claude): align 2.1.280 fingerprint and thinking visibility (#6096)
* fix(claude): align Opus 5.5 cloak and preserve native CLI hints

* fix(claude): recognize the 2.1.280 Haiku title helper

The native title request now appends server-side fallback, fallback credit,
and cache diagnosis after the structured-output beta. Keep the helper
allowlist exact so this sequence passes through without cloaking.

* fix(claude): align thinking visibility and Messages passthrough

* fix(claude): preserve thinking visibility through compatibility paths

* fix(claude): harden OAuth beta, session alignment, and 2.1.280 helper headers
2026-09-24 15:26:39 +08:00
Luis Pater
2fe9932bb9 feat(usage): track execution request ID and trace ID across usage records
- Add `RequestID` (unique execution UUID) and `TraceID` (inbound request ID) fields to usage records and plugin API
- Generate unique UUIDs per model attempt in `UsageReporter` while linking to parent trace context
- Expose `execution_id` and `trace_id` in Redis queue usage payloads while preserving legacy `request_id`
2026-09-23 19:31:39 +08:00
Luis Pater
779bf317e0 feat(claude): bump claude cli baseline to 2.1.280 and support tool changes beta
- Update default Claude CLI version to 2.1.280 in cloaking and device profile
- Add `mid-conversation-tool-changes-2026-07-01` beta header support for supported models

Closes: #6054
2026-09-23 05:07:49 +08:00
Luis Pater
320100ecf7 fix(codex): strip octal NUL pattern escapes from tool schemas
- Strip octal NUL (`\0`) escapes in regex patterns to prevent rejection by strict upstream JSON Schema validators
- Update tool schema normalization fast-path to check for serialized `\0` escape sequences

Closes: #6025
2026-09-22 18:25:48 +08:00
Luis Pater
639b7f1126 perf(executor): reuse identical Claude and Gemini request translations
Skip the second compatibility translation for Claude, Gemini, and Gemini
interactions when the baseline and working payloads share a backing array
and no plugin hooks are installed. Keep independent buffers, the existing
hook order, and native interactions copies.
2026-09-22 05:16:25 +08:00
Luis Pater
5083f65037 Merge pull request #5990 from jack-5566/fix/responses-request-cache-pr
perf: cache Responses request validation and index tool declarations
2026-09-22 04:51:07 +08:00
Luis Pater
7f63f8c8d2 Merge pull request #5680 from cookerpapa/perf/codex-tool-schema-batch
perf(codex): batch tool schema rewrites
2026-09-22 04:23:03 +08:00
Luis Pater
d582067c06 feat(executor): support execution-scoped request proxy overrides
- Add context helpers to manage execution-scoped proxy overrides
- Prioritize request proxy over credential and global proxy settings across HTTP and uTLS clients
- Propagate request proxy in conductor execution and plugin host adapters
- Isolate Codex WebSocket connection reuse by proxy endpoint

Closes: #6013
2026-09-22 03:54:34 +08:00
Luis Pater
a5ab69521f feat: add full support for kimi.ai oauth and runtime execution 2026-09-21 04:13:44 +08:00
jack
8a6a39684d perf: index Responses tools and cache stream request validation 2026-09-20 23:10:57 +09:00
sususu
c52ca7bd4e docs(claude): clarify patch version floor rationale for native passthrough 2026-09-20 19:26:48 +08:00
camy-x
83a4913aa4 fix(claude): accept newer patch releases as native clients (#5820) 2026-09-20 19:15:51 +08:00
Luis Pater
690f4f3116 feat(executor): support use-max-completion-tokens for openai compatibility models
- Add `use-max-completion-tokens` setting to OpenAI compatibility model configuration
- Provide token normalization between `max_tokens` and `max_completion_tokens` based on model preference

Closes: #5939
2026-09-19 01:54:05 +08:00
Luis Pater
e84e248c51 fix(executor): record expected Devin upstream model and bound stream observer memory
- Set expected upstream model for Devin in both streaming and non-streaming paths to avoid false positive substitution warnings on intentional mappings
- Account for line overhead and enforce max lines per stream event in StreamResponseModelObserver, dropping overflowed events until the event boundary
- Add unit tests for Devin intentional mappings and stream observer bounded memory behavior
2026-09-18 22:08:35 +08:00
Luis Pater
cde7d57e44 fix(executor): robust response model observability across meta, kimi, and openai-compat streams
- observe response model from terminal sourceEvent in Meta non-stream multi-event SSE responses
- record expected upstream model in UsageReporter to prevent false substitution warnings on Kimi canonical mappings
- use bounded stream observer to extract response models across image stream chunk boundaries
- add regression tests for Meta SSE non-stream, Kimi model mappings, and chunked image streams
2026-09-18 21:53:19 +08:00
Luis Pater
f8467f07dc fix(executor): record authentic Devin and Gemini Interactions response models
- Devin: extract authentic upstream model name from parsed Usage.ModelName
  instead of synthesized interactions JSON or binary Connect frames. Keep
  response model empty when upstream does not report one.
- Gemini: support interaction.model and event_type terminal semantics
  in response model extractors for Gemini Interactions streaming.
- Add unit tests for Devin and Gemini Interactions response model observability.
2026-09-18 21:32:59 +08:00
Luis Pater
e9463ff5a7 feat(executor): extend response model recording and substitution warnings to all providers 2026-09-18 21:22:43 +08:00
Luis Pater
cd5af08e31 Merge pull request #5928 from Viggo95/feat/codex-response-model-observability 2026-09-18 21:05:35 +08:00
Luis Pater
cc545cbf90 fix(openai): align tool call messages and preserve ordering on ambiguous outputs
- Add `AlignOpenAIToolCallMessages` to reorder tool results immediately after the matching assistant tool calls while preserving original content and numeric precision.
- Prevent deferred message reordering and call ID guessing when tool outputs are incomplete, duplicate, or missing IDs.
- Normalize translated requests after applying summary configuration in Codex multi-agent execution.

Closes: #5925
2026-09-18 12:32:21 +08:00
Viggo95
25f40d8cf8 feat(codex): record upstream response model and warn on silent model substitution
Codex upstreams can silently serve a different model than the one requested
(HTTP 200, with response.model naming the substitute). The proxy kept no record
of it: nothing logged, nothing reported, only the pass-through response body.

- Add Record.ResponseModel to sdk/cliproxy/usage, aligned with the existing
  ResponseServiceTier field, and emit it from the redis usage queue as the
  optional response_model payload field alongside response_service_tier. Only
  the record for the requested model carries it: additional-model records
  (image generation tool usage) describe a side model the upstream response
  never refers to, and would otherwise look like a substitution downstream.
- Add internal/runtime/executor/helps/response_model.go with
  extractCodexResponseModelEvent (SSE frames and raw JSON, restricted to the events
  that embed the authoritative response object, rejecting non-string and
  oversized upstream model names) and IsCodexModelSubstituted (both sides
  trimmed, lower-cased and stripped of thinking suffixes, dated aliases such as
  gpt-5.6-terra-2026-05-13 accepted in either direction).
- UsageReporter records the served model on the event path and emits the WARN
  when the attempt publishes its usage record, so no logging work happens
  before the first event is forwarded. Repeats are throttled per
  (auth id, requested model, served model) with a 10 minute window, because on
  an affected credential every request is substituted and an unthrottled
  warning would mirror the whole request volume into the logs. The credential
  is labelled auth_index=<index> only: codex credential file names embed the
  account e-mail, which must not be written to the logs at request rate.

Coverage, by entry point. The served model is observed on the HTTP streaming
path (both the bootstrap-buffered handshake and the streaming goroutine), the
HTTP non-streaming Execute loop, the websocket streaming and non-streaming
paths, and the two /responses-shaped image entry points. The remaining codex
entry points cannot report it and are therefore left alone: executeCompact
(/responses/compact answers with a compaction object that has no event type and
no response.model), the two direct image endpoints (/images/generations and
/images/edits answer in the Images API shape and stream image_generation.*
events), and CountTokens (counts locally with tiktoken, never reaching an
upstream).

TokenAccountingSchemaVersion is not bumped: it versions the token accounting
contract (token breakdown semantics), and this change only adds an optional
non-token field that leaves existing consumers and all token math untouched.

Note: response_model ships with the usage record and is the counting source;
the WARN is a throttled alerting signal and must not be used to count
substitutions.

Tests: table-driven unit tests for both helpers over real model ids, reporter
tests covering the published record, the single throttled warning, the absence
of account identifiers in it, concurrent observation and publishing under
-race, the throttle window and its entry bound, an executor-level guard for the
observeCodexTokenEvent wiring and the per-model records, plus a redisqueue
payload assertion for response_model. gofmt, go vet, go test -race on the
touched packages and go test ./... are clean.
2026-09-18 12:31:52 +08:00
Luis Pater
1cce932573 fix(claude): skip retry-after header on overage-only rejections
- Skip parsing the `Retry-After` header when a rate limit rejection is overage-only to prevent global credential cooldowns.
- Allow exponential backoff to handle model recovery while keeping shared subscription windows available for other models.

Closes: #5920
2026-09-18 09:15:48 +08:00
Luis Pater
44eaef0009 feat(claude): support model-level cooling and scope overage rate limits
- Add `claude.model-level-cooling` configuration to scope rate limit cooldowns to the requested model.
- Treat overage-only and spend cap rejections as model-scoped when shared subscription windows remain healthy.
- Propagate model-level cooling settings into streaming, token counting, and direct execution error classifiers.

Closes: #5915
2026-09-18 01:55:36 +08:00
Luis Pater
b6fe4f20c4 fix(devin): handle orphaned tool results and normalize function result payloads
- Match tool results against pending tool calls and downgrade unmatched results to user messages.
- Prevent downgraded orphaned tool results from consuming images intended for user turns.
- Unwrap protocol wrapper envelopes and extract structured text parts while preserving arbitrary business JSON.
- Provide a placeholder for empty or whitespace-only tool results.

Closes: #5911
2026-09-18 01:34:38 +08:00
Luis Pater
9e10db53ad fix(devin): aggregate tool calls by id and track cache write tokens
- Track and aggregate tool calls by call ID instead of slot index in streaming and buffered execution.
- Support raw arguments from invalid JSON fields for custom tool calls.
- Parse usage field 4 as cache write tokens instead of adding to prompt tokens.
- Align client metadata with the default client name and drop deprecated tag 28.

Closes: #5910
2026-09-18 01:04:43 +08:00