# Task: fix a credential-leak bug in this code This directory is a slice of the `hermes-agent` codebase (the modules involved in building the Anthropic-protocol HTTP client). There is a security bug in it, described below. Fix it by editing the source. A regression test is included. ## The bug When a custom provider is configured with `api_mode: anthropic` and its own API key, Hermes sends **two** credentials to the provider's endpoint: - `x-api-key: ` — correct - `Authorization: Bearer ` — **leak** Any `ANTHROPIC_AUTH_TOKEN` present in the shell — commonly pointing at a completely unrelated account or proxy — is transmitted to the third-party endpoint on every request. This is both a security leak (one vendor's credential sent to another vendor's server) and a functional failure (the receiving endpoint rejects the unexpected token). ## Root cause `agent/anthropic_adapter.py::build_anthropic_client` passes `api_key=` but never suppresses the Anthropic SDK's environment fallback. The SDK auto-reads `ANTHROPIC_AUTH_TOKEN` when `auth_token` is not set and attaches it as a `Bearer` header **in addition to** `x-api-key`. Note: passing `auth_token=None` does **not** fix it — the SDK treats `None` as "fall back to env". The env-sourced token must be actively suppressed on the client. ## What to do 1. Edit the source in this directory to stop the foreign credential from being sent to a third-party endpoint, while keeping the provider's own `x-api-key` intact. Official Anthropic OAuth flows (which set `auth_token` explicitly) must keep working. 2. **Do not modify `regression_test.py`.** It is the acceptance criterion. 3. Verify with: `./run_test.sh` — it must print `OK`. The test lives in `regression_test.py` and is run with `PYTHONPATH=. python regression_test.py`.