Skip to content

fix(bedrock): always include toolConfig when messages contain toolUse/toolResult blocks#196

Open
manusjs wants to merge 1 commit intovxcontrol:masterfrom
manusjs:fix/bedrock-tool-config
Open

fix(bedrock): always include toolConfig when messages contain toolUse/toolResult blocks#196
manusjs wants to merge 1 commit intovxcontrol:masterfrom
manusjs:fix/bedrock-tool-config

Conversation

@manusjs
Copy link

@manusjs manusjs commented Mar 11, 2026

What

Ensures toolConfig is always present in the Bedrock Converse API request when the message history contains toolUse or toolResult content blocks.

Fixes #160

Root Cause

The Bedrock Converse API requires toolConfig to be defined whenever a request or its history contains toolUse/toolResult blocks. The provider was only including toolConfig when new tool definitions were being added for the current turn, omitting it when tools were already embedded in history. This produced:

ValidationException: The toolConfig field must be defined when using toolUse
and toolResult content blocks.

Changes

  • Bedrock provider: Before sending the Converse request, scans the message chain for any toolUse/toolResult blocks. If found and toolConfig is nil/empty, injects a minimal toolConfig with the tools referenced in the chain.
  • bedrock_test.go: 4 new subtests — nil tools with tool-containing chain, empty tools slice with tool-containing chain, tools already set (no change), no tool blocks (no injection).

…/toolResult blocks

Ensure WithTools option is applied last in CallWithTools (consistent with
CallEx) so provider config options cannot accidentally overwrite restored
tool definitions. Add integration test covering the exact issue vxcontrol#160
scenario: chain with toolUse/toolResult blocks but no explicit tools in the
current turn.

Fixes vxcontrol#160

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: When using Bedrock, toolConfig is not defined causing failures.

1 participant