From 40bf4aee99ba195971aa3fe4e43ca63319c0b8c1 Mon Sep 17 00:00:00 2001 From: Bastien Leblanc Date: Wed, 15 Apr 2026 08:48:58 +0100 Subject: [PATCH] fix(bedrock): add ainvoke override, endpoint_url mapping with guard Address Gemini review comments: - Override ainvoke for async content normalization - Map base_url to endpoint_url for custom Bedrock endpoints - Guard against non-Bedrock URLs (e.g. OpenAI default) being passed as endpoint_url, which caused 404 errors --- tradingagents/llm_clients/bedrock_client.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tradingagents/llm_clients/bedrock_client.py b/tradingagents/llm_clients/bedrock_client.py index 3250a431..d0810575 100644 --- a/tradingagents/llm_clients/bedrock_client.py +++ b/tradingagents/llm_clients/bedrock_client.py @@ -25,6 +25,9 @@ class NormalizedChatBedrockConverse(ChatBedrockConverse): def invoke(self, input, config=None, **kwargs): return normalize_content(super().invoke(input, config, **kwargs)) + async def ainvoke(self, input, config=None, **kwargs): + return normalize_content(await super().ainvoke(input, config, **kwargs)) + class BedrockClient(BaseLLMClient): """Client for Amazon Bedrock models via ChatBedrockConverse.""" @@ -38,6 +41,8 @@ class BedrockClient(BaseLLMClient): "model_id": self.model, "config": BotoConfig(read_timeout=300, retries={"max_attempts": 3}), } + if self.base_url and "openai.com" not in self.base_url: + llm_kwargs["endpoint_url"] = self.base_url for key in _PASSTHROUGH_KWARGS: if key in self.kwargs: llm_kwargs[key] = self.kwargs[key]