Skip to content

[BUG] filter_restored_tool_context is incompatible with extended thinking #621

Open

Description

@surecloud-jleite

Version

bedrock-agentcore 1.19.0

Model

Claude Sonnet 4.6 via Amazon Bedrock, with extended thinking enabled ({"type": "adaptive", "display": "summarized"})

What happens

Setting filter_restored_tool_context=True on AgentCoreMemoryConfig makes every request fail once there is history to restore:

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

The option is unusable for any agent with extended thinking enabled. Turning the flag off restores normal operation.

Expected

Either the option works alongside extended thinking, or the incompatibility is documented and the flag rejected at configuration time rather than failing on every request at runtime.

Context

We hit this while trying to work around strands-agents/harness-sdk#3651, where an interrupted turn leaves a session permanently unusable.

Activity

  1. gingeekrishna commented on Aug 8, 2026

    @gingeekrishna

    Hi, I've investigated this and opened a fix in #627.

    Root cause: When extended thinking is enabled, Bedrock structures an assistant turn as a reasoningContent block immediately followed by a toolUse block — they're treated as a coupled pair by the API. filter_restored_tool_context was stripping toolUse/toolResult but leaving reasoningContent intact, producing a partial assistant message that Bedrock rejects with a ValidationException.

    Fix: Add "reasoningContent" not in content to the filter predicate in _filter_restored_tool_context() so thinking blocks are always removed together with the tool calls they preceded.

    Five new tests cover the new behaviour and confirm no regression in the existing tool-context filtering.

  2. added a commit that references this issue on Oct 6, 2026
    d007650
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

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions