fix(bedrock): inference profile ID preservation + correct client rebuild on interrupt - #14680
Closed
bsgdigital wants to merge 2 commits into
Closed
fix(bedrock): inference profile ID preservation + correct client rebuild on interrupt#14680bsgdigital wants to merge 2 commits into
bsgdigital wants to merge 2 commits into
Conversation
added 2 commits
April 23, 2026 18:24
19 tasks
teknium1
pushed a commit
that referenced
this pull request
Apr 24, 2026
…rupt Three interrupt-recovery sites in run_agent.py rebuilt self._anthropic_client with build_anthropic_client(self._anthropic_api_key, ...) unconditionally. When provider=bedrock + api_mode=anthropic_messages (AnthropicBedrock SDK path), self._anthropic_api_key is the sentinel 'aws-sdk' — build_anthropic_client doesn't accept that and the rebuild either crashed or produced a non-functional client. Extract a _rebuild_anthropic_client() helper that dispatches to build_anthropic_bedrock_client(region) when provider='bedrock', falling back to build_anthropic_client() for native Anthropic and other anthropic_messages providers (MiniMax, Kimi, Alibaba, etc.). Three inline rebuild sites now call the helper. Partial salvage of #14680 by @bsgdigital — only the _rebuild_anthropic_client helper. The normalize_model_name Bedrock-prefix piece was subsumed by #14664, and the aux client aws_sdk branch was subsumed by #14770 (both in the same salvage PR as this commit).
justrhoto
pushed a commit
to justrhoto/hermes-agent
that referenced
this pull request
Apr 24, 2026
…rupt Three interrupt-recovery sites in run_agent.py rebuilt self._anthropic_client with build_anthropic_client(self._anthropic_api_key, ...) unconditionally. When provider=bedrock + api_mode=anthropic_messages (AnthropicBedrock SDK path), self._anthropic_api_key is the sentinel 'aws-sdk' — build_anthropic_client doesn't accept that and the rebuild either crashed or produced a non-functional client. Extract a _rebuild_anthropic_client() helper that dispatches to build_anthropic_bedrock_client(region) when provider='bedrock', falling back to build_anthropic_client() for native Anthropic and other anthropic_messages providers (MiniMax, Kimi, Alibaba, etc.). Three inline rebuild sites now call the helper. Partial salvage of NousResearch#14680 by @bsgdigital — only the _rebuild_anthropic_client helper. The normalize_model_name Bedrock-prefix piece was subsumed by NousResearch#14664, and the aux client aws_sdk branch was subsumed by NousResearch#14770 (both in the same salvage PR as this commit).
Contributor
|
Thanks for this contribution, @bsgdigital! All three fixes from this PR are now on This is an automated hermes-sweeper review. What landed:
All changes verified present in |
aj-nt
pushed a commit
to aj-nt/hermes-agent
that referenced
this pull request
May 1, 2026
…rupt Three interrupt-recovery sites in run_agent.py rebuilt self._anthropic_client with build_anthropic_client(self._anthropic_api_key, ...) unconditionally. When provider=bedrock + api_mode=anthropic_messages (AnthropicBedrock SDK path), self._anthropic_api_key is the sentinel 'aws-sdk' — build_anthropic_client doesn't accept that and the rebuild either crashed or produced a non-functional client. Extract a _rebuild_anthropic_client() helper that dispatches to build_anthropic_bedrock_client(region) when provider='bedrock', falling back to build_anthropic_client() for native Anthropic and other anthropic_messages providers (MiniMax, Kimi, Alibaba, etc.). Three inline rebuild sites now call the helper. Partial salvage of NousResearch#14680 by @bsgdigital — only the _rebuild_anthropic_client helper. The normalize_model_name Bedrock-prefix piece was subsumed by NousResearch#14664, and the aux client aws_sdk branch was subsumed by NousResearch#14770 (both in the same salvage PR as this commit).
donald131
pushed a commit
to donald131/hermes-agent
that referenced
this pull request
May 2, 2026
…rupt Three interrupt-recovery sites in run_agent.py rebuilt self._anthropic_client with build_anthropic_client(self._anthropic_api_key, ...) unconditionally. When provider=bedrock + api_mode=anthropic_messages (AnthropicBedrock SDK path), self._anthropic_api_key is the sentinel 'aws-sdk' — build_anthropic_client doesn't accept that and the rebuild either crashed or produced a non-functional client. Extract a _rebuild_anthropic_client() helper that dispatches to build_anthropic_bedrock_client(region) when provider='bedrock', falling back to build_anthropic_client() for native Anthropic and other anthropic_messages providers (MiniMax, Kimi, Alibaba, etc.). Three inline rebuild sites now call the helper. Partial salvage of NousResearch#14680 by @bsgdigital — only the _rebuild_anthropic_client helper. The normalize_model_name Bedrock-prefix piece was subsumed by NousResearch#14664, and the aux client aws_sdk branch was subsumed by NousResearch#14770 (both in the same salvage PR as this commit).
02356abc
pushed a commit
to 02356abc/hermes-agent
that referenced
this pull request
May 14, 2026
…rupt Three interrupt-recovery sites in run_agent.py rebuilt self._anthropic_client with build_anthropic_client(self._anthropic_api_key, ...) unconditionally. When provider=bedrock + api_mode=anthropic_messages (AnthropicBedrock SDK path), self._anthropic_api_key is the sentinel 'aws-sdk' — build_anthropic_client doesn't accept that and the rebuild either crashed or produced a non-functional client. Extract a _rebuild_anthropic_client() helper that dispatches to build_anthropic_bedrock_client(region) when provider='bedrock', falling back to build_anthropic_client() for native Anthropic and other anthropic_messages providers (MiniMax, Kimi, Alibaba, etc.). Three inline rebuild sites now call the helper. Partial salvage of NousResearch#14680 by @bsgdigital — only the _rebuild_anthropic_client helper. The normalize_model_name Bedrock-prefix piece was subsumed by NousResearch#14664, and the aux client aws_sdk branch was subsumed by NousResearch#14770 (both in the same salvage PR as this commit).
gweeteve
pushed a commit
to gweeteve/hermes-agent
that referenced
this pull request
Jun 2, 2026
…rupt Three interrupt-recovery sites in run_agent.py rebuilt self._anthropic_client with build_anthropic_client(self._anthropic_api_key, ...) unconditionally. When provider=bedrock + api_mode=anthropic_messages (AnthropicBedrock SDK path), self._anthropic_api_key is the sentinel 'aws-sdk' — build_anthropic_client doesn't accept that and the rebuild either crashed or produced a non-functional client. Extract a _rebuild_anthropic_client() helper that dispatches to build_anthropic_bedrock_client(region) when provider='bedrock', falling back to build_anthropic_client() for native Anthropic and other anthropic_messages providers (MiniMax, Kimi, Alibaba, etc.). Three inline rebuild sites now call the helper. Partial salvage of NousResearch#14680 by @bsgdigital — only the _rebuild_anthropic_client helper. The normalize_model_name Bedrock-prefix piece was subsumed by NousResearch#14664, and the aux client aws_sdk branch was subsumed by NousResearch#14770 (both in the same salvage PR as this commit).
waefrebeorn
pushed a commit
to waefrebeorn/slermes
that referenced
this pull request
Jul 2, 2026
…rupt Three interrupt-recovery sites in run_agent.py rebuilt self._anthropic_client with build_anthropic_client(self._anthropic_api_key, ...) unconditionally. When provider=bedrock + api_mode=anthropic_messages (AnthropicBedrock SDK path), self._anthropic_api_key is the sentinel 'aws-sdk' — build_anthropic_client doesn't accept that and the rebuild either crashed or produced a non-functional client. Extract a _rebuild_anthropic_client() helper that dispatches to build_anthropic_bedrock_client(region) when provider='bedrock', falling back to build_anthropic_client() for native Anthropic and other anthropic_messages providers (MiniMax, Kimi, Alibaba, etc.). Three inline rebuild sites now call the helper. Partial salvage of NousResearch#14680 by @bsgdigital — only the _rebuild_anthropic_client helper. The normalize_model_name Bedrock-prefix piece was subsumed by NousResearch#14664, and the aux client aws_sdk branch was subsumed by NousResearch#14770 (both in the same salvage PR as this commit).
prmartinow
pushed a commit
to prmartinow/hermes-agent
that referenced
this pull request
Aug 26, 2026
…rupt Three interrupt-recovery sites in run_agent.py rebuilt self._anthropic_client with build_anthropic_client(self._anthropic_api_key, ...) unconditionally. When provider=bedrock + api_mode=anthropic_messages (AnthropicBedrock SDK path), self._anthropic_api_key is the sentinel 'aws-sdk' — build_anthropic_client doesn't accept that and the rebuild either crashed or produced a non-functional client. Extract a _rebuild_anthropic_client() helper that dispatches to build_anthropic_bedrock_client(region) when provider='bedrock', falling back to build_anthropic_client() for native Anthropic and other anthropic_messages providers (MiniMax, Kimi, Alibaba, etc.). Three inline rebuild sites now call the helper. Partial salvage of NousResearch#14680 by @bsgdigital — only the _rebuild_anthropic_client helper. The normalize_model_name Bedrock-prefix piece was subsumed by NousResearch#14664, and the aux client aws_sdk branch was subsumed by NousResearch#14770 (both in the same salvage PR as this commit).
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.
Bug Description
Two Bedrock-specific bugs that cause failures when running hermes-agent with AWS Bedrock as the inference provider.
Root Cause / Fix
1. Bedrock inference profile IDs mangled by
normalize_model_nameBedrock cross-region inference profile IDs use dots as namespace separators (
us.anthropic.claude-haiku-4-5-20251001-v1:0). The existingnormalize_model_name()function converted those dots to hyphens (OpenRouter compat path), turning the model ID into garbage and causingValidationExceptionfrom Bedrock.Fix: add an early-return in
normalize_model_name()for IDs that start withus.,eu.,ap., orglobal.— these are Bedrock inference profile namespaces and must be passed through unchanged.2. Client rebuild after interrupt always uses direct Anthropic SDK
When a Ctrl-C interrupt is caught, the agent rebuilds
self._anthropic_client. The original code always calledbuild_anthropic_client(), which requires a direct Anthropic API key (ANTHROPIC_API_KEY). On Bedrock there is no such key — auth goes through AWS SDK — so the rebuilt client was misconfigured and subsequent requests failed.Fix: extract a
_rebuild_anthropic_client()method that checksself.provider == "bedrock"and callsbuild_anthropic_bedrock_client()viaAnthropicBedrockinstead. The three rebuild call sites inrun_agent.pyare updated to use it. Also adds theaws_sdkauth_type path toresolve_provider_client()inagent/auxiliary_client.pyso the auxiliary client (used for vision/summarization) works with Bedrock too.Files Changed
agent/anthropic_adapter.py— add early-return for Bedrock inference profile ID prefixesrun_agent.py— add_rebuild_anthropic_client(), update 3 rebuild call sitesagent/auxiliary_client.py— addaws_sdkauth_type branch toresolve_provider_client()How to Verify
provider: bedrockand a cross-region inference profile model likeus.anthropic.claude-haiku-4-5-20251001-v1:0ValidationExceptionTest Plan
Risk Assessment
Low — changes are gated to Bedrock-specific paths only. The
normalize_model_nameearly-return fires only forus./eu./ap./global.prefixes that no other provider uses. The_rebuild_anthropic_clientrefactor is a pure code-motion change with identical behaviour for non-Bedrock providers.