Skip to content

fix: stop replaying Anthropic thinking as visible xAI assistant text (#12128)#12131

Open
shaun0927 wants to merge 1 commit intoRooCodeInc:mainfrom
shaun0927:fix/xai-drop-anthropic-thinking-replay
Open

fix: stop replaying Anthropic thinking as visible xAI assistant text (#12128)#12131
shaun0927 wants to merge 1 commit intoRooCodeInc:mainfrom
shaun0927:fix/xai-drop-anthropic-thinking-replay

Conversation

@shaun0927
Copy link
Copy Markdown

@shaun0927 shaun0927 commented Apr 16, 2026

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 Anthropic thinking blocks into ordinary assistant-visible output_text entries like [Thinking] ..., which changes the semantics of the saved history.

This PR changes the replay transform to skip persisted Anthropic thinking blocks instead of converting them into visible assistant text.

Why this scope is narrow:

  • no provider selection changes
  • no task persistence changes
  • no attempt to invent a new hidden-reasoning format for Responses replay
  • only the replay transform behavior is corrected, plus a regression test

Files touched:

  • src/api/transform/responses-api-input.ts
  • src/api/transform/__tests__/responses-api-input.spec.ts

Test Procedure

  • pnpm --dir src exec vitest run api/transform/__tests__/responses-api-input.spec.ts api/providers/__tests__/xai.spec.ts

Result locally:

  • 2 test files passed
  • 30 tests passed

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue.
  • Scope: Changes are focused on the linked issue.
  • Self-Review: I performed a self-review.
  • Testing: Added/updated tests for the changed behavior.
  • Documentation Impact: No user-facing documentation updates are required.
  • Contribution Guidelines: I reviewed the contribution guidelines.

Documentation Updates

  • No documentation updates are required.

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 thinking into output_text.

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] xAI Responses API path replays persisted Anthropic thinking blocks as plain assistant text

1 participant