Skip to content

fix(pricing): resolve versioned Bedrock profile IDs - #50437

Closed
Osraka wants to merge 2 commits into
NousResearch:mainfrom
Osraka:fix/bedrock-versioned-profile-pricing
Closed

fix(pricing): resolve versioned Bedrock profile IDs#50437
Osraka wants to merge 2 commits into
NousResearch:mainfrom
Osraka:fix/bedrock-versioned-profile-pricing

Conversation

@Osraka

@Osraka Osraka commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #50307 and the now-closed #50295.

#50307 fixed the main /usage failure for Bedrock Claude cache tokens and exact cross-region profile IDs such as us.anthropic.claude-sonnet-4-5. Two profile shapes can still miss the official pricing table:

  • versioned Bedrock profile IDs, e.g. us.anthropic.claude-sonnet-4-6-20250514-v1:0
  • less common AWS profile scopes such as apac.

Those IDs normalize to a valid Bedrock Claude model family, but the lookup only tried an exact key. Since the pricing snapshot is keyed by the shorter model-family ID (anthropic.claude-sonnet-4-6), these still fell through to None.

This PR leaves the cache pricing rows from #50307 alone and only tightens the Bedrock pricing lookup.

Changes

  • Expand the Bedrock inference-profile prefix list to include global., us., eu., ap., apac., jp., ca., sa., me., and af..
  • Add a longest-prefix fallback for Bedrock official-docs pricing entries so versioned IDs resolve to their bare table row.
  • Add regression tests for versioned us. / global. Claude profile IDs and an apac. Claude Haiku profile ID.

Validation

Before this patch on current origin/main:

Model Pricing lookup
us.anthropic.claude-sonnet-4-6 resolves
us.anthropic.claude-sonnet-4-6-20250514-v1:0 misses
global.anthropic.claude-sonnet-4-6-20250514-v1:0 misses
apac.anthropic.claude-haiku-4-5-20251001-v1:0 misses

Tests run:

  • python3 -m pytest tests/agent/test_usage_pricing.py -q -> 17 passed
  • python3 -m ruff check agent/usage_pricing.py tests/agent/test_usage_pricing.py
  • git diff --check
  • python3 -m py_compile agent/usage_pricing.py tests/agent/test_usage_pricing.py

Note: bash scripts/run_tests.sh tests/agent/test_usage_pricing.py could not run in this local checkout because the wrapper requires a .venv or venv directory.

@alt-glitch alt-glitch added type/bug Something isn't working comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P2 Medium — degraded but workaround exists labels Jun 21, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Thanks for the focused Bedrock pricing regression coverage. The premise remains valid on current main: agent/usage_pricing.py:692-697 strips only a limited set of scopes, and agent/usage_pricing.py:733-738 then relies on an exact normalized pricing key. Current integration tests carry dated and APAC model-ID shapes (tests/agent/test_bedrock_integration.py:366-379).

Problems

  • The fallback added in the PR's agent/usage_pricing.py lookup hunk treats every known_model-... or known_model:... continuation as that known model. This would price an otherwise unrecognized similarly named SKU using the base-model entry rather than leaving its price unknown.

Suggested changes

  • Normalize only documented trailing Bedrock revision components (date, -vN, and :N) before the existing exact lookup. This fixes the reported IDs without broad model-family matching.
  • Have the APAC test compare against the corresponding bare Bedrock entry, as the versioned-ID test already does, rather than asserting snapshot price literals.

Automated hermes-sweeper review.

@teknium1 teknium1 added sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Jul 15, 2026
@Osraka
Osraka force-pushed the fix/bedrock-versioned-profile-pricing branch from f831530 to bd1d63a Compare July 15, 2026 08:53
@teknium1 teknium1 added the area/profiles Multi-profile isolation, HERMES_HOME scoping label Jul 19, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Merged via PR #67976 — both of your commits (the region-prefix expansion + version/date suffix strip, and the follow-up restricting normalization to anchored trailing forms) were cherry-picked onto current main with your authorship preserved (rebase merge). You were the earliest submission for this fix. Thanks for the careful anchoring so model versions like -4-6 are never eaten!

#67976

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

Labels

area/profiles Multi-profile isolation, HERMES_HOME scoping comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P2 Medium — degraded but workaround exists sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bedrock Claude /usage shows cost unknown — pricing table lacks cache cost fields + cross-region prefix normalization

3 participants