{"record":{"id":"8c145a346d287b09","repo":"NousResearch/hermes-agent","slug":"the-anthropic-package-is-required-for-the-anthro","errorCode":null,"errorMessage":"The 'anthropic' package is required for the Anthropic provider. Install it with: pip install 'anthropic>=0.39.0'","messagePattern":"The 'anthropic' package is required for the Anthropic provider\\. Install it with: pip install 'anthropic>=0\\.39\\.0'","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"agent/anthropic_adapter.py","lineNumber":825,"sourceCode":"      header. The SDK never sees the callable directly.\n\n    If *timeout* is provided it overrides the default 900s read timeout.  The\n    connect timeout stays at 10s.  Callers pass this from the per-provider /\n    per-model ``request_timeout_seconds`` config so Anthropic-native and\n    Anthropic-compatible providers respect the same knob as OpenAI-wire\n    providers.\n\n    ``drop_context_1m_beta=True`` strips ``context-1m-2025-08-07`` from the\n    client-level ``anthropic-beta`` header. Used by the reactive OAuth retry\n    path in ``run_agent.py`` when a subscription rejects the beta; leave at\n    its default on fresh clients so 1M-capable subscriptions keep the\n    capability.\n\n    Returns an anthropic.Anthropic instance.\n    \"\"\"\n    _anthropic_sdk = _get_anthropic_sdk()\n    if _anthropic_sdk is None:\n        raise ImportError(\n            \"The 'anthropic' package is required for the Anthropic provider. \"\n            \"Install it with: pip install 'anthropic>=0.39.0'\"\n        )\n\n    # Callable api_key → Entra ID bearer provider path. Delegated to a\n    # helper so the existing static-key code below stays unchanged.\n    if callable(api_key) and not isinstance(api_key, str):\n        return _build_anthropic_client_with_bearer_hook(\n            api_key, base_url, timeout,\n            drop_context_1m_beta=drop_context_1m_beta,\n        )\n\n    normalize_proxy_env_vars()\n\n    from httpx import Timeout\n\n    normalized_base_url = _normalize_base_url_text(base_url)\n    if normalized_base_url:","sourceCodeStart":807,"sourceCodeEnd":843,"githubUrl":"https://github.com/NousResearch/hermes-agent/blob/c896c09c42910c584c4c7d2325b58c14713ea42c/agent/anthropic_adapter.py#L807-L843","documentation":"ImportError raised by the main Anthropic client builder: _get_anthropic_sdk() is None, so the optional 'anthropic' dependency is missing from the runtime environment. Every path that builds a native Anthropic client — static API key or the callable Entra bearer variant — hits this guard before any SDK object is constructed.","triggerScenarios":"Selecting the anthropic provider (or any code path that calls this builder) on an environment where `import anthropic` fails: package not installed, broken install, or interpreter mismatch.","commonSituations":"Fresh checkout without optional extras installed; venv rebuilt; dependency conflict removed anthropic; running under system Python while the package lives in the project venv.","solutions":["pip install 'anthropic>=0.39.0' into the environment hermes runs in","Confirm with: python -c \"import anthropic; print(anthropic.__version__)\"","Recreate/sync the venv (uv sync) if the install is broken"],"exampleFix":"# before: provider 'anthropic' selected, ImportError raised\n# after\npip install 'anthropic>=0.39.0'","handlingStrategy":"validation","validationCode":"def anthropic_sdk_available() -> bool:\n    try:\n        import anthropic  # noqa: F401\n        return True\n    except ImportError:\n        return False\n\nif provider == \"anthropic\" and not anthropic_sdk_available():\n    raise SystemExit(\"pip install 'anthropic>=0.39.0' before selecting the anthropic provider\")","typeGuard":null,"tryCatchPattern":"try:\n    client = build_anthropic_client(api_key=key, base_url=url)\nexcept ImportError as e:\n    if \"anthropic\" in str(e):\n        install_and_prompt(\"pip install 'anthropic>=0.39.0'\")\n    raise","preventionTips":["Declare the anthropic dependency when the anthropic provider is part of your setup","After recreating a venv, re-run the dependency sync before launching hermes","Prefer the setup wizard (`hermes setup`) which checks optional deps when a provider is chosen"],"tags":["anthropic","dependency","provider","import"],"backgroundTag":null,"analyzedSha":"c896c09c42910c584c4c7d2325b58c14713ea42c","analyzedAt":"2026-08-14T17:18:01.089Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}