fix(pricing): strip apac./au. Bedrock region prefixes so cost isn't unknown - #65973
fix(pricing): strip apac./au. Bedrock region prefixes so cost isn't unknown#65973Drexuxux wants to merge 1 commit into
Conversation
…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
left a comment
There was a problem hiding this comment.
Looks good. No obvious issues found.
Reviewed by Hermes Agent
tonydwb
left a comment
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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., andaf.profiles.hermes_cli/model_setup_flows.py:36-38identifies 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., andaf..
Automated hermes-sweeper review.
| """ | ||
| name = model.lower().strip() | ||
| for prefix in ("us.", "global.", "eu.", "ap.", "jp."): | ||
| for prefix in ("us.", "global.", "eu.", "apac.", "ap.", "au.", "jp."): |
There was a problem hiding this comment.
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.
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.
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.
|
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! |
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.
What
_normalize_bedrock_model_namestripped("us.", "global.", "eu.", "ap.", "jp.")before the Bedrock pricing lookup, but AWS's Asia-Pacific cross-region inference
profiles are prefixed
apac.(and Australiaau.), notap.. A bareap.never matches anapac.*id ("apac.".startswith("ap.")isFalse), soapac.anthropic.claude-*/au.anthropic.claude-*kept the prefix, missed thebare
anthropic.claude-*pricing key, and every Asia-Pacific / Australia Bedrocksession 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 isalready guarded by
startswith("claude-")). This fixes the cost-lookup copy #46297doesn't touch.
Fix
agent/usage_pricing.py— addapac.andau.to the region-prefix striplist in
_normalize_bedrock_model_name(+ docstring).Tests
pytest tests/agent/test_usage_pricing.py -q→ 27 passed. Extended theexisting
test_bedrock_cross_region_profile_prefix_resolves_to_pricingto coverapac./au.; revert the fix and it fails withscoped == Noneforapac.(prices as unknown).