Commit Graph

4783 Commits

Author SHA1 Message Date
hkfires
e479ab1253 perf(auth): compact weighted round-robin pools
Replace string pool keys and map-based credit state with SHA-256
digest keys and sorted slice members holding weight, current, and
pending credits in a single allocation. Reservations now retain
only the member index instead of a weights map and auth ID.

Verify full pool identity on digest hits and chain collisions so
unrelated candidate pools never share credits or weights. Update
tests to access pool credits through test helpers.
2026-11-09 14:23:17 +08:00
hkfires
d20451504f feat(auth): compensate weighted routing for sticky sessions
Charge session-affinity hits, parent inheritance, LCP matches,
and pinned requests against the eligible weighted pool without
moving existing bindings, so new sessions favor under-served
credentials and request ratios stay approximately weighted.

Scope settled credits per eligible credential set, capped at
+/-32 pool rounds, with in-flight reservations that commit on
local selection success and release on failure.
2026-11-09 14:23:16 +08:00
hkfires
0561334f06 fix(home): preserve fork kind in home dispatch
Map IsFork metadata to X-Node-Kind: fork when dispatching to
Home so forked sessions keep their lineage kind alongside
explicit kinds such as compaction. Clone dispatch headers
before adding the Home-only header to avoid mutating caller
headers, and cover fork, compaction, and ordinary children
with session hierarchy tests.
2026-11-09 14:18:50 +08:00
Luis Pater
098af7d543 fix(auth): share and migrate model cooldowns across equivalent model spellings
- Normalize model state, scheduler shard, and cooldown lookups case-insensitively while preserving stored model key casing.
- Atomically migrate route-alias cooldowns to the resolved upstream model key when OAuth model aliases or credentials are updated.
- Add regression tests covering mixed-case alias targets, pre-existing alias cooldown migration, and concurrent persistence windows.

Closes: #7360
2026-11-09 09:35:10 +08:00
Luis Pater
14e577174a fix(pluginhost): support credential-scoped rate limit errors from plugin executors
- Add optional credential_scoped metadata and documented routing/cooldown error code constants to pluginabi.Error so plugin executors can report account-wide 429 limits.
- Preserve credential-scoped classification on rpcError across synchronous RPC envelopes and streaming error callbacks while prioritizing credential quota scope over model-only or cooldown-skipping error codes.
- Recognize credential_quota error codes in core auth cooldown classification and cover whole-credential cooldown propagation and error events with regression tests.

Closes: #7359
2026-11-09 03:19:45 +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
681ce41b6e Merge pull request #7281 from duu261/docs/readme-cpa-status
docs(readme): mention cpa-status in Hermes entry
v8.0.61
2026-11-08 22:30:45 +08:00
Luis Pater
0074897481 feat(pluginhost): expose token modality details in usage.handle
- Extend pluginapi.UsageDetail with optional modality token counters matching core usage.Detail.
- Forward independent pointer copies of modality counters in usageAdapter.HandleUsage so plugins receive full breakdown details.
- Add adapter, SDK, and RPC regression tests covering populated, explicit zero, and absent modality counters.

Closes: #7352
2026-11-08 20:52:39 +08:00
Luis Pater
40c16182b8 feat(auth): support session-affinity-rebind-on never mode
- Add the "never" option for routing.session-affinity-rebind-on to preserve established session bindings across all credential failures and refuse cross-credential failover across primary, fallback-key, and Merkle LCP paths.
- Scope retry rounds and Antigravity credits fallback to the bound credential under "never" mode, returning 503 session_auth_retry on transient unavailability and 429 or upstream errors on quota/auth blocks.
- Add unit and end-to-end regression tests covering selector refusal, retry rounds, empty candidate sets, Antigravity credits fallback, and runtime config reload.

Closes: #7348
2026-11-08 15:38:30 +08:00
Luis Pater
05e668cf2d fix(responses): sanitize orphan tool outputs lacking call_id
- Rewrite standalone function_call_output and custom_tool_call_output items without call_id into user messages while preserving paired tool outputs and multimodal content parts.
- Apply orphan tool output sanitization in both Codex Responses request translation and the Responses HTTP/compact handlers while keeping codex_app delegation compatibility intact.
- Add regression tests covering orphan Companion Page outputs, multimodal array outputs, paired tool calls, and HTTP/compact endpoints.

Closes: #7341
2026-11-08 14:46:03 +08:00
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
f69db99d5e feat(plugin-store): support opt-in release cache refresh on store listing
- Accept refresh=true or refresh=1 on the plugin store listing endpoint to bypass the 1-hour latest-release cache TTL for installed plugins.
- Track last check timestamps on release cache entries with a 10-second per-key refresh floor while preserving GitHub rate-limit cooldowns and in-flight coalescing.
- Add unit tests and update v8 management API documentation for the refresh query parameter.

