@@ -67,7 +67,7 @@ def tools():
6767
6868class TestAmazonBedrockChatGeneratorUtils :
6969 def test_format_tools (self , tools ):
70- formatted_tool = _format_tools (tools , tools_cachepoint_config = {"type" : "default" })
70+ formatted_tool = _format_tools (tools , tools_cachepoint_config = {"cachePoint" : { " type" : "default" } })
7171 assert formatted_tool == {
7272 "tools" : [
7373 {
@@ -103,6 +103,19 @@ def test_format_tools(self, tools):
103103 ],
104104 }
105105
106+ def test_format_tools_does_not_double_wrap_cachepoint (self , tools ):
107+ # Regression test for https://github.com/deepset-ai/haystack-core-integrations/issues/3181
108+ # __init__ pre-formats tools_cachepoint_config via _validate_and_format_cache_point,
109+ # so _format_tools must append it as-is without an extra cachePoint wrapper.
110+
111+ formatted_config = _validate_and_format_cache_point ({"type" : "default" })
112+ assert formatted_config == {"cachePoint" : {"type" : "default" }}
113+
114+ result = _format_tools (tools , tools_cachepoint_config = formatted_config )
115+ cache_entries = [e for e in result ["tools" ] if "cachePoint" in e ]
116+ assert len (cache_entries ) == 1
117+ assert cache_entries [0 ] == {"cachePoint" : {"type" : "default" }}
118+
106119 def test_convert_file_content_to_bedrock_format_no_mime_type (self ):
107120 file_content = FileContent (
108121 base64_data = base64 .b64encode (b"This is a test file content." ),
0 commit comments