Skip to content

fix(bedrock): preserve dots in Bedrock inference profile model IDs - #12578

Closed
jessica025 wants to merge 1 commit into
NousResearch:mainfrom
jessica025:fix/bedrock-preserve-dots
Closed

fix(bedrock): preserve dots in Bedrock inference profile model IDs#12578
jessica025 wants to merge 1 commit into
NousResearch:mainfrom
jessica025:fix/bedrock-preserve-dots

Conversation

@jessica025

@jessica025 jessica025 commented Apr 19, 2026

Copy link
Copy Markdown

Summary

Bedrock Claude calls fail with HTTP 400: The provided model identifier is invalid when using cross-region inference profile IDs such as us.anthropic.claude-sonnet-4-6.

Root cause: AIAgent._anthropic_preserve_dots() is missing bedrock from its whitelist. The default normalize_model_name() converts dots → hyphens to normalize OpenRouter-style IDs (e.g. anthropic/claude-opus-4.6claude-opus-4-6), which mangles Bedrock's inference profile IDs:

us.anthropic.claude-sonnet-4-6  →  us-anthropic-claude-sonnet-4-6  ❌

Bedrock then rejects the mangled ID. This is a follow-up to #10549 (native AWS Bedrock provider) — the Bedrock path is wired up in runtime_provider.py / bedrock_adapter.py, but this whitelist missed it, so Claude-on-Bedrock breaks end-to-end as soon as an inference-profile ID is needed.

Reproduction

Configure Bedrock + any Claude model that requires a cross-region inference profile (Claude 4.6 / 4.7 family on-demand). Send any message → HTTP 400: The provided model identifier is invalid.

Confirmed the raw SDK call with the dotted ID works fine:

from anthropic import AnthropicBedrock
AnthropicBedrock(aws_region="...").messages.create(
    model="us.anthropic.claude-sonnet-4-6",
    max_tokens=64,
    messages=[{"role": "user", "content": "ping"}],
)

So it's purely a model-name normalization bug, not a credential / region / profile access issue.

Fix

run_agent.py::AIAgent._anthropic_preserve_dots() — add bedrock to the provider whitelist and bedrock-runtime to the base_url match.

Verification

Round-trip AIAgent(...).chat(...) against Bedrock returns a proper response after the fix; before the fix it aborts on HTTP 400. Gateway end-to-end also works after restart.

Verified with the following Bedrock inference profile IDs:

  • us.anthropic.claude-sonnet-4-6
  • us.anthropic.claude-opus-4-7
  • us.anthropic.claude-opus-4-6-v1

All previously failed with the 400; all work after the fix.

Scope / side effects

  • Only affects Bedrock paths (gated by provider == "bedrock" and bedrock-runtime in base_url).
  • No behavior change for OpenRouter / native Anthropic / Nous / any other provider.
  • AnthropicBedrock SDK accepts dotted inference profile IDs natively — no further conversion needed downstream.

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.
@jessica025
jessica025 force-pushed the fix/bedrock-preserve-dots branch from 7177e25 to cff3b3f Compare April 19, 2026 14:24
@alt-glitch alt-glitch added type/bug Something isn't working P1 High — major feature broken, no workaround comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint labels Apr 23, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Likely duplicate of #12577 — identical fix adding 'bedrock' to _anthropic_preserve_dots() provider whitelist. Also related to #13112 which addresses the same normalize_model_name() bug.

@teknium1

Copy link
Copy Markdown
Contributor

Thanks for the careful diagnosis and the clean reproduction steps, @jessica025! After reviewing current main, this fix is already in place.

Evidence:

  • run_agent.py line 7260: "bedrock" is already in the _anthropic_preserve_dots() provider whitelist
  • run_agent.py line 7272: "bedrock-runtime." is already in the base_url defense-in-depth check
  • The fix landed via commit 1cf1016e7 (fix(run_agent): preserve dotted Bedrock inference-profile model IDs (#11976))
  • The method's docstring explicitly documents dotted Bedrock inference-profile IDs (e.g. us.anthropic.claude-sonnet-4-5) and the HTTP 400 rejection behavior

As @alt-glitch noted, this appears to be a duplicate of #12577 which addressed the same whitelist. Closing as already implemented on main.

This is an automated hermes-sweeper review.

@teknium1 teknium1 closed this Apr 27, 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 P1 High — major feature broken, no workaround type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants