feat: add Amazon Bedrock as inference provider#6845
Conversation
66ba505 to
2cafcb1
Compare
|
In Observation: If a user sends a message containing an image URL (e.g., Question: Have you considered how this adapter behaves in such scenarios? Should this trigger an error, a warning log, or a fallback mechanism (e.g., attempting to fetch and convert the URL to base64 before sending to Bedrock)? Specifically, what is the expected behavior for |
2cafcb1 to
e727c53
Compare
|
@trevorgordon981 , yes you are right. URL images → fetched at call time, converted to bytes, sent to Converse. Supports jpeg/png/gif/webp, 25MB cap, 10s timeout. Failure handling → logs a warning and skips the image (text parts still go through). No silent dropping. |
f5fb0f3 to
3fbfd3a
Compare
Add Amazon Bedrock as a first-class inference provider using the Converse API via boto3. Supports three authentication methods: Bedrock API keys (Bearer tokens), AWS profiles (~/.aws/credentials), and AWS access key pairs. - agent/bedrock_adapter.py — Converse API adapter (message conversion, tool schema translation, response normalization) - hermes_cli/auth.py — ProviderConfig, _resolve_bedrock_base_url(), region-aware endpoint construction, provider aliases - hermes_cli/providers.py — HermesOverlay with bedrock_converse transport, aliases, labels - hermes_cli/models.py — Curated model list with global/eu/us inference profile IDs and bare model IDs - hermes_cli/config.py — AWS_BEARER_TOKEN_BEDROCK and AWS_BEDROCK_REGION env vars - hermes_cli/runtime_provider.py — bedrock_converse in valid API modes - agent/models_dev.py — PROVIDER_TO_MODELS_DEV mapping - New api_mode 'bedrock_converse' with full lifecycle support: init, switch_model, _build_api_kwargs, _interruptible_api_call, response validation, finish_reason extraction, response normalization - Safe vars() call in error logging (handles dict responses from boto3) - Dedicated _model_flow_bedrock() with interactive setup: - Auth picker: existing API key, new API key, AWS profile, access keys - Region selector with common regions + custom input - Model selection from curated list - Persists api_mode=bedrock_converse in config.yaml - Added boto3 to pyproject.toml Bedrock models use cross-region inference profile prefixes: - global. — works from any region - eu. — EU cross-region routing - us. — US cross-region routing - bare — single-region direct access
3fbfd3a to
b4b7aa9
Compare
|
Hey @hheydaroff — saw your comment on #3863. We've got a parallel PR at #7920 that also uses the Converse API + boto3. Some differences worth noting:
Would be great to get one of these merged — the community clearly wants this (#3863 has been open since March). Happy to help consolidate if needed. |
|
Closing it in favor of #7920 |
Summary
Add Amazon Bedrock as a first-class inference provider using the Converse API via boto3.
Authentication
Three methods supported, selectable via
hermes model:AWS_BEARER_TOKEN_BEDROCK) — generate in the Bedrock console → API keys~/.aws/credentials, setsAWS_PROFILEAWS_ACCESS_KEY_ID+AWS_SECRET_ACCESS_KEYRegion support
Interactive region picker in
hermes modelwith common regions (us-east-1, eu-central-1, etc.) or custom entry. Stored asAWS_BEDROCK_REGION.Model IDs
Bedrock uses cross-region inference profile prefixes:
global.anthropic.claude-opus-4-6-v1— works from any regioneu.anthropic.claude-opus-4-6-v1— EU cross-region routingus.anthropic.claude-opus-4-6-v1— US cross-region routinganthropic.claude-opus-4-6-v1— single-region (direct access only)Usage
Architecture
bedrock_converse— joins existingchat_completions,codex_responses,anthropic_messagesagent/bedrock_adapter.py— translates OpenAI-format messages ↔ Converse API format (system blocks, toolUse/toolResult content blocks, tool schemas)elifbranchesFiles changed
agent/bedrock_adapter.pyhermes_cli/auth.pyhermes_cli/config.pyAWS_BEARER_TOKEN_BEDROCK,AWS_BEDROCK_REGIONenv varshermes_cli/main.py_model_flow_bedrock()with auth/region/model setuphermes_cli/models.pyhermes_cli/providers.pyhermes_cli/runtime_provider.pybedrock_conversein valid modesagent/models_dev.pyrun_agent.pypyproject.tomlTesting
All 9632 existing tests pass. Changes are additive — no existing provider flows modified.