fix(bedrock): prevent runtime failure when toolConfig is undefined#166
Merged
asdek merged 1 commit intovxcontrol:feature/next_releasefrom Mar 4, 2026
Merged
Conversation
Contributor
|
hey @Priyanka-2725 thank you for the PR! |
30 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request: Fix AWS Bedrock Converse API
toolConfigValidationExceptionDescription of the Change
Problem
When using any model with the AWS Bedrock provider, all agent runs that involve tool calls fail on subsequent turns with:
The AWS Bedrock Converse API enforces a strict requirement: if any message in the request contains
toolUseortoolResultcontent blocks, the request must include atoolConfigfield — even when no new tools are being offered in the current turn. This is not a requirement imposed by other providers (OpenAI, Anthropic direct, etc.).The
CallExandCallWithToolsmethods in the Bedrock provider did not account for this. As a result, any multi-turn conversation where a tool was previously called would fail on all follow-up turns, making it impossible to complete any agentic task with the Bedrock provider.Solution
Added a
buildMinimalToolsFromChainhelper function inbackend/pkg/providers/bedrock/bedrock.gothat:llms.ToolCallandllms.ToolCallResponsecontent parts.llms.Toolplaceholder definitions (with an empty{"type":"object","properties":{}}parameter schema) for each unique tool name.These placeholder definitions are injected via
llms.WithToolsso the underlying library includestoolConfigin the Bedrock API request. Placeholder schemas are used intentionally — Bedrock only validates thattoolConfigis present, not that the schemas match historical usage.The fix is applied to both call paths that can hit this error:
CallEx: detects tool blocks in the chain and injects minimal definitions when no tools were explicitly provided for the current turn.CallWithTools: falls back to reconstructed minimal definitions when an emptytoolsslice is passed but the chain contains tool blocks.Closes #
Type of Change
Areas Affected
Testing and Verification
Test Configuration
Test Steps
toolUse/toolResultblocks to appear in the conversation history).ValidationException).Test Results
Unit tests added in
backend/pkg/providers/bedrock/bedrock_test.go—TestBuildMinimalToolsFromChain— covering all edge cases:nilchainnil(no tools injected)nilnilToolCallToolCallResponseToolCallandToolCallResponseToolCallwithnilFunctionCallniltype=object, emptypropertiesmapAll existing tests continue to pass.
Security Considerations
No security implications. The placeholder tool schemas sent to Bedrock contain no sensitive information — they exist solely to satisfy the AWS API's structural
toolConfigrequirement. No new dependencies are introduced.Performance Impact
Negligible.
buildMinimalToolsFromChainperforms a single O(n) linear scan over the conversation chain on each call, and only injects tools when tool-related content blocks are actually present. No caching or persistent state is involved.Documentation Updates
No documentation updates required. The fix is an internal implementation detail of the Bedrock provider with no user-facing configuration changes.
Deployment Notes
No new environment variables, configuration changes, database migrations, or deployment steps required. The fix is a drop-in change to the Bedrock provider implementation.
Checklist
Code Quality
go fmtandgo vet(for Go code)Security
Compatibility
Documentation
Additional Notes
The root cause is an AWS Bedrock Converse API constraint that is not enforced by other LLM providers. The fix is fully isolated to
backend/pkg/providers/bedrock/and has no effect on any other provider (OpenAI, Anthropic, Gemini, Ollama, etc.).Files changed:
backend/pkg/providers/bedrock/bedrock.go— addedbuildMinimalToolsFromChain, updatedCallExandCallWithToolsbackend/pkg/providers/bedrock/bedrock_test.go— addedTestBuildMinimalToolsFromChainwith 8 sub-tests