Skip to content

fix(weave): map Bedrock Nova region prefix ap to apac - #7677

Open
feiiiiii5 wants to merge 1 commit into
wandb:masterfrom
feiiiiii5:fix/bedrock-nova-apac-region-prefix
Open

fix(weave): map Bedrock Nova region prefix ap to apac#7677
feiiiiii5 wants to merge 1 commit into
wandb:masterfrom
feiiiiii5:fix/bedrock-nova-apac-region-prefix

Conversation

@feiiiiii5

Copy link
Copy Markdown

Root Cause

In _setup_provider_credentials_and_model, Nova models on Bedrock get the cross-region inference geography prefixed onto the model name:

aws_inference_region = aws_region_name.split("-")[0]
inputs.model = "bedrock/" + aws_inference_region + "." + inputs.model

Asia-Pacific regions start with ap (e.g. ap-southeast-1), but Bedrock cross-region inference profile IDs use the apac geography prefix. So Nova calls from any ap-* region became bedrock/ap.amazon.nova-* and never matched the cost table (which only carries apac.amazon.nova-* keys), silently losing token/cost tracking (issue #7325). us-*/eu-* worked by coincidence because their first segment already equals their geography prefix.

Fix

Map the region's first segment to the geography prefix; only ap needs remapping to apac (US/EU already match):

region_prefix = aws_region_name.split("-")[0]
aws_inference_region = "apac" if region_prefix == "ap" else region_prefix

Test

New tests/trace_server/test_llm_completion_bedrock.py:

  • us-east-1bedrock/us.amazon.nova-lite-v1:0
  • eu-west-1bedrock/eu.amazon.nova-lite-v1:0
  • ap-southeast-1 / ap-northeast-1bedrock/apac.amazon.nova-lite-v1:0
  • a non-Nova model is left untouched

Verified locally against the real llm_completion.py code with get_bedrock_credentials patched: 5 passed.

Diff scope

2 files, +33/-1: weave/trace_server/llm_completion.py, tests/trace_server/test_llm_completion_bedrock.py.

AI Disclosure

AI-assisted root-cause analysis, initial draft, and test scaffolding; human review of the geography mapping and cost-table keys.

Not PR-related failures

None; the new tests pass locally (litellm emits an unrelated cost-map fetch timeout warning during import, falling back to its local backup).

For Nova models on Bedrock, the model name is prefixed with the
cross-region inference geography derived from the AWS region name
(aws_region_name.split('-')[0]). Asia-Pacific regions start with 'ap'
(e.g. ap-southeast-1), but the Bedrock inference profile geography is
'apac', so Nova calls from ap-* regions were emitted as
bedrock/ap.amazon.nova-* and never matched the cost table.

Map the 'ap' prefix to 'apac'; us/eu and other geographies are
unchanged. Add regression tests covering us/eu/ap regions and a
non-Nova model.

Closes wandb#7325

Signed-off-by: fei <204683769+feiiiiii5@users.noreply.github.com>
@feiiiiii5
feiiiiii5 requested a review from a team as a code owner August 1, 2026 05:22
@github-actions

github-actions Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@feiiiiii5 feiiiiii5 changed the title fix(llm_completion): map Bedrock Nova region prefix ap to apac fix(weave): map Bedrock Nova region prefix ap to apac Aug 1, 2026
@feiiiiii5

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

github-actions Bot added a commit that referenced this pull request Aug 1, 2026
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