Skip to content

fix(agent): unpin anthropic to 0.112.0 so Bedrock Claude works with bearer-token auth - #54431

Open
krystiancharubin wants to merge 1 commit into
NousResearch:mainfrom
krystiancharubin:fix/anthropic-bedrock-bearer-token
Open

fix(agent): unpin anthropic to 0.112.0 so Bedrock Claude works with bearer-token auth#54431
krystiancharubin wants to merge 1 commit into
NousResearch:mainfrom
krystiancharubin:fix/anthropic-bedrock-bearer-token

Conversation

@krystiancharubin

Copy link
Copy Markdown

What & why

Both the anthropic extra in pyproject.toml and tools/lazy_deps.py pin anthropic==0.87.0. On AWS Bedrock, Claude models are routed through the AnthropicBedrock SDK client (agent/anthropic_adapter.build_anthropic_bedrock_client) for full feature parity (prompt caching, thinking budgets, 1M-context beta). In 0.87.0 that client only authenticates via SigV4, so a user whose only credential is an Amazon Bedrock API key (AWS_BEARER_TOKEN_BEDROCK) hits:

API call failed after 3 retries: could not resolve credentials from session

…even though:

  • hermes doctor reports AWS Bedrock ✓ (its probe uses the bearer token directly), and
  • non-Claude Bedrock models (Amazon Nova, OpenAI gpt-oss, DeepSeek, Llama…) work fine, because they route through the boto3 Converse API, which honors AWS_BEARER_TOKEN_BEDROCK.

So today Bedrock-with-an-API-key works for every model family except Claude — the one most users select first.

