Skip to content

fix(core): apply us-gov prefix for Bedrock models in GovCloud regions - #49055

Closed
jeff-armis wants to merge 3 commits into
anomalyco:devfrom
jeff-armis:fix-govcloud-bedrock-prefixes
Closed

jeff-armis wants to merge 3 commits into
anomalyco:devfrom
jeff-armis:fix-govcloud-bedrock-prefixes

Conversation

@jeff-armis

@jeff-armis jeff-armis commented Sep 14, 2026 •

Copy link
Copy Markdown

Issue for this PR

Closes #2481

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

PR #2495 attempted to fix GovCloud support but incorrectly prevented prefix application for GovCloud regions. AWS Bedrock requires us-gov. prefix for cross-region inference in GovCloud (similar to how commercial US regions need us. prefix).

The original fix detected GovCloud with if (requiresPrefix && !isGovCloud) which skipped prefixing entirely. This caused "invalid model identifier" errors.

This PR corrects the logic to apply us-gov. prefix for GovCloud regions and adds missing models (Grok, Nemotron) to the prefix list.

How did you verify your code works?

Manually tested with OpenCode built from source:

  1. GovCloud (us-gov-east-1): Grok and Claude models work correctly with us-gov. prefix
  2. Commercial (us-east-1): Claude works correctly with us. prefix
  3. Updated existing tests to expect correct GovCloud behavior

Screenshots / recordings

N/A - Backend logic change

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Fixes the incomplete fix from PR anomalyco#2495 which addressed issue anomalyco#2481.

PR anomalyco#2495 added GovCloud detection but prevented prefix application for
GovCloud regions, when they actually require the "us-gov." prefix.

Changes:
- Add "us-gov." to crossRegionPrefixes skip list (prevents double-prefixing)
- Add "grok" and "nemotron" to models requiring prefixes
- Apply "us-gov." prefix for GovCloud regions (was no prefix before)
- Update tests to expect correct us-gov. prefix behavior

Tested with both us-gov-east-1 (GovCloud) and us-east-1 (commercial).
@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. needs:issue labels Sep 14, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

The search found one potentially related PR:

PR #18948: fix(provider): prevent Bedrock from prefixing ARN and deepseek.v3.2 model IDs

This PR is related as it addresses prefix handling for Bedrock models, though it focuses on preventing prefixes for ARN and deepseek.v3.2 rather than applying the us-gov prefix for GovCloud regions. Both PRs deal with the core issue of correct model ID prefixing behavior in the Bedrock provider.

However, this appears to be a distinct fix for the incomplete solution from PR #2495, so PR #49055 doesn't appear to be a direct duplicate—it's a follow-up fix for issue #2481.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Sep 14, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@opencode-agent

Copy link
Copy Markdown
Contributor

This isn't mergeable as-is:

  • packages/opencode/src/provider/provider.ts still omits us-gov. from crossRegionPrefixes, so an explicitly prefixed us-gov.* model ID can be prefixed again.
  • Prefixing needs to remain model/region-specific. Nova Lite in GovCloud uses its bare in-region model ID rather than a us-gov. inference profile, while Nemotron in commercial US regions also uses its bare in-region ID. This change instead produces invalid us-gov.amazon.nova-* and us.nvidia.nemotron-* IDs.

Please split these cases and cover both provider paths with tests.

Cross-region inference profiles differ by partition. Verified against
the live Bedrock catalog (list-inference-profiles):
- GovCloud: us-gov. profiles exist for claude, grok, nemotron;
  nova has no us-gov. profile (bare in-region id).
- Commercial: us. profiles exist for nova, claude, deepseek.r1, grok;
  nemotron has no us. profile (bare in-region id).

Also add us-gov. to crossRegionPrefixes in packages/opencode provider
so an explicit us-gov.* id is not double-prefixed, and add GovCloud
coverage to the opencode provider test path.
@jeff-armis

Copy link
Copy Markdown
Author

Thanks — good catch. Verified against the live Bedrock catalog (aws bedrock list-inference-profiles) in both partitions and split the lists accordingly:

model commercial (us-east-1) govcloud (us-gov-east-1)
claude us. us-gov.
grok us. us-gov.
nova us. bare (no us-gov. profile)
nemotron bare (no us. profile) us-gov.
Changes:

  • GovCloud list is now claude, grok, nemotron; commercial keeps nova*, claude, deepseek.r1, grok. Nova stays bare in GovCloud and nemotron stays bare in commercial, matching the catalog.
  • Added us-gov. to crossRegionPrefixes in packages/opencode/src/provider/provider.ts so an explicit us-gov.* id is not double-prefixed.
  • Added GovCloud coverage to the opencode provider test path in addition to the core prefix-matrix table.

Thanks — good catch. Verified against the live Bedrock catalog (`aws bedrock list-inference-profiles`) in both partitions and split the lists accordingly:

model commercial (us-east-1) govcloud (us-gov-east-1)
claude `us.` `us-gov.`
grok `us.` `us-gov.`
nova `us.` bare (no `us-gov.` profile)
nemotron bare (no `us.` profile) `us-gov.`

Changes:

  • GovCloud list is now `claude, grok, nemotron`; commercial keeps `nova*, claude, deepseek.r1, grok`. Nova stays bare in GovCloud and nemotron stays bare in commercial, matching the catalog.
  • Added `us-gov.` to `crossRegionPrefixes` in `packages/opencode/src/provider/provider.ts` so an explicit `us-gov.*` id is not double-prefixed.
  • Added GovCloud coverage to the opencode provider test path in addition to the core prefix-matrix table.

@thdxr

thdxr commented Oct 10, 2026

Copy link
Copy Markdown
Member

This branch has been upgraded to V2. We're no longer taking PRs for V1. If you think this is still relevant, please port it over and open it for V2.

— from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊

@thdxr thdxr closed this Oct 10, 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.

Bedrock provider doesn't work with govcloud

2 participants