Skip to content

feat(session): auto-recovery for 'Invalid signature in thinking block' errors #89684

Description

@ai-agents-lahaus

Problem

When thinking: adaptive is enabled and a session has accumulated signed thinking blocks, a model version update (or TTL expiry) can invalidate those signatures. The gateway currently has no recovery path for this error:

LLM request rejected: messages.N.content.N: Invalid signature in thinking block

The session enters a permanent loop — every subsequent message re-attempts the same request with the corrupt history, failing repeatedly. The only workaround is a manual /reset command, which loses session context.

Steps to Reproduce

  1. Enable thinking: adaptive on an agent
  2. Let the session accumulate thinking blocks over an extended period
  3. Trigger a model version update (fleet rolling deploy) OR wait for signature TTL to expire
  4. Any new message to the agent triggers the error loop

Expected Behavior

When the gateway receives Invalid signature in thinking block from the LLM provider:

  1. Strip all thinking blocks from the current session history
  2. Retry the original request
  3. Log a warning for audit purposes (e.g., [session] thinking blocks stripped due to invalid signature, retrying)

Current Behavior

The gateway forwards the error to the end user and does not retry or recover.

Impact

  • Agent session becomes permanently stuck until manual /reset
  • All in-flight tool calls and pending messages are lost
  • Affects production agent workloads silently (the error may be invisible to operators)

Suggested Recovery Config (optional)

Could be gated behind a config flag:

{
  "compaction": {
    "recoverInvalidThinkingBlocks": true
  }
}

Default true seems safe since the alternative is a hard failure.

Environment

  • OpenClaw 2026.5.27 (27ae826)
  • Model: anthropic/claude-opus-4-6 with thinking: adaptive
  • Triggered after fleet update to claude-opus-4-6
  • Session context at ~7% of 1M limit (compaction.mode: safeguard did not trigger)

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High-priority user-facing bug, regression, or broken workflow.impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions