{"record":{"id":"ac94f7f93014a855","repo":"NousResearch/hermes-agent","slug":"httpx-is-required-for-entra-id-bearer-auth-on-micr","errorCode":null,"errorMessage":"httpx is required for Entra ID bearer auth on Microsoft Foundry Anthropic-style endpoints. It is normally a transitive dependency of the openai/anthropic SDKs.","messagePattern":"httpx is required for Entra ID bearer auth on Microsoft Foundry Anthropic-style endpoints\\. It is normally a transitive dependency of the openai/anthropic SDKs\\.","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"agent/azure_identity_adapter.py","lineNumber":517,"sourceCode":"    typically the result of :func:`build_token_provider`.\n\n    ``httpx_kwargs`` are forwarded verbatim to ``httpx.Client(...)`` so\n    callers can attach a ``timeout``, ``transport``, ``proxy``, etc.\n\n    Raises ``ImportError`` if ``httpx`` is not installed (it is a\n    transitive dependency of both ``openai`` and ``anthropic`` SDKs, so\n    in practice always available when this helper is reached).\n    \"\"\"\n    if not is_token_provider(token_provider):\n        raise ValueError(\n            \"build_bearer_http_client requires a zero-arg callable \"\n            \"token provider\"\n        )\n\n    try:\n        import httpx\n    except ImportError as exc:  # pragma: no cover — httpx ships with openai/anthropic\n        raise ImportError(\n            \"httpx is required for Entra ID bearer auth on Microsoft Foundry \"\n            \"Anthropic-style endpoints. It is normally a transitive \"\n            \"dependency of the openai/anthropic SDKs.\"\n        ) from exc\n\n    def _inject_bearer(request: \"httpx.Request\") -> None:\n        try:\n            token = materialize_bearer_for_http(token_provider)\n        except ValueError as exc:\n            # Token provider failed (chain exhausted, token service unreachable,\n            # az login expired, etc.). Strip any auth headers the SDK\n            # may have set — including our own placeholder sentinel\n            # ``entra-id-bearer-via-http-hook`` from\n            # ``_build_anthropic_client_with_bearer_hook`` — so the\n            # outbound request hits Azure with NO Authorization rather\n            # than with the placeholder. Azure returns a clean 401\n            # \"missing auth\" that is easier to diagnose than a 401\n            # against the sentinel string, and the sentinel never","sourceCodeStart":499,"sourceCodeEnd":535,"githubUrl":"https://github.com/NousResearch/hermes-agent/blob/c896c09c42910c584c4c7d2325b58c14713ea42c/agent/azure_identity_adapter.py#L499-L535","documentation":"build_bearer_http_client() needs httpx to construct the per-request Authorization-injecting client for Foundry Anthropic-style endpoints. httpx is expected as a transitive dependency of the openai/anthropic SDKs; its absence means the environment is unusually stripped (the code even marks the branch 'pragma: no cover').","triggerScenarios":"Selecting Entra bearer auth on a Foundry Anthropic endpoint in an environment where httpx was never installed alongside the SDKs (agent/azure_identity_adapter.py:517).","commonSituations":"Minimal dependency set where openai/anthropic were vendored without httpx; dependency pruning tools (pip-autoremove) removed it; corrupted venv.","solutions":["pip install httpx","Reinstall the openai/anthropic SDK so transitives are restored: pip install --force-reinstall anthropic","Recreate the venv from the project's lockfile (uv sync / pip install -e '.')."],"exampleFix":"pip install httpx","handlingStrategy":"validation","validationCode":"import importlib.util\nassert importlib.util.find_spec(\"httpx\") is not None, \"httpx missing — pip install httpx\"","typeGuard":null,"tryCatchPattern":"try:\n    client = build_bearer_http_client(provider)\nexcept ImportError as e:\n    if \"httpx is required\" in str(e):\n        run(\"pip install httpx\"); client = build_bearer_http_client(provider)","preventionTips":["Do not prune transitive dependencies of the openai/anthropic SDKs.","Include httpx in Foundry deployment requirement lists."],"tags":["azure","httpx","dependencies","import"],"backgroundTag":null,"analyzedSha":"c896c09c42910c584c4c7d2325b58c14713ea42c","analyzedAt":"2026-08-14T17:18:01.089Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}