Closes: #7333
2026-11-08 04:42:54 +08:00
Luis Pater
0e07108899 Merge pull request #7306 from kdcokenny/docs/swe-2-flash-availability
docs(readme): add SWE-2 Flash to Devin models
2026-11-08 04:16:24 +08:00
Luis Pater
91e0dee827 fix(openai): prevent SSE keep-alive injection mid-line during image streaming
- Track SSE event newline boundaries across streamed image chunks and suppress keep-alive comments while inside an incomplete SSE event.
- Reset streaming keep-alive tickers when downstream bytes are written and ensure terminal error events start on a clean SSE boundary.

Closes: #7330
v8.0.60
2026-11-08 02:02:31 +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
69637a662a fix(openai): skip whitespace-only reasoning when opening Claude thinking blocks
- Ignore whitespace-only reasoning deltas and non-streaming reasoning entries when no thinking block is currently active so Anthropic-incompatible blank thinking blocks are never emitted.
- Allow whitespace reasoning segments to extend already-open streaming thinking blocks, tool-call-buffered thinking chunks, and non-streaming thinking builders.
- Add streaming and non-streaming regression tests covering whitespace-only and intra-thought whitespace reasoning.

Closes: #7325
2026-11-07 18:22:20 +08:00
Luis Pater
b5b724d06d fix(pluginhost): reuse content-addressed plugin shadow copies across restarts
- Reuse existing content-addressed shadow binaries in `<plugin_dir>/.shadow` (with a per-directory shared cache fallback) and verify target digests before creating any temporary files.
- Publish shadow binaries without unlinking active targets and coordinate plugin loading with stale shadow cleanup via OS-level file locks.
- Add regression tests covering cross-restart shadow reuse, zero-write cache hits, fallback isolation, and concurrent load/prune coordination.

Closes: #7323
2026-11-07 18:10:39 +08:00
Luis Pater
f4d3f0618d fix(openai): replace responses websocket transcript when pending tool calls are unanswered
- Treat subsequent responses websocket requests without previous_response_id that leave pending tool calls unanswered as transcript replacements regardless of incremental upstream mode.
- Add regression tests covering both unanswered and answered pending tool calls when incremental previous_response_id injection is disabled.

Closes: #7320
2026-11-07 17:09:50 +08:00
Dylan
bbefed6824 Merge pull request #7305 from router-for-me/fix/codex-refresh-uncertain-outcome
fix(auth): keep native Codex available during SIWC recovery
2026-11-07 12:54:59 +08:00
Dylan
5f38d5572c fix(auth): keep native Codex available during SIWC recovery
Preserve unknown refresh recovery state without inventing an access-token rejection. Evaluate availability for the requested partition and block missing tokens before model-level selection in both auth guards.

Cover partial refresh and later inference through real OAuth HTTP responses, CodexExecutor, and Manager execution. Auth, executor, integration, race, and build checks pass. The full suite encounters an existing WebSocket temporary-log cleanup race, reproduced on clean dev.
2026-11-07 12:50:35 +08:00
Luis Pater
c5251b57b3 fix(translator): preserve reasoning and text across multi-part gemini and antigravity chunks
- Treat empty-text thoughtSignature carrier parts as non-content payloads in Gemini and Antigravity OpenAI Chat Completions response translators so trailing signature parts do not overwrite earlier deltas.
- Accumulate reasoning_content and content across all parts within a candidate chunk using strings.Builder before writing the delta fields.
- Add regression tests covering trailing empty-text signature parts and multi-part thought and text concatenation.

Closes: #7315
v8.0.59
2026-11-07 12:35:41 +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
Dylan
eabcd01d77 Merge pull request #7317 from router-for-me/fix/claude-oauth-authorization-parameters
fix(claude): restore OAuth login compatibility
2026-11-07 12:15:29 +08:00
Dylan
ea0b471291 fix(claude): align OAuth authorization state and scopes
Use a Claude-specific 256-bit base64url state for CLI and management logins. Include the native Console scope only during authorization while preserving existing token refresh scopes. Cover callback state preservation and case-sensitive session checks. Refs #7316.
2026-11-07 12:05:08 +08:00
Luis Pater
482efbf5a7 feat(auth): enhance OAuth provider handling with explicit hints and metadata preservation 2026-11-07 04:38:59 +08:00
Luis Pater
c9f9739869 Merge pull request #7308 from WizisCool/feat/management-oauth-provider
feat(management): expose oauth_provider in credential list
2026-11-07 04:06:33 +08:00
Luis Pater
374056f28b fix(codex): preserve prompt cache prefix when loading deferred tools via ToolSearch
- Withhold defer_loading tools from top-level Codex tools[] and emit discovered definitions as additional_tools input items at the tool_result or tool_reference discovery point.
- Deduplicate repeated tool_reference declarations across turns and prioritize non-deferred tools in short-name mapping so newly inserted deferred tools never alter existing top-level tool names.
- Add regression tests covering ToolSearch discovery cache-prefix stability, repeated references, colliding >64-char MCP tool names, mixed tool_result content, and standalone reference ordering.

