{"record":{"id":"b10ccf356273346f","repo":"TauricResearch/TradingAgents","slug":"aws-bedrock-support-requires-the-optional-langcha","errorCode":null,"errorMessage":"AWS Bedrock support requires the optional 'langchain-aws' dependency. Install it with: pip install \"tradingagents[bedrock]\"","messagePattern":"AWS Bedrock support requires the optional 'langchain-aws' dependency\\. Install it with: pip install \"tradingagents\\[bedrock\\]\"","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"tradingagents/llm_clients/bedrock_client.py","lineNumber":26,"sourceCode":"_DEFAULT_REGION = \"us-west-2\"\n_BEDROCK_CLASS = None\n\n\ndef _bedrock_class():\n    \"\"\"Lazily import langchain-aws (the optional ``[bedrock]`` extra) and return a\n    ChatBedrockConverse subclass with normalized content output.\n\n    Imported on demand so the optional dependency (and boto3) isn't required by\n    the rest of the package; cached after the first call.\n    \"\"\"\n    global _BEDROCK_CLASS\n    if _BEDROCK_CLASS is not None:\n        return _BEDROCK_CLASS\n\n    try:\n        from langchain_aws import ChatBedrockConverse\n    except ImportError as exc:\n        raise ImportError(\n            \"AWS Bedrock support requires the optional 'langchain-aws' dependency. \"\n            'Install it with: pip install \"tradingagents[bedrock]\"'\n        ) from exc\n\n    class NormalizedChatBedrockConverse(ChatBedrockConverse):\n        \"\"\"ChatBedrockConverse with normalized (string) content output.\"\"\"\n\n        def invoke(self, input, config=None, **kwargs):\n            return normalize_content(super().invoke(input, config, **kwargs))\n\n    _BEDROCK_CLASS = NormalizedChatBedrockConverse\n    return _BEDROCK_CLASS\n\n\nclass BedrockClient(BaseLLMClient):\n    \"\"\"Client for Amazon Bedrock via the Converse API (langchain-aws).\n\n    Authentication is either a Bedrock API key (bearer token) via","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/TauricResearch/TradingAgents/blob/a33fd4c0f134485a43553a2c23a63cb14adbd88f/tradingagents/llm_clients/bedrock_client.py#L8-L44","documentation":"ImportError raised by the Bedrock client factory (tradingagents/llm_clients/bedrock_client.py) when langchain_aws cannot be imported. AWS Bedrock support ships as an optional dependency; the lazy import keeps boto3/langchain-aws out of the base install, and the error names the exact extra to install.","triggerScenarios":"Configuring the LLM provider as 'bedrock' (which routes through factory.py to BedrockClient) without having installed the optional extra. The `from langchain_aws import ChatBedrockConverse` inside _get_bedrock_class raises ImportError, which is re-raised with install instructions.","commonSituations":"Deploying to environments where only the base package was installed; lockfiles that dropped langchain-aws after a refactor; assuming boto3 alone is sufficient.","solutions":["Install the extra: pip install \"tradingagents[bedrock]\" (or pip install langchain-aws).","Rebuild your Docker image / lockfile so langchain-aws and boto3 are pinned.","If Bedrock is not intended, switch the provider config to an installed one (openai/azure/openai-compatible)."],"exampleFix":"# before\npip install tradingagents\nTradingAgentsGraph(config with provider='bedrock')  # ImportError\n\n# after\npip install \"tradingagents[bedrock]\"\nTradingAgentsGraph(config with provider='bedrock')","handlingStrategy":"validation","validationCode":"def bedrock_available() -> bool:\n    try:\n        import langchain_aws  # noqa: F401\n        return True\n    except ImportError:\n        return False\n\nif provider == 'bedrock' and not bedrock_available():\n    raise SystemExit('install first: pip install \"tradingagents[bedrock]\"')","typeGuard":null,"tryCatchPattern":"try:\n    client = BedrockClient(model, base_url)\nexcept ImportError as e:\n    raise SystemExit(f'missing optional dependency: {e}')  # fail deployment with install hint","preventionTips":["Pin extras in requirements: tradingagents[bedrock] when provider is bedrock.","Add an import smoke test for the provider you configure in CI/Docker build.","Keep boto3 credentials (AWS_REGION etc.) configured alongside the dependency."],"tags":["dependency","bedrock","aws","installation"],"backgroundTag":null,"analyzedSha":"a33fd4c0f134485a43553a2c23a63cb14adbd88f","analyzedAt":"2026-08-14T19:45:16.920Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}