Root cause / fix: AWS bearer-token auth for AnthropicBedrock was added in anthropic 0.88.0 (anthropics/anthropic-sdk-python#1623). The client now reads AWS_BEARER_TOKEN_BEDROCK and sends Authorization: Bearer <token>, falling back to SigV4 only when no api_key resolves. Bumping the pin to 0.112.0 makes Claude-on-Bedrock work with just the bearer token on the full-feature path — no routing/logic change required.

Security note (why the bump is safe)

The exact ==0.87.0 pin was introduced for CVE-2026-34450 (memory-tool world-readable files) and CVE-2026-34452 (async memory-tool symlink TOCTOU). Both affect >=0.86.0,<0.87.0 and were fixed in 0.87.0; the official guidance is "upgrade to 0.87.0 or later." I verified 0.112.0 retains both fixes — memory files use 0o600/0o700 + O_EXCL + a TOCTOU-safe _secure_mkdir. So this bump does not regress either CVE.

Pinned exactly (not a range) per the supply-chain no-ranges policy in pyproject.toml; uv.lock regenerated with uv lock (only the anthropic entry changes — no transitive churn in pinned deps).

How to test

With only an Amazon Bedrock API key configured (AWS_BEARER_TOKEN_BEDROCK set, no AWS_ACCESS_KEY_ID/AWS_PROFILE/IMDS), provider: bedrock, and a Claude default:

hermes -z "Reply with exactly: CLAUDE_OK"
  • Before (anthropic==0.87.0): could not resolve credentials from session
  • After (anthropic==0.112.0): replies normally; streaming + tool-calling + title generation all work; response usage includes cache_creation/cache_read, confirming the full-feature path.

Tests

pytest tests/agent/test_bedrock_adapter.py tests/agent/test_anthropic_adapter.py tests/agent/test_bedrock_integration.py tests/agent/test_bedrock_1m_context.py tests/hermes_cli/test_bedrock_model_picker.py373 passed. The 6 failures in this set are pre-existing and unrelated (OAuth tests that read real ~/.claude credentials; one EU-region picker test with mock leakage) — they fail identically on unmodified main @ anthropic==0.87.0.

Platforms tested

  • macOS (darwin, arm64), Python 3.11.15, against live Bedrock us-east-1 with us.anthropic.claude-sonnet-4-6.

🤖 Generated with Claude Code

…earer-token auth

The `anthropic` extra and tools/lazy_deps.py both pinned `anthropic==0.87.0`.
On AWS Bedrock, Claude models are routed through the AnthropicBedrock SDK
client (agent/anthropic_adapter.build_anthropic_bedrock_client). In 0.87.0
that client only authenticates via SigV4, so users whose only credential is
an Amazon Bedrock API key (AWS_BEARER_TOKEN_BEDROCK) get:

    API call failed after 3 retries: could not resolve credentials from session

even though `hermes doctor` reports Bedrock connectivity OK (the doctor probe
uses the bearer token directly) and non-Claude Bedrock models — Nova, OpenAI
gpt-oss, DeepSeek, etc. — work fine because they go through the boto3 Converse
API, which honors the bearer token.

AWS bearer-token auth for AnthropicBedrock was added in anthropic 0.88.0
(anthropics/anthropic-sdk-python#1623): the client now reads
AWS_BEARER_TOKEN_BEDROCK and sends `Authorization: Bearer <token>`, falling
back to SigV4 only when no api_key is resolved. Bumping to 0.112.0 makes
Claude-on-Bedrock work with just the bearer token on the full-feature path
(prompt caching, 1M-context beta) — no routing/logic change needed.

The exact `==0.87.0` pin was introduced for CVE-2026-34450 and CVE-2026-34452
(insecure memory-tool file permissions / async symlink TOCTOU). Both were
fixed *in* 0.87.0 and remain fixed in 0.112.0 (memory files still use
0o600/0o700 + O_EXCL + TOCTOU-safe mkdir), so this bump does not regress them.
Pinned exactly per the supply-chain no-ranges policy; uv.lock regenerated.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@krystiancharubin
krystiancharubin requested a review from a team June 28, 2026 20:53
@alt-glitch alt-glitch added type/bug Something isn't working comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint provider/anthropic Anthropic native Messages API provider/bedrock AWS Bedrock (boto3, IAM) dependencies Pull requests that update a dependency file P2 Medium — degraded but workaround exists labels Jun 28, 2026
moro-no-kimi added a commit to RosenblattAI/hermes-agent that referenced this pull request Jul 7, 2026
…earer-token auth

Bumps the anthropic SDK from 0.87.0 to 0.112.0. Claude models on Bedrock
are routed through AnthropicBedrock (agent/anthropic_adapter.build_anthropic_bedrock_client)
for full feature parity (prompt caching, thinking budgets, 1M-context beta).
In 0.87.0 that client only authenticates via SigV4, so a user whose only
credential is an Amazon Bedrock API key (AWS_BEARER_TOKEN_BEDROCK) hit:

  API call failed after 3 retries: could not resolve credentials from session

AWS bearer-token auth for AnthropicBedrock was added in anthropic 0.88.0
(anthropics/anthropic-sdk-python#1623). No hermes-agent routing/logic
change required.

CVE-2026-34450/34452 (the reason for the exact 0.87.0 pin) are fixed in
0.87.0 and confirmed retained in 0.112.0.

Verified locally end-to-end: `hermes -z "Reply with exactly: CLAUDE_OK"`
against claude-sonnet-5 on Bedrock via AWS_BEARER_TOKEN_BEDROCK alone
(no AWS_ACCESS_KEY_ID/AWS_PROFILE/IMDS) now succeeds. 379 tests pass
(test_bedrock_adapter, test_anthropic_adapter, test_bedrock_integration,
test_bedrock_1m_context, test_bedrock_model_picker).

Applying as a T2 patch ahead of upstream merge.
Upstream PR: NousResearch#54431

@teknium1 teknium1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for isolating the Anthropic SDK update across the extra, lazy-install, and lockfile surfaces.

Problems

  • uv.lock:2900 removes the sys_platform == 'win32' marker from the portalockerpywin32 dependency. Current main retains that marker at uv.lock:3030, consistent with the Windows-only logging dependency rationale in pyproject.toml:128-140. This unrelated resolution change should not accompany the Anthropic update.

Suggested changes

  • Regenerate uv.lock against current main and keep the existing pywin32 platform marker, so the lockfile change is scoped to the Anthropic resolution.
  • Keep pyproject.toml:146 and tools/lazy_deps.py:99 in lockstep; both currently pin anthropic==0.87.0 while Claude Bedrock routing selects the AnthropicBedrock path at hermes_cli/runtime_provider.py:1979.

Automated hermes-sweeper review.

Comment thread uv.lock
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "pywin32", marker = "sys_platform == 'win32'" },
{ name = "pywin32" },

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please retain marker = "sys_platform == 'win32'" on this edge. Current main has that marker at uv.lock:3030, matching the Windows-only concurrent-log-handler dependency in pyproject.toml; this unrelated lockfile change should be removed when regenerating for the Anthropic bump.

@teknium1 teknium1 added sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-platform-windows Sweeper risk: may break or behave differently on native Windows sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint dependencies Pull requests that update a dependency file P2 Medium — degraded but workaround exists provider/anthropic Anthropic native Messages API provider/bedrock AWS Bedrock (boto3, IAM) sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-platform-windows Sweeper risk: may break or behave differently on native Windows type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants