fix(agent): support AWS Bedrock provider for inference and auxiliary tasks - #10745
Closed
zlyuan9 wants to merge 2 commits into
Closed
fix(agent): support AWS Bedrock provider for inference and auxiliary tasks#10745zlyuan9 wants to merge 2 commits into
zlyuan9 wants to merge 2 commits into
Conversation
…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
|
This fix works for me |
This was referenced Apr 17, 2026
Collaborator
Author
|
Seems that the issue's been resolved already, I think we can close this PR |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 aGET /modelsprobe. 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 bynormalize_model_name()Bedrock cross-region inference profile IDs use dot notation:
us.anthropic.claude-sonnet-4-6._anthropic_preserve_dots()returnedFalsefor Bedrock, sonormalize_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.py—aws_sdkauth type unhandledresolve_provider_client()handledapi_key,external_process, andoauth_device_codeauth types but notaws_sdk(Bedrock's auth type). It fell through to anunknown providerwarning and returned(None, None)— a confusing log message that looked like a bug rather than an expected fallback.Fix: Added an explicit
aws_sdkbranch that returns(None, None)with adebug-level log, so callers fall back to an OpenAI-compatible auxiliary provider as intended.How to test
Reproduction steps (before fix):
model.default: us.anthropic.claude-sonnet-4-6,model.provider: bedrockin~/.hermes/config.yamlAWS_ACCESS_KEY_IDandAWS_SECRET_ACCESS_KEYin~/.hermes/.envhermes chat -q "Hello"→ HTTP 400 "The provided model identifier is invalid"Verification (after fix):
hermes chat -q "Hello"→ agent responds normallyunhandled auth_type aws_sdkwarning appearsus.anthropic.claude-sonnet-4-6(dots preserved)Platforms tested
Notes
The existing debug request dump in
_dump_api_request_debug()always reconstructs the URL as/chat/completionsand auth asBearer {key}for Bedrock requests regardless of actualapi_mode— this is a pre-existing display artifact and not addressed in this PR.