From 6b0993d94cf8626f4f67407dcc3db85ca68bcac0 Mon Sep 17 00:00:00 2001 From: SyedShahmeerAli12 Date: Wed, 22 Apr 2026 00:31:13 +0500 Subject: [PATCH] fix: remove double-wrapping of tools_cachepoint_config in _format_tools `__init__` already calls `_validate_and_format_cache_point` which wraps the user-supplied `{"type": "default"}` into `{"cachePoint": {"type": "default"}}`. `_format_tools` was then wrapping it a second time, producing a nested `{"cachePoint": {"cachePoint": {...}}}` that Bedrock rejects with ParamValidationError. Fixes #3181 --- .../components/generators/amazon_bedrock/chat/utils.py | 2 +- integrations/amazon_bedrock/tests/test_chat_generator_utils.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/integrations/amazon_bedrock/src/haystack_integrations/components/generators/amazon_bedrock/chat/utils.py b/integrations/amazon_bedrock/src/haystack_integrations/components/generators/amazon_bedrock/chat/utils.py index f6a5ce2251..d436faf9e8 100644 --- a/integrations/amazon_bedrock/src/haystack_integrations/components/generators/amazon_bedrock/chat/utils.py +++ b/integrations/amazon_bedrock/src/haystack_integrations/components/generators/amazon_bedrock/chat/utils.py @@ -93,7 +93,7 @@ def _format_tools( ) if tools_cachepoint_config: - tool_specs.append({"cachePoint": tools_cachepoint_config}) + tool_specs.append(tools_cachepoint_config) return {"tools": tool_specs} diff --git a/integrations/amazon_bedrock/tests/test_chat_generator_utils.py b/integrations/amazon_bedrock/tests/test_chat_generator_utils.py index b9f1ba6cd0..a3f947f718 100644 --- a/integrations/amazon_bedrock/tests/test_chat_generator_utils.py +++ b/integrations/amazon_bedrock/tests/test_chat_generator_utils.py @@ -67,7 +67,7 @@ def tools(): class TestAmazonBedrockChatGeneratorUtils: def test_format_tools(self, tools): - formatted_tool = _format_tools(tools, tools_cachepoint_config={"type": "default"}) + formatted_tool = _format_tools(tools, tools_cachepoint_config={"cachePoint": {"type": "default"}}) assert formatted_tool == { "tools": [ {