Skip to content

Anthropic thinking block 'signature' field lost during session persistence — causes API rejection #43691

Description

@PenguinMiaou

Problem

When using Anthropic models with extended thinking enabled, the signature field on thinking content blocks is not preserved when messages are serialized to the session JSONL file. When the conversation history is sent back to the Anthropic API in subsequent turns, the API rejects the request:

LLM request rejected: messages.31.content.2: `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

Anthropic API returns thinking blocks with a signature field that must be passed back verbatim. During session persistence (writing to .jsonl), the signature field is stripped or not captured. Inspecting the session file confirms all thinking blocks have no signature:

type=thinking thinking_len=224 signature=(none)
type=thinking thinking_len=562 signature=(none)
...

This causes any subsequent API call using those messages to fail, since the thinking blocks are considered "modified".

Impact

  • Once the session accumulates enough messages with thinking blocks, all further interactions in that session fail permanently
  • /new and /reset commands may not properly clear the corrupted session
  • The only workaround is manually deleting the session JSONL file

Steps to reproduce

  1. Configure an agent with anthropic/claude-sonnet-4-6 (or any Anthropic model with thinking)
  2. Have a multi-turn conversation in a Feishu group (or any channel)
  3. After ~15+ assistant turns with thinking, the session starts failing with the above error

Expected behavior

The signature field (and any other fields) on thinking / redacted_thinking content blocks should be preserved exactly as received from the API when serializing to the session file.

Environment

  • OpenClaw version: 2026.3.8
  • Model: anthropic/claude-sonnet-4-6
  • Provider: anthropic
  • Compaction mode: safeguard

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions