Skip to content

Thinking blocks in conversation history cause 400 error on multi-turn #45

Description

@meappy

Problem

Multi-turn conversations fail with:

messages.15.content.5: `thinking` or `redacted_thinking` blocks in the latest assistant message cannot be modified. These blocks must remain as they were in the original response.

Root Cause

The proxy correctly protects thinking blocks during forward/reverse mapping. However, OpenClaw's internal JSON storage appears to re-serialise the conversation history (normalising whitespace, key ordering, or escaping). When the thinking blocks are sent back on the next turn, they're no longer byte-identical to the original API response.

Environment

  • OpenClaw v2026.4.11
  • Model: claude-sonnet-4-6 (extended thinking enabled)
  • Proxy cloned from main branch

Suggested Fix

Option 1: Strip all thinking and redacted_thinking blocks from request message history before forwarding to the API. The API accepts messages without thinking blocks — it just requires them to be byte-identical if present.

Option 2: Detect and strip only from the latest assistant message (since that's what Anthropic validates).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions