Skip to content

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

@shaun0927

Description

@shaun0927

Problem (one or two sentences)

When a persisted conversation contains Anthropic thinking blocks and that history is replayed through the xAI Responses API path, Roo converts the hidden reasoning into ordinary assistant text ([Thinking] ...) instead of preserving or safely dropping it.

Context (who is affected and when)

This affects users who switch providers or resume existing conversations where earlier turns were produced by an Anthropic reasoning model and later turns are sent through the xAI provider.

Reproduction steps

Tested locally on current main at cb83656718.

  1. Install dependencies in the repo.
  2. Run the following script from the repo root:
import { convertToResponsesApiInput } from './src/api/transform/responses-api-input'

const messages = [
  {
    role: 'assistant',
    content: [
      { type: 'thinking', thinking: 'SECRET_CHAIN_OF_THOUGHT', signature: 'sig-1' },
      { type: 'text', text: 'visible answer' },
    ],
  },
] as any

console.log(JSON.stringify(convertToResponsesApiInput(messages), null, 2))
  1. Observe that the transform outputs:
[
  {
    "type": "message",
    "role": "assistant",
    "content": [
      {
        "type": "output_text",
        "text": "[Thinking] SECRET_CHAIN_OF_THOUGHT"
      }
    ]
  },
  {
    "type": "message",
    "role": "assistant",
    "content": [
      {
        "type": "output_text",
        "text": "visible answer"
      }
    ]
  }
]

Expected result

Persisted Anthropic thinking blocks should either:

  • be dropped for the xAI Responses replay path, or
  • be preserved only in a provider-safe/native hidden reasoning format.

They should not be flattened into normal assistant-visible text.

Actual result

thinking is converted into a normal assistant output_text entry prefixed with [Thinking], which changes the semantics of the conversation history and can leak previously hidden reasoning into later prompt context.

Variations tried (optional)

Related local source inspection on current main:

  • src/core/task/Task.ts:904-924 persists Anthropic reasoning as type: "thinking"
  • src/api/providers/xai.ts:93-104 routes xAI history through convertToResponsesApiInput(messages)
  • src/api/transform/responses-api-input.ts:55-63 converts thinking into [Thinking] ... text

App Version

main (cb83656718)

API Provider (optional)

xAI

Model Used (optional)

Grok / xAI Responses path

Roo Code Task Links (optional)

No response

Relevant logs or errors (optional)

This seems best categorized as a provider interoperability / reasoning round-trip bug rather than a general crash. The regression appears adjacent to the xAI Responses migration in #11961 / #11962, but I could not find an existing issue that tracks this exact replay behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions