Bedrock Plugin: Claude Thinking Chain Fails with Tool Calls - ValidationException #627

Closed
opened 2026-02-16 10:19:57 -05:00 by yindo · 4 comments
Owner

Originally created by @qiqizjl on GitHub (Sep 5, 2025).

Self Checks

  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues Dify issues & Dify Official Plugins, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

2.0.0-beta

Plugin version

0.0.35

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

  1. Configure a Claude model in the Bedrock plugin with extended thinking enabled
  2. Set up a conversation scenario that involves tool calls
  3. Send an initial message that triggers the model to use tools
  4. After receiving the tool call response, send a follow-up message
  5. The plugin will fail when attempting to send the next message to AWS Bedrock
Image

✔️ Error log

[bedrock] Error: req_id: 6c47fd831a PluginInvokeError: {"args":{"description":"[models] Error: Failed to invoke inference profile global.anthropic.claude-sonnet-4-20250514-v1:0: ValidationException: The model returned the following errors: messages.1.content.0.type: Expected `thinking` or `redacted_thinking`, but found `tool_use`. When `thinking` is enabled, a final `assistant` message must start with a thinking block (preceeding the lastmost set of `tool_use` and `tool_result` blocks). We recommend you include thinking blocks from previous turns. To avoid this requirement, disable `thinking`. Please consult our documentation at https://docs.anthropic.com/en/docs/build-with-claude/extended-thinking"},"error_type":"InvokeError","message":"[models] Error: Failed to invoke inference profile global.anthropic.claude-sonnet-4-20250514-v1:0: ValidationException: The model returned the following errors: messages.1.content.0.type: Expected `thinking` or `redacted_thinking`, but found `tool_use`. When `thinking` is enabled, a final `assistant` message must start with a thinking block (preceeding the lastmost set of `tool_use` and `tool_result` blocks). We recommend you include thinking blocks from previous turns. To avoid this requirement, disable `thinking`. Please consult our documentation at https://docs.anthropic.com/en/docs/build-with-claude/extended-thinking"}
Originally created by @qiqizjl on GitHub (Sep 5, 2025). ### Self Checks - [x] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [x] I have searched for existing issues [Dify issues](https://github.com/langgenius/dify/issues) & [Dify Official Plugins](https://github.com/langgenius/dify-official-plugins/issues), including closed ones. - [x] I confirm that I am using English to submit this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [x] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [x] Please do not modify this template :) and fill in all the required fields. ### Dify version 2.0.0-beta ### Plugin version 0.0.35 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce 1. Configure a Claude model in the Bedrock plugin with extended thinking enabled 2. Set up a conversation scenario that involves tool calls 3. Send an initial message that triggers the model to use tools 4. After receiving the tool call response, send a follow-up message 5. The plugin will fail when attempting to send the next message to AWS Bedrock <img width="3024" height="1528" alt="Image" src="https://github.com/user-attachments/assets/e30ee94c-458c-4b26-afd5-42730be62b1c" /> ### ✔️ Error log ``` [bedrock] Error: req_id: 6c47fd831a PluginInvokeError: {"args":{"description":"[models] Error: Failed to invoke inference profile global.anthropic.claude-sonnet-4-20250514-v1:0: ValidationException: The model returned the following errors: messages.1.content.0.type: Expected `thinking` or `redacted_thinking`, but found `tool_use`. When `thinking` is enabled, a final `assistant` message must start with a thinking block (preceeding the lastmost set of `tool_use` and `tool_result` blocks). We recommend you include thinking blocks from previous turns. To avoid this requirement, disable `thinking`. Please consult our documentation at https://docs.anthropic.com/en/docs/build-with-claude/extended-thinking"},"error_type":"InvokeError","message":"[models] Error: Failed to invoke inference profile global.anthropic.claude-sonnet-4-20250514-v1:0: ValidationException: The model returned the following errors: messages.1.content.0.type: Expected `thinking` or `redacted_thinking`, but found `tool_use`. When `thinking` is enabled, a final `assistant` message must start with a thinking block (preceeding the lastmost set of `tool_use` and `tool_result` blocks). We recommend you include thinking blocks from previous turns. To avoid this requirement, disable `thinking`. Please consult our documentation at https://docs.anthropic.com/en/docs/build-with-claude/extended-thinking"} ```
yindo added the bug label 2026-02-16 10:19:57 -05:00
yindo closed this issue 2026-02-16 10:19:57 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Sep 5, 2025):

This error happens because the Bedrock plugin doesn't prepend a thinking (or redacted_thinking) block before tool_use blocks in the assistant's message when extended thinking is enabled, which is required by Anthropic Claude's API. As a result, Claude returns a ValidationException when it encounters a message that starts with tool_use instead of thinking in this mode. This is a known issue and has been reported by other users as well (example).

Currently, there are two practical workarounds:

  1. Disable extended thinking for Claude in your Bedrock plugin configuration to avoid the strict message structure requirement.
  2. Modify the plugin code to ensure that when extended thinking is enabled and tool calls are present, the outgoing assistant message always starts with a thinking block before any tool_use or tool_result blocks. This would require changes in how the plugin constructs messages (details in code).

If you need to keep extended thinking enabled, you’ll need to patch the plugin to enforce this message structure. Otherwise, disabling extended thinking is the quickest way to resolve the error for now.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Join Discord Share on X

@dosubot[bot] commented on GitHub (Sep 5, 2025): <!-- Answer --> This error happens because the Bedrock plugin doesn't prepend a `thinking` (or `redacted_thinking`) block before `tool_use` blocks in the assistant's message when extended thinking is enabled, which is required by Anthropic Claude's API. As a result, Claude returns a ValidationException when it encounters a message that starts with `tool_use` instead of `thinking` in this mode. This is a known issue and has been reported by other users as well ([example](https://github.com/langgenius/dify-official-plugins/issues/564)). Currently, there are two practical workarounds: 1. **Disable extended thinking** for Claude in your Bedrock plugin configuration to avoid the strict message structure requirement. 2. **Modify the plugin code** to ensure that when extended thinking is enabled and tool calls are present, the outgoing assistant message always starts with a `thinking` block before any `tool_use` or `tool_result` blocks. This would require changes in how the plugin constructs messages ([details in code](https://github.com/langgenius/dify-official-plugins/blob/205d2fb694c9cda6324c0fc66c9c20c05f59b2ae/models/bedrock/models/llm/llm.py)). If you need to keep extended thinking enabled, you’ll need to patch the plugin to enforce this message structure. Otherwise, disabling extended thinking is the quickest way to resolve the error for now. <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/52fd04da-a056-4928-8524-343285229c88?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/52fd04da-a056-4928-8524-343285229c88?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/52fd04da-a056-4928-8524-343285229c88?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/52fd04da-a056-4928-8524-343285229c88?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/52fd04da-a056-4928-8524-343285229c88?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/52fd04da-a056-4928-8524-343285229c88?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/52fd04da-a056-4928-8524-343285229c88?feedback_type=other)</sup>&nbsp;&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify-official-plugins/issues/1672)
Author
Owner

@qiqizjl commented on GitHub (Sep 26, 2025):

Is this a bug? Is there any plan to fix it?

@qiqizjl commented on GitHub (Sep 26, 2025): Is this a bug? Is there any plan to fix it?
Author
Owner

@dosubot[bot] commented on GitHub (Sep 26, 2025):

@crazywoola The user qiqizjl has indicated that the issue marked stale and closed is still relevant and is asking if it is a bug and whether there are plans to fix it. Could you please assist?

@dosubot[bot] commented on GitHub (Sep 26, 2025): @crazywoola The user qiqizjl has indicated that the issue marked stale and closed is still relevant and is asking if it is a bug and whether there are plans to fix it. Could you please assist?
Author
Owner

@chrisesposito92 commented on GitHub (Nov 19, 2025):

i am running into the same issue. it's hard to find any models that actually do work in the Agent nodes

@chrisesposito92 commented on GitHub (Nov 19, 2025): i am running into the same issue. it's hard to find any models that actually do work in the Agent nodes
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify-official-plugins#627