Skip to content

feat: native AWS Bedrock provider via Converse API#10549

Merged
teknium1 merged 1 commit into
mainfrom
hermes/hermes-19e7c897
Apr 15, 2026
Merged

feat: native AWS Bedrock provider via Converse API#10549
teknium1 merged 1 commit into
mainfrom
hermes/hermes-19e7c897

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Summary

Salvaged from PR #7920 by @JiaDe-Wu — cherry-picked Bedrock-specific additions onto current main, skipping all stale-branch reverts (original PR was 293 commits behind).

What this PR does

Adds AWS Bedrock as a first-class inference provider with a dual-path architecture:

  • Claude models → AnthropicBedrock SDK (prompt caching, thinking budgets, adaptive thinking)
  • Non-Claude models → Converse API via boto3 (Nova, DeepSeek, Llama, Mistral)

Features

  • Core Converse API adapter (agent/bedrock_adapter.py, 1098 lines)
  • Full provider registration across all 6 touchpoints (auth, models, providers, config, runtime, main)
  • IAM credential chain (env vars, SSO, instance roles, ECS/Lambda) + Bedrock API Key auth
  • Dynamic model discovery via ListFoundationModels + ListInferenceProfiles
  • Real-time streaming with delta callbacks (text, tool, reasoning)
  • Error classification (ThrottlingException, context overflow, etc.)
  • AWS Guardrails support (config.yaml integration)
  • hermes doctor — checks Bedrock access, model count, credential source
  • hermes auth — displays IAM identity, region
  • /usage pricing for 7 Bedrock models
  • pip install hermes-agent[bedrock] optional dependency

Testing

  • 130 automated tests (79 unit + 28 integration + 23 follow-up fixes) — all passing
  • 12 E2E integration checks verifying the full registration chain
  • 0 regressions — all pre-existing test failures confirmed on clean main

Files changed (18 files, +3543 / -20)

File Change
agent/bedrock_adapter.py New — Core Converse API adapter
agent/anthropic_adapter.py +27 — build_anthropic_bedrock_client()
agent/error_classifier.py +9 — Bedrock throttling + context overflow patterns
agent/model_metadata.py +10 — Bedrock context length resolution
agent/usage_pricing.py +74 — 7 Bedrock model pricing entries
hermes_cli/auth.py +25 — ProviderConfig, aliases, auto-detect
hermes_cli/models.py +57 — Model list, labels, aliases, validation
hermes_cli/providers.py +14 — Aliases, transport mapping, URL heuristic
hermes_cli/config.py +37 — bedrock config section, env vars
hermes_cli/runtime_provider.py +73 — Bedrock resolution with guardrails
hermes_cli/main.py +248 — _model_flow_bedrock() with discovery
hermes_cli/doctor.py +25 — Bedrock diagnostics
hermes_cli/auth_commands.py +21 — AWS credential status display
run_agent.py +178 — api_mode, init, build_kwargs, streaming, non-streaming
pyproject.toml +2 — boto3 optional dep
tests/agent/test_bedrock_adapter.py New — 79 unit tests
tests/agent/test_bedrock_integration.py New — 28 integration tests
website/docs/guides/aws-bedrock.md New — Full setup guide

Closes #3863. Credit: @JiaDe-Wu (original implementation), @hheydaroff (earlier PR #6845, voluntarily closed in favor of #7920).

Salvaged from PR #7920 by JiaDe-Wu — cherry-picked Bedrock-specific
additions onto current main, skipping stale-branch reverts (293 commits
behind).

Dual-path architecture:
  - Claude models → AnthropicBedrock SDK (prompt caching, thinking budgets)
  - Non-Claude models → Converse API via boto3 (Nova, DeepSeek, Llama, Mistral)

Includes:
  - Core adapter (agent/bedrock_adapter.py, 1098 lines)
  - Full provider registration (auth, models, providers, config, runtime, main)
  - IAM credential chain + Bedrock API Key auth modes
  - Dynamic model discovery via ListFoundationModels + ListInferenceProfiles
  - Streaming with delta callbacks, error classification, guardrails
  - hermes doctor + hermes auth integration
  - /usage pricing for 7 Bedrock models
  - 130 automated tests (79 unit + 28 integration + follow-up fixes)
  - Documentation (website/docs/guides/aws-bedrock.md)
  - boto3 optional dependency (pip install hermes-agent[bedrock])

Co-authored-by: JiaDe WU <40445668+JiaDe-Wu@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Supply Chain Risk Detected

This PR contains patterns commonly associated with supply chain attacks. This does not mean the PR is malicious — but these patterns require careful human review before merging.

⚠️ WARNING: Dependency manifest files modified

Changes to dependency files can introduce new packages or change version pins. Verify all dependency changes are intentional and from trusted sources.

Files:

pyproject.toml

Automated scan triggered by supply-chain-audit. If this is a false positive, a maintainer can approve after manual review.

@teknium1 teknium1 merged commit 0cb8c51 into main Apr 15, 2026
6 of 8 checks passed
@teknium1 teknium1 deleted the hermes/hermes-19e7c897 branch April 15, 2026 23:17
jessica025 added a commit to jessica025/hermes-agent that referenced this pull request Apr 19, 2026
AIAgent._anthropic_preserve_dots() whitelist was missing 'bedrock'.
The default normalize_model_name() converts dots to hyphens for
OpenRouter compat (e.g. anthropic/claude-opus-4.6 -> claude-opus-4-6),
which mangles Bedrock's cross-region inference profile IDs:

  us.anthropic.claude-sonnet-4-6 -> us-anthropic-claude-sonnet-4-6

Bedrock then rejects the mangled ID with:

  HTTP 400: The provided model identifier is invalid.

This is a follow-up to PR NousResearch#10549 (native AWS Bedrock provider):
the Bedrock path was wired up in runtime_provider.py and
bedrock_adapter.py, but the dot-preservation whitelist missed it.

Add 'bedrock' to the provider whitelist and 'bedrock-runtime' to
the base_url match so Claude models on Bedrock work out of the box.

Verified against us.anthropic.claude-sonnet-4-6,
us.anthropic.claude-opus-4-7, and us.anthropic.claude-opus-4-6-v1.
turbo998 added a commit to turbo998/hermes-agent that referenced this pull request May 9, 2026
Closes parity gap between Azure Foundry (NousResearch#15845) and AWS Bedrock (NousResearch#10549).
Adds the operational polish layer Bedrock established as the bar:

- Azure AI Content Safety client + guardrails block (mirrors Bedrock shape)
- hermes doctor Azure Foundry section
- hermes auth Azure Foundry status row
- Error-classifier patterns: ResponsibleAIPolicyViolation, content_filter,
  Azure 429 retry-after, DeploymentNotFound
- /usage pricing for 7 Azure Foundry models the wizard prefills
- pyproject [azure] optional extra (provider works without it)
- Docs: Content Safety guardrails section in azure-foundry.md
- ~70 new tests across 6 files

Signed-off-by: Chen Qi <turbo998@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Native AWS Bedrock provider support

2 participants