Repository navigation
fix: replay signed thinking for the Claude (MultiProvider) route - #2266
Open
lambdaloop wants to merge 1 commit into
Open
lambdaloop wants to merge 1 commit into
lambdaloop wants to merge 1 commit into
Conversation
Contributor
[Medium impact] The PR appears safe to merge, with a non-blocking test-isolation issue. Findings
Fix with agent prompt### Issue 1
crates/jcode-base/src/message/tests.rs:930-934
If `preserve_reasoning_context` is disabled in the user's config file or through `JCODE_PRESERVE_REASONING_CONTEXT=false`, this test fails at `assert!(store)` even though the code correctly honors that setting. Give the test a controlled configuration, or test the provider-name match separately from the configuration gate.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.SummaryFixes signed thinking replay for the default Claude route.
Reviews (2) · Last reviewed commit: "fix: replay signed thinking for the Clau..." · Reviewed by Greptile |
xenking
added a commit
to xenking/jcode
that referenced
this pull request
Nov 22, 2026
Recognize the MultiProvider Claude route and keep every completed signed block, including empty ones, in its original position among provider-native blocks. Keep unsigned reasoning in the readable trace and honor the existing replay setting. Upstream-PR: 1jehuang#2266 Related-Upstream-PR: 1jehuang#2274 Co-authored-by: Lili Karashchuk <[email protected]> Co-authored-by: eniyanyosuva <[email protected]>
xenking
added a commit
to xenking/jcode
that referenced
this pull request
Nov 22, 2026
Upstream-PR: 1jehuang#1357 Upstream-PR-Commit: 1jehuang#1357 0da5e81 Upstream-PR: 1jehuang#1362 Upstream-PR-Commit: 1jehuang#1362 5962058 Upstream-PR: 1jehuang#1486 Upstream-PR-Commit: 1jehuang#1486 fadc624 Upstream-PR: 1jehuang#1733 Upstream-PR-Commit: 1jehuang#1733 01f3415 Upstream-PR: 1jehuang#1750 Upstream-PR-Commit: 1jehuang#1750 1ac0c82 Upstream-PR: 1jehuang#1822 Upstream-PR-Commit: 1jehuang#1822 73f85fc Upstream-PR: 1jehuang#1912 Upstream-PR-Commit: 1jehuang#1912 36d7682 Upstream-PR: 1jehuang#1978 Upstream-PR-Commit: 1jehuang#1978 0f55643 Upstream-PR: 1jehuang#2007 Upstream-PR-Commit: 1jehuang#2007 638f87c Upstream-PR: 1jehuang#2213 Upstream-PR-Commit: 1jehuang#2213 c5e1487 Upstream-PR: 1jehuang#2234 Upstream-PR-Commit: 1jehuang#2234 0d4d5d4 Upstream-PR: 1jehuang#2266 Upstream-PR-Commit: 1jehuang#2266 217ddc2 Upstream-PR: 1jehuang#2267 Upstream-PR-Commit: 1jehuang#2267 e98c40b
Comment on lines
+930
to
+934
| let store = crate::provider::stores_reasoning_content_for_context("Claude"); | ||
| assert!( | ||
| store, | ||
| "Claude turns must keep their signed thinking for replay" | ||
| ); |
Contributor
There was a problem hiding this comment.
If preserve_reasoning_context is disabled in the user's config file or through JCODE_PRESERVE_REASONING_CONTEXT=false, this test fails at assert!(store) even though the code correctly honors that setting. Give the test a controlled configuration, or test the provider-name match separately from the configuration gate.
Prompt To Fix With AI
This is a comment left during a code review.
Path: crates/jcode-base/src/message/tests.rs
Line: 930-934
Comment:
**Local settings break the test**
If `preserve_reasoning_context` is disabled in the user's config file or through `JCODE_PRESERVE_REASONING_CONTEXT=false`, this test fails at `assert!(store)` even though the code correctly honors that setting. Give the test a controlled configuration, or test the provider-name match separately from the configuration gate.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
This branch has not been deployed
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.
Closes #2265
Symptom
On the default Claude route (
MultiProvider, which reports its name as"Claude"), signed thinking blocks are never replayed to the Anthropic API. The model re-plans every tool-loop step and thinks far longer than it needs to.Root cause
stores_reasoning_content_for_context(provider/mod.rs) andpush_reasoning_blocks(message.rs) gate replay on the provider name"anthropic". ButMultiProvider::name()returns"Claude"forActiveProvider::Claude, which dispatches to the Anthropic runtime. So the signature-bearingAnthropicThinkingblock is never stored.Fix
"claude"(case-insensitive, like the existing checks).AnthropicThinkingblock is inserted at the front of the assistant content instead of after the text. Anthropic expects thinking to lead the assistant turn, and the request builder sends blocks in stored order.push_reasoning_blocks_claude_multiprovider_replays_signed_thinking_first) fails before the fix and passes after.The diff is 3 files, +38/−7. I kept it deliberately minimal. A more structural option would be a provider capability (for example
Provider::reasoning_replay()) that asks the runtime for its wire format instead of matching names. I'm happy to follow up with that if you prefer.Measured effect
Opus 5.5, medium effort, comparable agent workloads, before vs after replay was fixed:
Tests
cargo test -p jcode-base --lib: the new test and the existingpush_reasoning_blocks_*tests pass.