{"record":{"id":"4285a3fdb35dbc26","repo":"NousResearch/hermes-agent","slug":"anthropic-anthropicbedrock-not-available-upgrade","errorCode":null,"errorMessage":"anthropic.AnthropicBedrock not available. Upgrade with: pip install 'anthropic>=0.39.0'","messagePattern":"anthropic\\.AnthropicBedrock not available\\. Upgrade with: pip install 'anthropic>=0\\.39\\.0'","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"agent/anthropic_adapter.py","lineNumber":968,"sourceCode":"    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    )\n\n\ndef _read_claude_code_credentials_from_keychain() -> Optional[Dict[str, Any]]:\n    \"\"\"Read Claude Code OAuth credentials from the macOS Keychain.\n","sourceCodeStart":950,"sourceCodeEnd":986,"githubUrl":"https://github.com/NousResearch/hermes-agent/blob/c896c09c42910c584c4c7d2325b58c14713ea42c/agent/anthropic_adapter.py#L950-L986","documentation":"Distinct from a missing package: `anthropic` IS importable but exposes no AnthropicBedrock attribute, meaning the installed version predates the Bedrock client class. The remediation is an upgrade, not an install — the version floor (>=0.39.0) is where AnthropicBedrock with the required constructor surface exists.","triggerScenarios":"Bedrock provider client construction on an environment with an old anthropic package: `import anthropic` succeeds but hasattr(anthropic, 'AnthropicBedrock') is False.","commonSituations":"Long-lived venv with anthropic pinned low; system package shadowing the venv's newer copy; dependency resolver kept an old version to satisfy another constraint.","solutions":["Upgrade: pip install --upgrade 'anthropic>=0.39.0'","Verify the class exists: python -c \"from anthropic import AnthropicBedrock\"","If a conflicting pin holds it back, inspect pip's resolution and relax the conflicting constraint"],"exampleFix":"# before: anthropic 0.30.x installed, AnthropicBedrock missing\n# after\npip install --upgrade 'anthropic>=0.39.0'\npython -c \"from anthropic import AnthropicBedrock; print('ok')\"","handlingStrategy":"validation","validationCode":"import anthropic\nfrom packaging.version import parse\n\ndef bedrock_client_available() -> tuple[bool, str]:\n    if not hasattr(anthropic, \"AnthropicBedrock\"):\n        return False, f\"anthropic {anthropic.__version__} lacks AnthropicBedrock; upgrade to >=0.39.0\"\n    return True, \"\"\n\nok, why = bedrock_client_available()\nif not ok:\n    raise SystemExit(why)","typeGuard":"def has_anthropic_bedrock(sdk) -> bool:\n    \"\"\"True when the imported anthropic SDK exposes AnthropicBedrock.\"\"\"\n    return hasattr(sdk, \"AnthropicBedrock\")","tryCatchPattern":"try:\n    client = build_bedrock_client(region=region)\nexcept ImportError as e:\n    if \"AnthropicBedrock not available\" in str(e):\n        upgrade_and_restart(\"pip install --upgrade 'anthropic>=0.39.0'\")\n    else:\n        raise","preventionTips":["Pin anthropic with a lower bound >=0.39.0 so old versions can't be resolved","After dependency updates, assert `from anthropic import AnthropicBedrock` succeeds in CI","Watch for system-site-packages shadowing the venv's newer anthropic"],"tags":["anthropic","bedrock","version","dependency"],"backgroundTag":null,"analyzedSha":"c896c09c42910c584c4c7d2325b58c14713ea42c","analyzedAt":"2026-08-14T17:18:01.089Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}