fix(bedrock): recognise au./apac. inference profiles to enable prompt caching - #46297
Closed
jaketracey wants to merge 1 commit into
Closed
fix(bedrock): recognise au./apac. inference profiles to enable prompt caching#46297jaketracey wants to merge 1 commit into
jaketracey wants to merge 1 commit into
Conversation
… caching is_anthropic_bedrock_model() strips a regional prefix before checking for "anthropic.claude" to route Claude through the AnthropicBedrock SDK path (prompt caching, thinking budgets) instead of the Converse path. The prefix list was missing "au." and "ap." does not match "apac.", so AU/APAC Claude inference profiles silently lost prompt caching. Add "apac." and "au.". Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
|
Thanks for identifying a real Bedrock routing gap. Current Problems
Suggested changes
Automated hermes-sweeper review. |
teknium1
pushed a commit
that referenced
this pull request
Jul 20, 2026
…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 #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.".
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
pushed a commit
that referenced
this pull request
Jul 20, 2026
…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 #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.".
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.
Contributor
|
Merged via PR #68005 — your commit was cherry-picked onto current main with your authorship preserved (rebase merge). You were the earliest submission for the au./apac. gap (June 14), and during salvage we found two more sibling sites with the same stale prefix list (the Bedrock-ID detector in anthropic_adapter and the reasoning-timeout resolver) — all four now share one roster. Thanks for the fix, prompt caching now works down under! |
randlee
pushed a commit
to randlee/hermes-agent
that referenced
this pull request
Aug 11, 2026
…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.".
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Claude models invoked on Amazon Bedrock through the Australia (
au.) or Asia-Pacific (apac.) cross-region inference profiles — e.g.au.anthropic.claude-haiku-4-5-20251001-v1:0,apac.anthropic.claude-sonnet-4-6— run without prompt caching, making multi-turn / agentic sessions far more expensive than they should be.Root cause
is_anthropic_bedrock_model()decides the routing fork: Claude models go through the AnthropicBedrock SDK path (full feature parity — prompt caching, thinking budgets, adaptive thinking), everything else through the Converse API path (nocache_controlsupport). It detects Claude by stripping a regional prefix and checking foranthropic.claude:This list is missing
au.entirely, andap.does not matchapac.("apac.anthropic…".startswith("ap.")isFalse). Soau.*andapac.*Claude profiles fall through to the Converse path and silently lose prompt caching.Fix
Add
"apac."and"au."to the prefix list (apac.beforeap.for clarity; they don't overlap functionally):Impact
Validated live on a real agentic session (SEO audit,
au.anthropic.claude-*) before vs after:cache_read_tokensi.e. the static system+tools prefix was being re-billed at full input price every turn instead of the ~10×-cheaper cache-read rate — a large, silent cost regression for AU/APAC Bedrock users.
Tests
Adds
test_au_inference_profileandtest_apac_inference_profiletoTestIsAnthropicBedrockModel, matching the existingtest_eu_claudestyle. No behaviour change for non-Anthropic models (Nova / DeepSeek / Llama / Mistral) or the existingus./global./eu.profiles.Notes
Discovered while deploying Hermes on Bedrock in
ap-southeast-2(Australia) for an AU-data-residency deployment. AWS added theau.(Sydney + Melbourne) inference profiles relatively recently; this just brings the detector in line. Worth auditing other prefix lists for the sameau./apac.gap.🤖 Generated with Claude Code