Skip to content

fix: preserve Bedrock model ID dots in normalization pipeline#10772

Closed
ptlally wants to merge 1 commit into
NousResearch:mainfrom
ptlally:fix/bedrock-model-id-normalization
Closed

fix: preserve Bedrock model ID dots in normalization pipeline#10772
ptlally wants to merge 1 commit into
NousResearch:mainfrom
ptlally:fix/bedrock-model-id-normalization

Conversation

@ptlally

@ptlally ptlally commented Apr 16, 2026

Copy link
Copy Markdown

Bedrock model IDs use dots as vendor separators (e.g. anthropic.claude-sonnet-4-6), but normalize_model_name() was replacing all dots with hyphens, producing invalid IDs like anthropic-claude-sonnet-4-6.

Root cause: _anthropic_preserve_dots() in run_agent.py did not include "bedrock" in its provider set, so the anthropic_messages path called normalize_model_name() with preserve_dots=False.

Fix:

  • Add "bedrock" to _anthropic_preserve_dots() provider set so Bedrock model IDs keep their vendor dot separators through the Anthropic Messages API adapter.
  • Add "bedrock" to _AUTHORITATIVE_NATIVE_PROVIDERS in model_normalize.py so Bedrock model IDs pass through startup normalization unchanged.

Covers standard (anthropic.claude-*), cross-region (us.anthropic.claude-*), and versioned (anthropic.claude-*-v2:0) model ID formats.

Tests: 22 new parametrized tests for bug condition + preservation.

Note: Bedrock's inference profile requirement (needing us.anthropic.claude-* instead of bare anthropic.claude-* for on-demand throughput) is a separate issue — this PR only fixes the dot-mangling that broke Anthropic/Claude model IDs on the Bedrock anthropic_messages path. Non-Claude Bedrock models (Nova, Llama, etc.) use the bedrock_converse path and were unaffected. Users can work around the inference profile issue by setting the full model ID (e.g. us.anthropic.claude-sonnet-4-6) in config.yaml.

What does this PR do?

When provider is bedrock and a Claude model is detected, hermes routes through the anthropic_messages API mode using the AnthropicBedrock SDK. The model ID (e.g. anthropic.claude-sonnet-4-6) flows through normalize_model_name() with preserve_dots=False, which replaces the vendor dot separator with a hyphen. The resulting anthropic-claude-sonnet-4-6 is not a valid Bedrock model identifier, causing API calls to fail with a 400.

Non-Claude Bedrock models (Nova, DeepSeek, Llama, etc.) use the bedrock_converse path and were not affected by this bug.

This PR adds "bedrock" to two existing provider sets so Bedrock model IDs pass through both normalization layers unchanged. The Anthropic SDK itself does no model ID normalization — it just URL-encodes the model for the Bedrock invoke path — so the fix is entirely within hermes.

Related Issue

N/A — discovered during Bedrock provider testing.

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

  • run_agent.py: Added "bedrock" to the provider set in _anthropic_preserve_dots() (~line 6295)
  • hermes_cli/model_normalize.py: Added "bedrock" to _AUTHORITATIVE_NATIVE_PROVIDERS (~line 88)
  • tests/agent/test_anthropic_adapter.py: Added TestBedrockDotPreservation (5 tests) and TestNonBedrockPreservation (11 tests)
  • tests/hermes_cli/test_model_normalize.py: Added TestBedrockModelIdPreservation (4 tests) and TestNonBedrockPreservation (3 tests)

How to Test

  1. Configure hermes with provider: bedrock and a Claude model (e.g. us.anthropic.claude-sonnet-4-6)
  2. Run hermes and send a message — the API call should succeed without model ID errors
  3. Verify non-Bedrock providers still work (e.g. provider: anthropic with claude-sonnet-4.6 should still normalize to claude-sonnet-4-6)
  4. Run python -m pytest tests/agent/test_anthropic_adapter.py tests/hermes_cli/test_model_normalize.py -q — 172 tests pass

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform: Ubuntu (EC2), tested with Bedrock + Claude models

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — or N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — or N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — or N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — or N/A
  • I've updated tool descriptions/schemas if I changed tool behavior — or N/A

Screenshots / Logs

Before fix:
image
image

After fix (with inference profile model ID us.anthropic.claude-sonnet-4-6):
Model ID passes through unchanged, API calls succeed.
image

Bedrock model IDs use dots as vendor separators (e.g.
anthropic.claude-sonnet-4-6), but normalize_model_name() was replacing
all dots with hyphens, producing invalid IDs like
anthropic-claude-sonnet-4-6.

Root cause: _anthropic_preserve_dots() in run_agent.py did not include
'bedrock' in its provider set, so the anthropic_messages path called
normalize_model_name() with preserve_dots=False.

Fix:
- Add 'bedrock' to _anthropic_preserve_dots() provider set so Bedrock
  model IDs keep their vendor dot separators through the Anthropic
  Messages API adapter.
- Add 'bedrock' to _AUTHORITATIVE_NATIVE_PROVIDERS in model_normalize.py
  so Bedrock model IDs pass through startup normalization unchanged.

Covers standard (anthropic.claude-*), cross-region
(us.anthropic.claude-*), and versioned (anthropic.claude-*-v2:0) model
ID formats.

Tests: 22 new parametrized tests for bug condition + preservation.
@ptlally

ptlally commented Apr 21, 2026

Copy link
Copy Markdown
Author

Issue resolved with PR #12793, thanks Tek :)

Closing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant