Skip to content

Adapt reasoning history automatically for routed upstreams - #396

Merged
fylorn merged 6 commits into
mainfrom
codex/reasoning-history-capabilities
Nov 10, 2026
Merged

fylorn merged 6 commits into
mainfrom
codex/reasoning-history-capabilities

Conversation

@fylorn

@fylorn fylorn commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Problem and behavior

Chat-compatible APIs do not share a reasoning-history request schema. A later conversation turn can fail with 422 extra_forbidden for messages[n].assistant.reasoning_content even when earlier responses and tool calls worked.

History conversion preserves native thinking blocks, ordering, signatures and source identity, and encodes separately for the actual routed upstream and model. Existing advanced provider/model capabilities and exact endpoint profiles select the request encoding. Signed history is rejected before contacting an incompatible upstream.

Automatic mode also negotiates from precise structured HTTP 400/422 field-validation errors on unknown Chat-compatible endpoints. The reported message must actually be an assistant message containing that field. Only the explicitly rejected unsigned field is omitted; rejection does not imply support for another encoding. The request is rebuilt from the original history and passes through outbound redaction again. One logical request has one schema-repair budget shared across providers and existing effort, cache-breakpoint and sealed-history repairs. The resend is a separately accounted attempt.

Automatic runtime behavior

Only accepted adjustments are remembered. The internal cache is bounded to 1,024 entries, expires after 24 hours and resets on configuration reload/restart. It isolates actual upstream credentials/headers, model, API path and tool/thinking mode. Configuration reload replaces the runtime, so requests using an older runtime cannot populate the new cache.

There are no new settings screens, menu entries or compatibility-management endpoints. Existing advanced overrides remain authoritative and survive ordinary provider/model edits. Core is prepared as 0.92.0. The control protocol remains 58 and request-store schema remains 28.

Validation and scope

Regression tests cover actual multi-turn exchanges, exact validation locations, explicit-override precedence, bounded retries across failover, unsuccessful trials, cache isolation/expiry/reload, signed native history, tool-call/result IDs and outbound redaction on every attempt. SSE errors never start negotiation or confirm a trial. Ambiguous errors and required reasoning profiles do not trigger omission.

Refs ThinkWatchProject/ThinkWatch-Lite#407. This fixes the reproduced multi-turn field rejection. The original streaming-delay report remains open for reporter confirmation or a complete capture. No installed application, live database or client configuration is changed. Lite will receive the matching tagged Core dependency on dev; its release remains deferred.

Validation passed: gateway unit/conversion/negotiation suites (872 tests), API/control/configuration suites (832 passed, 1 ignored), generated documentation and message-code manifests, and workspace all-target Clippy with warnings denied. Final platform CI passed on macOS (4,397 tests), Linux (4,394) and Windows (4,376), including real-binary/control-plane smoke checks. Regression coverage also confirms that a plugin changing the retry body cannot make an unapplied repair populate the cache.

@fylorn fylorn changed the title Preserve reasoning history with upstream capabilities Negotiate reasoning-history compatibility safely Nov 10, 2026
@fylorn
fylorn marked this pull request as ready for review November 10, 2026 17:11
@fylorn fylorn changed the title Negotiate reasoning-history compatibility safely Adapt reasoning history automatically for routed upstreams Nov 10, 2026
@fylorn
fylorn merged commit 9e617ea into main Nov 10, 2026
7 checks passed
@fylorn
fylorn deleted the codex/reasoning-history-capabilities branch November 10, 2026 17:54
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 10, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant