fix(runtime): gate provider reasoning replay by source model - #4286
Draft
Astro-Han wants to merge 3 commits into
Draft
fix(runtime): gate provider reasoning replay by source model#4286Astro-Han wants to merge 3 commits into
Astro-Han wants to merge 3 commits into
Conversation
Astro-Han
force-pushed
the
fix/reasoning-replay-provenance
branch
3 times, most recently
from
August 31, 2026 01:21
2f5e97b to
a8d4bcb
Compare
Generated-by: Codex
Requires the source-route replay gate established by the preceding commit. Generated-by: Codex
Requires the source-route replay gate established by the first commit in this series. Generated-by: Codex
Astro-Han
force-pushed
the
fix/reasoning-replay-provenance
branch
from
August 31, 2026 01:54
a8d4bcb to
1feb2ef
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix provider-owned reasoning replay at the existing ModelAdapter → RuntimeEvent → AiSdkBackend boundary.
Root cause
The durable transcript already retained signed and plaintext provider reasoning, but replay projection had no source-route proof. Anthropic redacted thinking was emitted on reasoning-start metadata, which ModelAdapter previously discarded. Copilot OpenAI Chat returned reasoning_content but did not participate in the existing plaintext replay transport.
Fresh review also found that native OpenAI Codex history compaction projected RuntimeEvents without the AgentRun route headers used by normal replay. Cross-model provider reasoning could therefore enter a compaction request, making admitted replay differ from dispatched replay.
After adding route provenance to compaction, the malformed-summary circuit initially hashed every available run header. A failed manual compaction adds a header without adding model-visible folded content, so an unchanged retry received a different fingerprint and redispatched the same doomed request. The fingerprint now includes only routes referenced by folded events, in stable order.
Ownership and compatibility
RuntimeEvent remains the durable transcript authority. AgentRunHeader remains the route-provenance authority. ModelAdapter remains the only AI SDK boundary. Maka ToolRuntime and the outer loop continue to own execution, permissions, concurrency, and recovery.
This change does not add a provider serializer, duplicate provenance fields, a second replay converter, or another agent loop.
Provider-owned reasoning from another model, another connection, or legacy history without matching provenance now fails closed. Ordinary text, tool calls, and tool results remain available. Exact same-route Anthropic, Copilot OpenAI Chat, and OpenAI Responses replay remain enabled.
Commit structure
The three commits form an intentional dependency series, not three arbitrary-order revert units:
Either provider capability can be reverted independently. Removing the shared gate requires reverting the dependent provider commits first. This keeps one gate instead of duplicating safety policy per provider.
Simplification
The adjacent simplification pass removed:
Public wire and runtime composition coverage remains.
Verification
AI use
Select exactly one:
Tool(s) and scope: Codex implemented the runtime contract changes and tests through debug, TDD, adversarial review, and simplification-audit workflows. All three material commits include the Generated-by: Codex trailer.
Checklist
Does this PR entail a change in behavior?