Repository navigation
fix: preserve Anthropic replay fidelity - #25377
Conversation
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c955d6f573
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
|
/coder-agents-review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a9a0e92384
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Also addressed the non-thread DEREM-11 note in f4ef648: retry-time prompt preparation failures now preserve the phase label ( |
|
/coder-agents-review |
|
@codex review |
|
Codex Review: Didn't find any major issues. Nice work! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
There was a problem hiding this comment.
All 13 R1 findings addressed in f4ef648. Verified by 4 reviewers (Bisky, Mafuuu, Hisoka, Meruem) across the full delta.
Fix highlights: user-facing error now includes "Start a new chat to continue," the retryPrepareErr retry path has integration test coverage, the signed-reasoning predicate is centralized through hasAnthropicSignedReasoningMetadata, the immutability contract is documented at the top of anthropic.go, call.Prompt is only assigned on success, and the naming inversions are resolved.
Hisoka: "The code held up. Traced the SanitizeAnthropicProviderToolHistory loop with the immutable index exclusion. Each pass removes at least one non-immutable part. When only immutable violations remain, remove empties, loop terminates. No infinite loop."
1 nit (redundant assertion). Otherwise clean.
🤖 This review was automatically generated with Coder Agents.
…ned reasoning boundary Make the Anthropic signed/redacted reasoning message an immutable transcript boundary as a property of message content, enforced inside the appendSanitizedMessage merge primitive itself. Previously, three call sites preserved the immutable message by branching on messageIndex == immutableIndex and routing through a separate appendSanitizedMessagePreservingStructure helper. That left a hole: if sanitization dropped an intervening message, a later assistant message could still coalesce into the preserved signed assistant via the normal append path and mutate the signed reasoning block sequence. Move the invariant into appendSanitizedMessage: refuse to merge when either the prior or incoming message carries signed reasoning. The three call-site branches and the appendSanitizedMessagePreservingStructure helper are gone, and the local immutableIndex bookkeeping in stripAnthropicProviderToolHistoryFromMessages is no longer needed. Add table-driven tests covering signed and redacted reasoning variants on both the backward edge (prior assistant must not merge into signed) and the forward edge after a dropped intervening assistant.
Centralize the signed-reasoning predicate in chatsanitize, restrict immutability to the actual latest assistant turn, and make the guard contract return nil prompts on error so unsafe re-prepared prompts cannot leak into retry state. Also add retry-path coverage for chain-broken recovery, improve the user-facing recovery guidance, clarify the signed-turn merge boundary, and simplify the follow-up helpers/tests now that the invariant lives in the merge primitive.
a5b6a03 to
24b06fa
Compare
Anthropic is strict about replaying the latest assistant turn once it contains signed or redacted reasoning. We were still mutating that turn in a few Coder-owned places: dropping empty reasoning blocks on replay, rewriting provider-tool history during sanitization, and in the worst case sending a prompt we already knew Anthropic would reject.
This patch keeps the latest signed assistant immutable through Coder's replay and sanitization paths, preserves empty signed or redacted reasoning anywhere Coder owns the ledger, and fails before the provider call if the prompt is still unsafe.
It also bumps the existing
coder/fantasycoder_2_33fork thatmainalready uses to the commit containing coder/fantasy#35. These fixes have also been upstreamed to charmbracelet/fantasy.Closes CODAGT-409.