{"record":{"id":"06919a98e3666d45","repo":"NousResearch/hermes-agent","slug":"the-anthropic-package-is-required-for-the-bedroc","errorCode":null,"errorMessage":"The 'anthropic' package is required for the Bedrock provider. Install it with: pip install 'anthropic>=0.39.0'","messagePattern":"The 'anthropic' package is required for the Bedrock provider\\. Install it with: pip install 'anthropic>=0\\.39\\.0'","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"agent/anthropic_adapter.py","lineNumber":963,"sourceCode":"def build_anthropic_bedrock_client(region: str):\n    \"\"\"Create an AnthropicBedrock client for Bedrock Claude models.\n\n    Uses the Anthropic SDK's native Bedrock adapter, which provides full\n    Claude feature parity: prompt caching, thinking budgets, adaptive\n    thinking, fast mode — features not available via the Converse API.\n\n    Attaches the common Anthropic beta headers as client-level defaults so\n    that Bedrock-hosted Claude models get the same enhanced features as\n    native Anthropic. The ``context-1m-2025-08-07`` beta in particular\n    unlocks the 1M context window for Opus 4.6/4.7 on Bedrock — without\n    it, Bedrock caps these models at 200K even though the Anthropic API\n    serves them with 1M natively.\n\n    Auth uses the boto3 default credential chain (IAM roles, SSO, env vars).\n    \"\"\"\n    _anthropic_sdk = _get_anthropic_sdk()\n    if _anthropic_sdk is None:\n        raise ImportError(\n            \"The 'anthropic' package is required for the Bedrock provider. \"\n            \"Install it with: pip install 'anthropic>=0.39.0'\"\n        )\n    if not hasattr(_anthropic_sdk, \"AnthropicBedrock\"):\n        raise ImportError(\n            \"anthropic.AnthropicBedrock not available. \"\n            \"Upgrade with: pip install 'anthropic>=0.39.0'\"\n        )\n    from httpx import Timeout\n\n    return _anthropic_sdk.AnthropicBedrock(\n        aws_region=region,\n        timeout=Timeout(timeout=900.0, connect=10.0),\n        # Delegate retry to hermes's outer loop (honors Retry-After); the SDK\n        # default max_retries=2 ignores it and double-retries. (#26293)\n        max_retries=0,\n        default_headers={\"anthropic-beta\": \",\".join([*_COMMON_BETAS, _CONTEXT_1M_BETA])},\n    )","sourceCodeStart":945,"sourceCodeEnd":981,"githubUrl":"https://github.com/NousResearch/hermes-agent/blob/c896c09c42910c584c4c7d2325b58c14713ea42c/agent/anthropic_adapter.py#L945-L981","documentation":"ImportError raised when building the Bedrock client: _get_anthropic_sdk() returned None, i.e. the optional 'anthropic' package is not installed. Bedrock-hosted Claude requires the SDK client (AnthropicBedrock) with boto3's default credential chain, hence the explicit install instruction.","triggerScenarios":"Selecting the bedrock provider and constructing its client on an environment where `import anthropic` fails (absent or broken install).","commonSituations":"Bedrock configured on a machine where only boto3 was installed; slim/hermetic install; venv recreated without the anthropic extra.","solutions":["pip install 'anthropic>=0.39.0' in hermes' environment","Verify importability: python -c \"import anthropic\"","Ensure boto3 credentials (IAM role/SSO/env) are also configured for the Bedrock path"],"exampleFix":"# before: bedrock provider selected, ImportError raised\n# after\npip install 'anthropic>=0.39.0'","handlingStrategy":"validation","validationCode":"def bedrock_ready() -> bool:\n    try:\n        import anthropic\n    except ImportError:\n        return False\n    return hasattr(anthropic, \"AnthropicBedrock\")\n\nif provider == \"bedrock\" and not bedrock_ready():\n    raise SystemExit(\"pip install 'anthropic>=0.39.0' before using the bedrock provider\")","typeGuard":null,"tryCatchPattern":"try:\n    client = build_bedrock_client(region=region)\nexcept ImportError as e:\n    if \"Bedrock\" in str(e) or \"anthropic\" in str(e):\n        run_or_suggest(\"pip install 'anthropic>=0.39.0'\")\n    raise","preventionTips":["Install anthropic (and configure boto3 credentials) before selecting the bedrock provider","Include optional provider deps in the machine provisioning script for AWS-based setups","Smoke-test Bedrock client construction in deployment checks"],"tags":["anthropic","bedrock","dependency","aws"],"backgroundTag":null,"analyzedSha":"c896c09c42910c584c4c7d2325b58c14713ea42c","analyzedAt":"2026-08-14T17:18:01.089Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}