Closes: #7303
2026-11-07 03:24:41 +08:00
Jehuda Rajasa
a46be7ae3b fix(codex): retain SIWC renewal windows in refresh receipts 2026-11-07 01:27:48 +07:00
Jehuda Rajasa
03c394ee3f test(codex): make SIWC power-state checks deterministic 2026-11-07 01:23:36 +07:00
Jehuda Rajasa
baec297fec fix(auth): retain partition failures alongside SIWC wake cancellation 2026-11-07 01:23:36 +07:00
Jehuda Rajasa
8c6d8b1801 fix(codex): defer SIWC renewal during macOS maintenance wakes 2026-11-07 01:23:19 +07:00
Jehuda Rajasa
3891ebaab5 fix(codex): reuse the issued SIWC client during CLI reauthorization 2026-11-07 01:23:19 +07:00
Jehuda Rajasa
80ee739f33 fix(codex): preserve SIWC rotations and honor renewal windows 2026-11-07 01:23:01 +07:00
Luis Pater
2443e8830c fix(codex): normalize nested custom tools across Chat Completions round trips
- Flatten nested custom tool definitions and grammar formats into Responses API declarations while resolving nested names for tool choice, shortening, reverse mapping, and conversation history.
- Normalize nested custom tool declarations when collecting response metadata so custom apply_patch calls emit the JSON input wrapper across streaming and non-streaming responses.

Closes: #7300
2026-11-07 02:21:05 +08: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
JUNZE
0559fa3cfd feat(management): expose oauth_provider in credential list
Report the OAuth login entry a credential was signed in through, resolved
from Attributes then Metadata via oauth_provider and portal and normalized
the way sign-in and re-login already resolve it. A console can then group
credentials of a multi-entry plugin by entry instead of by provider.

The field is v8-only, so the deprecated /v0/management/auth-files response
keeps its frozen shape, and it is omitted when a credential carries no
entry, leaving built-in providers, single-entry plugins and files written
before #7126 unchanged. type and provider stay as they are because routing
and quota lookup key on them.

Fixes #7307
2026-11-07 01:54:58 +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
Kenny
59a2b35313 docs(readme): add SWE-2 Flash to Devin models 2026-11-06 09:03:15 -08:00
Dylan
e5e6ad1e1b Merge pull request #7295 from router-for-me/fix/codex-hosted-image-request-scope
fix(codex): reject unsupported hosted image requests
v8.0.58
2026-11-06 20:49:38 +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
Dylan
2c16b1a3df Merge pull request #7294 from router-for-me/fix/home-terminal-request-boundaries
fix(auth): preserve terminal responses across execution paths
2026-11-06 16:38:03 +08:00
Dylan
1d4e054978 fix(auth): preserve terminal responses across execution paths
Treat preserved terminal responses as request-scoped unless the executor
marks a credential-specific rejection. Reuse the existing request error
policy to stop credential retries, unauthorized refresh, and cooldown
without changing explicit continue rules or ordinary failover.

End stopped Home stream selections without waiting for a redispatch
release acknowledgement that could replace the original response.

Cover local and Home execute, count, stream and bootstrap paths, exact
response preservation, missing release acknowledgements, and terminal
401 refresh suppression.

Refs: router-for-me/CLIProxyAPIHome#178
2026-11-06 16:27:43 +08:00
Luis Pater
e458999bb3 fix(claude): show cooldown retry time in error messages
- Include the trusted retry delay in Claude cooldown errors.
- Verify response headers and stream messages across cooldown cases.

Closes: #7285
2026-11-06 10:25:22 +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
duu261
418b824ca6 docs(readme): mention cpa-status in Hermes entry 2026-11-06 04:37:49 +07:00
Luis Pater
c1842be211 feat(models): add gpt-6-chat-thinking to registries
- Register gpt-6-chat-thinking with 272k context, 128k max completion tokens, and thinking levels (low/medium/high/xhigh/max) across four model groups.
- Enable native web_search capability and configuration update support for the new model entry.
2026-11-06 03:19:46 +08:00