Skip to content

fix(agent): support AWS Bedrock provider for inference and auxiliary tasks - #10745

Closed
zlyuan9 wants to merge 2 commits into
NousResearch:mainfrom
zlyuan9:fix/bedrock-provider-support
Closed

fix(agent): support AWS Bedrock provider for inference and auxiliary tasks#10745
zlyuan9 wants to merge 2 commits into
NousResearch:mainfrom
zlyuan9:fix/bedrock-provider-support

Conversation

@zlyuan9

@zlyuan9 zlyuan9 commented Apr 16, 2026

Copy link
Copy Markdown

What changed and why

Three bugs prevented Hermes from working when configured with AWS Bedrock as the inference provider (e.g. provider: bedrock, model: us.anthropic.claude-sonnet-4-6).

1. agent/model_metadata.py — context-length probe hits unsupported Bedrock endpoint

_is_known_provider_base_url() didn't recognize Bedrock URLs (bedrock-runtime.*.amazonaws.com), so the context-length detection fell through to a GET /models probe. Bedrock does not expose this endpoint → HTTP 400 error before any real inference request was ever attempted.

Fix: Added "bedrock-runtime" and "bedrock-mantle" to _URL_TO_PROVIDER, so Bedrock URLs are recognized as a known provider and the code falls straight to the static context-length table (200k for Claude Sonnet 4.6).

2. run_agent.py — regional inference profile IDs mangled by normalize_model_name()

Bedrock cross-region inference profile IDs use dot notation: us.anthropic.claude-sonnet-4-6. _anthropic_preserve_dots() returned False for Bedrock, so normalize_model_name() converted all dots to hyphens → us-anthropic-claude-sonnet-4-6. Bedrock rejects this as an invalid model identifier.

Fix: Added "bedrock" to the provider set in _anthropic_preserve_dots(), and added Bedrock URL substrings to the base-URL fallback check.

3. agent/auxiliary_client.pyaws_sdk auth type unhandled

resolve_provider_client() handled api_key, external_process, and oauth_device_code auth types but not aws_sdk (Bedrock's auth type). It fell through to an unknown provider warning and returned (None, None) — a confusing log message that looked like a bug rather than an expected fallback.

Fix: Added an explicit aws_sdk branch that returns (None, None) with a debug-level log, so callers fall back to an OpenAI-compatible auxiliary provider as intended.

How to test

Reproduction steps (before fix):

  1. Set model.default: us.anthropic.claude-sonnet-4-6, model.provider: bedrock in ~/.hermes/config.yaml
  2. Set AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY in ~/.hermes/.env
  3. Run hermes chat -q "Hello" → HTTP 400 "The provided model identifier is invalid"

Verification (after fix):

  1. Same config as above
  2. Run hermes chat -q "Hello" → agent responds normally
  3. Enable debug logging and confirm no unhandled auth_type aws_sdk warning appears
  4. Confirm model name sent to Bedrock is us.anthropic.claude-sonnet-4-6 (dots preserved)

Platforms tested

  • macOS (darwin)

Notes

The existing debug request dump in _dump_api_request_debug() always reconstructs the URL as /chat/completions and auth as Bearer {key} for Bedrock requests regardless of actual api_mode — this is a pre-existing display artifact and not addressed in this PR.

…tasks

- model_metadata.py: add bedrock-runtime/bedrock-mantle to _URL_TO_PROVIDER
  so context-length detection skips the /models probe (unsupported on Bedrock)
- run_agent.py: add "bedrock" to _anthropic_preserve_dots() so regional
  inference profile IDs (e.g. us.anthropic.claude-sonnet-4-6) are not
  mangled to us-anthropic-... by normalize_model_name()
- auxiliary_client.py: handle aws_sdk auth type gracefully instead of
  emitting a warning and returning (None, None) unexpectedly
@limitMe

limitMe commented Apr 17, 2026

Copy link
Copy Markdown

This fix works for me

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint provider/bedrock AWS Bedrock (boto3, IAM) labels Apr 25, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Related to #11132, #11612, #12365, and #12979 — multiple open PRs addressing Bedrock support. Consider coordinating to avoid merge conflicts.

@zlyuan9

zlyuan9 commented Apr 26, 2026

Copy link
Copy Markdown
Author

Seems that the issue's been resolved already, I think we can close this PR

@zlyuan9 zlyuan9 closed this Apr 26, 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 P2 Medium — degraded but workaround exists provider/bedrock AWS Bedrock (boto3, IAM) type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants