Skip to content

Opus 4.8 + adaptive thinking: replayed thinking blocks lose text but keep signature → 400 "thinking blocks cannot be modified" on multi-turn #17457

@BrandiATMuhkuh

Description

@BrandiATMuhkuh

Summary

With the model router pointed at anthropic/claude-opus-4-8 and adaptive extended thinking, multi-turn conversations backed by Memory fail on the Anthropic API with a 400:

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

(invalid_request_error, HTTP 400, from AnthropicMessagesLanguageModel.doStream)

Root cause (observed)

When a prior assistant turn is replayed from Memory on a follow-up request, its thinking blocks are sent back with an empty thinking text but the original signature retained:

{ "type": "thinking", "thinking": "", "signature": "EtcDCmMIDhgC…<truncated>==" }

Anthropic re-validates the signature against the (now empty) text and rejects the block as "modified". This only triggers on a continuation — a follow-up message into a thread that already contains a signed-thinking assistant turn. Fresh single-shot runs are fine.

Versions

  • @mastra/core 1.37.0
  • @mastra/memory 1.20.0 (PostgresStore via @mastra/pg)
  • ai 6.0.x
  • model: anthropic/claude-opus-4-8 (model router)
  • providerOptions.anthropic: { thinking: { type: "adaptive" }, effort: "high" } → serialized to thinking: { type: "adaptive" } + output_config: { effort: "high" }

Repro

  1. Agent with Memory (Postgres), tools enabled, and the adaptive-thinking provider options above on claude-opus-4-8.
  2. Run a turn that produces thinking + tool calls; let it complete and persist to the thread.
  3. Send a follow-up message in the same thread.
  4. The next request 400s as above.

Notes

Expected

Persisted Anthropic thinking blocks should round-trip verbatim (text and signature), or be safely stripped from completed prior turns before send so the signature/text invariant can't break.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions