fix(amazon-bedrock): prevent double-wrapping of tools_cachepoint_config in _format_tools#3199
Merged
anakin87 merged 2 commits intodeepset-ai:mainfrom Apr 22, 2026
Conversation
…ig in _format_tools
AmazonBedrockChatGenerator.__init__ pre-formats tools_cachepoint_config
via _validate_and_format_cache_point, producing {"cachePoint": {...}}.
_format_tools then wrapped it a second time, sending
{"cachePoint": {"cachePoint": {...}}} to Bedrock which rejected it with
ParamValidationError.
Fix: append tools_cachepoint_config as-is in _format_tools since callers
always pass the already-formatted value.
Also updates the existing test to pass the pre-formatted value (matching
real usage) and adds a regression test that chains both functions.
Fixes deepset-ai#3181
anakin87
requested changes
Apr 22, 2026
Member
anakin87
left a comment
There was a problem hiding this comment.
Thank you!
I also tested it locally and works well.
Just a minor format issue to solve...
Comment on lines
+110
to
+112
| from haystack_integrations.components.generators.amazon_bedrock.chat.utils import ( | ||
| _validate_and_format_cache_point, | ||
| ) |
Member
There was a problem hiding this comment.
let's move the import at the top of the file
Contributor
Coverage report (amazon_bedrock)Click to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||
2 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.
Summary
Fixes #3181
AmazonBedrockChatGenerator.__init__pre-formatstools_cachepoint_configvia_validate_and_format_cache_point, converting the user-supplied{"type": "default"}to{"cachePoint": {"type": "default"}}and storing it asself.tools_cachepoint_config._format_toolsthen received this already-formatted value and wrapped it a second time:Fix: append
tools_cachepoint_configas-is since callers always pass the pre-formatted value:Changes
utils.py: remove the extra{"cachePoint": ...}wrapper in_format_toolstest_chat_generator_utils.py: update existingtest_format_toolsto pass the pre-formatted value (matching real call path from__init__); addtest_format_tools_does_not_double_wrap_cachepointregression test that chains_validate_and_format_cache_point→_format_toolsand asserts a single non-nestedcachePointentryHow to verify (no API key needed)