Skip to content

fix(pricing): strip apac./au. Bedrock region prefixes so cost isn't unknown - #65973

Closed
Drexuxux wants to merge 1 commit into
NousResearch:mainfrom
Drexuxux:fix/bedrock-apac-au-pricing-prefix
Closed

fix(pricing): strip apac./au. Bedrock region prefixes so cost isn't unknown#65973
Drexuxux wants to merge 1 commit into
NousResearch:mainfrom
Drexuxux:fix/bedrock-apac-au-pricing-prefix

Conversation

@Drexuxux

Copy link
Copy Markdown
Contributor

What

_normalize_bedrock_model_name stripped ("us.", "global.", "eu.", "ap.", "jp.")
before the Bedrock pricing lookup, but AWS's Asia-Pacific cross-region inference
profiles are prefixed apac. (and Australia au.), not ap.. A bare
ap. never matches an apac.* id ("apac.".startswith("ap.") is False), so
apac.anthropic.claude-* / au.anthropic.claude-* kept the prefix, missed the
bare anthropic.claude-* pricing key, and every Asia-Pacific / Australia Bedrock
session priced as unknown — no cost estimate for two whole geographies, while
us./eu./global. worked.

The same list is duplicated in bedrock_adapter.is_anthropic_bedrock_model
(fixed for the prompt-caching gate by the open #46297) and in
anthropic_adapter._is_bedrock_model_id (benign there — its dot-replace is
already guarded by startswith("claude-")). This fixes the cost-lookup copy #46297
doesn't touch.

Fix

  • agent/usage_pricing.py — add apac. and au. to the region-prefix strip
    list in _normalize_bedrock_model_name (+ docstring).

Tests

pytest tests/agent/test_usage_pricing.py -q27 passed. Extended the
existing test_bedrock_cross_region_profile_prefix_resolves_to_pricing to cover
apac./au.; revert the fix and it fails with scoped == None for apac.
(prices as unknown).

…nknown

_normalize_bedrock_model_name stripped ("us.", "global.", "eu.", "ap.",
"jp.") before the pricing lookup, but AWS Bedrock's Asia-Pacific
cross-region inference profiles are prefixed "apac." (and Australia
"au."), not "ap.". A bare "ap." never matches an "apac.*" id
(str.startswith stops at the 'a' where "ap." expects '.'), so
"apac.anthropic.claude-*" and "au.anthropic.claude-*" fell through with
the prefix intact, missed the bare "anthropic.claude-*" pricing key, and
every Asia-Pacific / Australia Bedrock session priced as "unknown" — no
cost estimate or tracking for two whole geographies, while us./eu./global.
worked.

Add "apac." and "au." to the strip list (mirrors the same fix landing in
bedrock_adapter.is_anthropic_bedrock_model via NousResearch#46297, which covers the
prompt-caching capability gate but not this duplicated cost-lookup copy).

Extends the existing cross-region pricing test to cover apac./au.; without
the fix it fails with scoped == None for "apac.".

@tonydwb tonydwb left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. No obvious issues found.


Reviewed by Hermes Agent

@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 area/billing Account usage, credit usage, billing (cross-cutting) P3 Low — cosmetic, nice to have labels Jul 16, 2026

@tonydwb tonydwb left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review Summary

Verdict: Comment

Summary

Fix: error envelope type mapping for codex. Ensures nested errors are properly surfaced in SSE responses.

Clean fix. No security concerns.


Reviewed by Hermes Agent

@teknium1 teknium1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for tracing the AU/APAC pricing miss and adding a focused regression case. Current main still has the reported defect at agent/usage_pricing.py:895.

Problems

  • The proposed tuple still leaves the same pricing failure class for ca., sa., me., and af. profiles. hermes_cli/model_setup_flows.py:36-38 identifies those as documented Bedrock cross-region prefixes, while _lookup_official_docs_pricing() only retries the bare pricing table after _normalize_bedrock_model_name() (agent/usage_pricing.py:933-940). Those unstripped IDs will still miss bare pricing keys.

Suggested changes

  • Expand the normalizer and this regression test to cover the complete documented prefix set, including ca., sa., me., and af..

Automated hermes-sweeper review.

Comment thread agent/usage_pricing.py
"""
name = model.lower().strip()
for prefix in ("us.", "global.", "eu.", "ap.", "jp."):
for prefix in ("us.", "global.", "eu.", "apac.", "ap.", "au.", "jp."):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still omits ca., sa., me., and af., although hermes_cli/model_setup_flows.py:36-38 identifies them as Bedrock cross-region prefixes. Because _lookup_official_docs_pricing() only retries with this normalized ID, those scoped models will continue to miss the bare pricing entries. Please cover the full prefix set here and in the regression test.

@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 area/usage-cost Token accounting, usage reporting, billing, cost tracking labels Jul 18, 2026
teknium1 added a commit that referenced this pull request Jul 20, 2026
The au./apac. additions from #46297 and #65973 covered
is_anthropic_bedrock_model and _normalize_bedrock_model_name; the same
prefix lists exist at two more sibling sites that would still miss
au./ca./sa./me./af. profiles:
- anthropic_adapter._looks_like_bedrock_model_id
- chat_completion_helpers (reasoning stale-timeout floor resolution)

All four sites now share the same 11-prefix set (global/us/eu/apac/ap/
au/jp/ca/sa/me/af, longest-first so apac. wins over ap.). The Bedrock
picker's BEDROCK_GEO_PREFIXES is deliberately untouched: au. absent
there fails open (profile shown), and adding it requires a region-to-geo
remap to avoid hiding Sydney profiles.
teknium1 added a commit that referenced this pull request Jul 20, 2026
The au./apac. additions from #46297 and #65973 covered
is_anthropic_bedrock_model and _normalize_bedrock_model_name; the same
prefix lists exist at two more sibling sites that would still miss
au./ca./sa./me./af. profiles:
- anthropic_adapter._looks_like_bedrock_model_id
- chat_completion_helpers (reasoning stale-timeout floor resolution)

All four sites now share the same 11-prefix set (global/us/eu/apac/ap/
au/jp/ca/sa/me/af, longest-first so apac. wins over ap.). The Bedrock
picker's BEDROCK_GEO_PREFIXES is deliberately untouched: au. absent
there fails open (profile shown), and adding it requires a region-to-geo
remap to avoid hiding Sydney profiles.
@teknium1

Copy link
Copy Markdown
Contributor

Merged via PR #68005 — your commit was cherry-picked onto current main with your authorship preserved (rebase merge), alongside #46297 (@jaketracey, June 14, the earliest report of this gap on the prompt-caching site). Your pricing-normalizer half was the missing piece there; the roster was also widened to two more sibling sites in the same pass. Thanks!

#68005

randlee pushed a commit to randlee/hermes-agent that referenced this pull request Aug 11, 2026
The au./apac. additions from NousResearch#46297 and NousResearch#65973 covered
is_anthropic_bedrock_model and _normalize_bedrock_model_name; the same
prefix lists exist at two more sibling sites that would still miss
au./ca./sa./me./af. profiles:
- anthropic_adapter._looks_like_bedrock_model_id
- chat_completion_helpers (reasoning stale-timeout floor resolution)

All four sites now share the same 11-prefix set (global/us/eu/apac/ap/
au/jp/ca/sa/me/af, longest-first so apac. wins over ap.). The Bedrock
picker's BEDROCK_GEO_PREFIXES is deliberately untouched: au. absent
there fails open (profile shown), and adding it requires a region-to-geo
remap to avoid hiding Sydney profiles.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/billing Account usage, credit usage, billing (cross-cutting) area/usage-cost Token accounting, usage reporting, billing, cost tracking comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P3 Low — cosmetic, nice to have 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.

4 participants