You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] filter_restored_tool_context is incompatible with extended thinking #621
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.
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.
Activity
gingeekrishna commentedon Aug 8, 2026
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
reasoningContentblock immediately followed by atoolUseblock — they're treated as a coupled pair by the API.filter_restored_tool_contextwas strippingtoolUse/toolResultbut leavingreasoningContentintact, producing a partial assistant message that Bedrock rejects with aValidationException.Fix: Add
"reasoningContent" not in contentto 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.
fix: strip reasoningContent blocks in filter_restored_tool_context