fix: stop replaying Anthropic thinking as visible xAI assistant text (#12128)#12131
Open
shaun0927 wants to merge 1 commit intoRooCodeInc:mainfrom
Open
fix: stop replaying Anthropic thinking as visible xAI assistant text (#12128)#12131shaun0927 wants to merge 1 commit intoRooCodeInc:mainfrom
shaun0927 wants to merge 1 commit intoRooCodeInc:mainfrom
Conversation
The xAI Responses path reuses convertToResponsesApiInput() when replaying persisted conversation history. Anthropic thinking blocks were being flattened into ordinary assistant-visible output_text entries, which changes conversation semantics and leaks hidden reasoning into later prompt context. This keeps the fix intentionally narrow: persisted Anthropic thinking blocks are now skipped for Responses replay, and a regression test covers the behavior. Constraint: Keep the change scoped to the replay transform without changing provider selection or task persistence Rejected: Preserve thinking by converting it to [Thinking] output_text | turns hidden reasoning into visible assistant content Confidence: medium Scope-risk: narrow Reversibility: clean Directive: If a provider-specific hidden reasoning replay format is added later, prefer that over flattening Anthropic thinking into visible text Tested: pnpm --dir src exec vitest run api/transform/__tests__/responses-api-input.spec.ts api/providers/__tests__/xai.spec.ts Not-tested: Full end-to-end provider-switch replay with live xAI credentials
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.
Related GitHub Issue
Closes: #12128
Description
This PR keeps the fix intentionally narrow and only addresses the replay behavior reported in
#12128.The current xAI Responses path reuses
convertToResponsesApiInput()when replaying persisted conversation history. That helper was flattening Anthropicthinkingblocks into ordinary assistant-visibleoutput_textentries like[Thinking] ..., which changes the semantics of the saved history.This PR changes the replay transform to skip persisted Anthropic
thinkingblocks instead of converting them into visible assistant text.Why this scope is narrow:
Files touched:
src/api/transform/responses-api-input.tssrc/api/transform/__tests__/responses-api-input.spec.tsTest Procedure
pnpm --dir src exec vitest run api/transform/__tests__/responses-api-input.spec.ts api/providers/__tests__/xai.spec.tsResult locally:
2test files passed30tests passedPre-Submission Checklist
Documentation Updates
Additional Notes
I chose the narrowest behaviorally-safe fix I could see from the issue discussion: do not replay persisted Anthropic hidden reasoning as visible assistant text. If maintainers want a different provider-specific hidden-reasoning replay strategy later, this should still be a cleaner baseline than flattening
thinkingintooutput_text.