-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
bugSomething isn't workingSomething isn't workingcoreAnything pertaining to core functionality of the application (opencode server stuff)Anything pertaining to core functionality of the application (opencode server stuff)
Description
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-1returns:deepseek.v3.2deepseek.r1-v1:0
aws bedrock-runtime converse --region us-east-1 --model-id deepseek.v3.2 ...succeedsaws bedrock-runtime converse --region us-east-1 --model-id arn:aws:bedrock:us-east-1::foundation-model/deepseek.v3.2 ...succeedsaws 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.deventry isproviders/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 frommodels.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 aus.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.2or 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
- Configure Amazon Bedrock in OpenCode with access to
DeepSeek V3.2. - Use region
us-east-1. - Select
amazon-bedrock/deepseek.v3.2. - Send a prompt.
- Observe the request fails with:
undefined: The provided model identifier is invalid.
Additional repro:
- Define a custom Bedrock model whose
idis:arn:aws:bedrock:us-east-1::foundation-model/deepseek.v3.2
- Run:
opencode run hi --model amazon-bedrock/deepseek-v3.2-arn --print-logs
- Observe OpenCode rewrites it to:
us.arn:aws:bedrock:us-east-1::foundation-model/deepseek.v3.2
- Bedrock rejects it with:
The provided model identifier is invalid.
(edited out duplicated text)
Screenshot and/or share link
Operating System
Pop!_OS 24.04 LTS
Terminal
Kitty, Cosmic, Ghosty
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingcoreAnything pertaining to core functionality of the application (opencode server stuff)Anything pertaining to core functionality of the application (opencode server stuff)