Skip to content

[Bug]: Reasoning model thinking blocks (<thinking> tags) in conversation history cause HTTP 400 on GitHub Copilot provider #81520

Description

@warcold

Bug type

Crash (process/app exits or hangs)

Beta release blocker

No

Summary

When a reasoning model generates blocks, they get stored in conversation history and sent back to GitHub Copilot on the next turn, which rejects them with HTTP 400 — breaking every multi-turn conversation.

Steps to reproduce

  1. Configure an agent with claude-sonnet-4.6 or claude-opus-4 via the GitHub Copilot provider, with thinking enabled.
  2. Send any message — the model generates a block, which gets stored in history.
  3. Send a follow-up in the same session.
  4. OpenClaw includes the {type: "thinking"} block from step 2 in the history sent to the API.
  5. GitHub Copilot returns HTTP 400.

First message works fine every time. It breaks on the second, without exception.

Expected behavior

Thinking blocks are internal model state — they should never appear in the history sent to the API. The context sanitization pipeline should strip them before any request goes out.

Actual behavior

HTTP 400 from the GitHub Copilot API on every second turn of any conversation with a reasoning model. The request payload shows the assistant message from turn 1 with a content array that includes {type: "thinking", thinking: "..."} — Copilot rejects this. Single-turn conversations are completely unaffected.

OpenClaw version

OpenClaw version: v2026.5.7

Operating system

Kali Linux

Install method

npm global (npm install -g openclaw)

Model

claude-sonnet-4.6 (also confirmed with claude-opus-4)

Provider / routing chain

OpenClaw → GitHub Copilot provider → Claude Sonnet 4.6

Additional provider/model setup details

No response

Logs, screenshots, and evidence

Second message in any conversation returns a 400 from the Copilot API endpoint. Payload inspection shows the assistant message from turn 1 containing a content array with a {type: "thinking"} block. Single-turn conversations succeed without any issue.

Impact and severity

  • Affected: Any deployment using reasoning models (Claude Sonnet/Opus) with the GitHub Copilot provider
  • Severity: High — multi-turn conversations broken entirely
  • Frequency: Every 2nd message, 100% reproducible
  • Consequence: The bot can't hold a conversation past the first exchange

Additional information

The fix is in dist/model-context-tokens*.js, in the sanitizedWithProvider function before the final return. Filter out any assistant message content blocks with type === "thinking" or type === "redacted_thinking":

content = content.filter(b => b.type !== 'thinking' && b.type !== 'redacted_thinking')

One line, applied in the right place — fully resolves the issue in production.

Metadata

Metadata

Assignees

Labels

P1High-priority user-facing bug, regression, or broken workflow.bugSomething isn't workingbug:crashProcess/app exits unexpectedly or hangsclawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:auth-providerAuth, provider routing, model choice, or SecretRef resolution may break.impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.

Type

No type

Fields

Priority

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions