Skip to content

Amazon Bedrock rewrites deepseek.v3.2 and foundation-model ARNs to invalid us.* model IDs #18812

@KissingerGPT

Description

@KissingerGPT

Description

Amazon Bedrock model IDs are being rewritten incorrectly in OpenCode before the request is sent to Bedrock.

This breaks DeepSeek V3.2 specifically, and also breaks foundation-model ARNs.

What I verified locally:

  • aws bedrock list-foundation-models --by-provider deepseek --region us-east-1 returns:
    • deepseek.v3.2
    • deepseek.r1-v1:0
  • aws bedrock-runtime converse --region us-east-1 --model-id deepseek.v3.2 ... succeeds
  • aws bedrock-runtime converse --region us-east-1 --model-id arn:aws:bedrock:us-east-1::foundation-model/deepseek.v3.2 ... succeeds
  • aws bedrock-runtime converse --region us-east-1 --model-id us.deepseek.v3.2 ... fails with:
    • ValidationException: The provided model identifier is invalid.
  • aws bedrock-runtime converse --region us-east-1 --model-id us.arn:aws:bedrock:us-east-1::foundation-model/deepseek.v3.2 ... also fails with the same validation error

What OpenCode is doing:

  • My selected model is deepseek.v3.2
  • The models.dev entry is providers/amazon-bedrock/models/deepseek.v3.2.toml
  • But OpenCode sends Bedrock requests to:
    • https://bedrock-runtime.us-east-1.amazonaws.com/model/us.deepseek.v3.2/converse-stream
  • If I override the model ID to a full foundation-model ARN, OpenCode sends:
    • https://bedrock-runtime.us-east-1.amazonaws.com/model/us.arn%3Aaws%3Abedrock%3Aus-east-1%3A%3Afoundation-model%2Fdeepseek.v3.2/converse-stream

I traced this to OpenCode source:

  • fromModelsDevModel() preserves the raw model ID from models.dev:
    • packages/opencode/src/provider/provider.ts#L839-L847
  • The rewrite happens later in the Bedrock loader:
    • packages/opencode/src/provider/provider.ts#L316-L346
  • In the US-region branch, OpenCode treats "deepseek" as a model family that always requires a us. prefix:
    • packages/opencode/src/provider/provider.ts#L333-L345
  • There is no guard for ARNs, so ARNs also get prefixed.
  • The existing tests appear to cover prefixed cross-region Bedrock models, but not deepseek.v3.2 or foundation-model ARNs:
    • packages/opencode/test/provider/amazon-bedrock.test.ts#L238-L447

This looks like a Bedrock model-ID transformation bug in OpenCode, not a models.dev issue.

Plugins

oh-my-opencode-slim (disabled and removed in testing)

OpenCode version

1.3.0

Steps to reproduce

  1. Configure Amazon Bedrock in OpenCode with access to DeepSeek V3.2.
  2. Use region us-east-1.
  3. Select amazon-bedrock/deepseek.v3.2.
  4. Send a prompt.
  5. Observe the request fails with:
    • undefined: The provided model identifier is invalid.

Additional repro:

  1. Define a custom Bedrock model whose id is:
    • arn:aws:bedrock:us-east-1::foundation-model/deepseek.v3.2
  2. Run:
    • opencode run hi --model amazon-bedrock/deepseek-v3.2-arn --print-logs
  3. Observe OpenCode rewrites it to:
    • us.arn:aws:bedrock:us-east-1::foundation-model/deepseek.v3.2
  4. Bedrock rejects it with:
    • The provided model identifier is invalid.

(edited out duplicated text)

Screenshot and/or share link

Image Image

Operating System

Pop!_OS 24.04 LTS

Terminal

Kitty, Cosmic, Ghosty

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingcoreAnything pertaining to core functionality of the application (opencode server stuff)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions