[GH-ISSUE #245] Bug: thinking blocks leak into ToolMessage from returnCommandWithStateUpdate #239

Closed
opened 2026-06-05 17:21:12 -04:00 by yindo · 0 comments
Owner

Originally created by @antonnak on GitHub (Feb 23, 2026).
Original GitHub issue: https://github.com/langchain-ai/deepagentsjs/issues/245

Related to #239returnCommandWithStateUpdate() passes lastMessage.content directly into ToolMessage.content without filtering. This also affects thinking and redacted_thinking blocks (not just tool_use blocks covered in #239).

When a subagent uses ChatAnthropic with extended thinking enabled, the final AIMessage.content contains thinking blocks. These get copied into the ToolMessage, which the Anthropic API rejects:

400 invalid_request_error: messages.2.content.0.tool_result.content.0: Input tag 'thinking' found using 'type' does not match any of the expected tags: 'document', 'image', 'search_result', 'text', 'tool_reference'

PR #240 only filters tool_use blocks — thinking and redacted_thinking should also be filtered.

Versions: deepagents 1.7.6, @langchain/anthropic 1.3.17

Originally created by @antonnak on GitHub (Feb 23, 2026). Original GitHub issue: https://github.com/langchain-ai/deepagentsjs/issues/245 Related to #239 — `returnCommandWithStateUpdate()` passes `lastMessage.content` directly into `ToolMessage.content` without filtering. This also affects `thinking` and `redacted_thinking` blocks (not just `tool_use` blocks covered in #239). When a subagent uses `ChatAnthropic` with extended thinking enabled, the final `AIMessage.content` contains `thinking` blocks. These get copied into the `ToolMessage`, which the Anthropic API rejects: ``` 400 invalid_request_error: messages.2.content.0.tool_result.content.0: Input tag 'thinking' found using 'type' does not match any of the expected tags: 'document', 'image', 'search_result', 'text', 'tool_reference' ``` PR #240 only filters `tool_use` blocks — `thinking` and `redacted_thinking` should also be filtered. **Versions:** deepagents 1.7.6, @langchain/anthropic 1.3.17
yindo closed this issue 2026-06-05 17:21:12 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/deepagentsjs#239