anomalyco / anomalyco/opencode

Amazon Bedrock provider: DeepSeek V3/V3.1/V3.2 broken by incorrect "us." cross-region prefix in resolveModelID

Open
#43,679 2 comments 1 reaction 1 assignee View on GitHub

@nexxeln is already working on this.

Since Aug 20, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Description

The built-in Amazon Bedrock provider plugin (packages/core/src/plugin/provider/amazon-bedrock.ts, function resolveModelID) unconditionally prepends a cross-region-inference prefix (us./eu./etc.) to any Bedrock model id containing the substring "deepseek":

if (regionPrefix === "us") {
  const requiresPrefix = ["nova-micro", "nova-lite", "nova-pro", "nova-premier", "nova-2", "claude", "deepseek"].some(
    (item) => modelID.includes(item),
  )
  if (requiresPrefix && !resolvedRegion.startsWith("us-gov")) return `${regionPrefix}.${modelID}`
  return modelID
}

This is correct for DeepSeek-R1, which has a real cross-region inference profile on Bedrock (us.deepseek.r1-v1:0). It is incorrect for DeepSeek V3 / V3.1 / V3.2, which AWS only exposes via their bare foundation-model id — there is no cross-region inference profile for these models. deepseek.v3.2 becomes us.deepseek.v3.2, which does not exist in Bedrock, so AWS rejects it.

Expected behavior

Request is sent to Bedrock with modelId: "deepseek.v3.2".

Actual behavior

resolveModelID rewrites it to us.deepseek.v3.2 before calling sdk.languageModel(...). Bedrock returns:
undefined: The provided model identifier is invalid.

Root cause

The requiresPrefix check does a blanket .includes("deepseek") instead of distinguishing DeepSeek-R1 (needs the prefix) from every other DeepSeek family model (must NOT be prefixed). Per AWS's Bedrock DeepSeek docs, V3.1/V3.2 are on-demand, in-region-only models invoked by their bare foundation-model id; only R1 has a documented cross-region inference profile.

Suggested fix

Narrow the match, e.g.:

const requiresPrefix = ["nova-micro", "nova-lite", "nova-pro", "nova-premier", "nova-2", "claude", "deepseek.r1", "deepseek-r1"].some(
  (item) => modelID.includes(item),
)

(or an explicit allow-list of the DeepSeek variants that actually have a cross-region profile, since this could grow/change as AWS adds inference profiles for other DeepSeek releases).

Workarounds attempted (both dead ends)
  1. Route the model through @ai-sdk/amazon-bedrock/mantle (via a models override with "provider": {"npm": "@ai-sdk/amazon-bedrock/mantle"}) to skip resolveModelID entirely — it does bypass the bug (confirmed via source: the mantle branch returns early before calling resolveModelID), but selectMantleModel hardcodes every model except openai.gpt-oss-safeguard-20b/120b to sdk.responses(modelID). Bedrock Mantle rejects DeepSeek on that surface:
    The model 'deepseek.v3.2' does not support the '/v1/responses' API
    (This is a second, related bug: selectMantleModel should route DeepSeek — and likely other non-OpenAI families — through sdk.chat() instead of defaulting to sdk.responses().)

  2. User-space plugin registering an aisdk.language hook to rebuild the language model from the untouched bare id: fails to load with error="Plugin export is not a function". The ctx.aisdk.language/ctx.catalog.transform hook system (@opencode-ai/plugin/v2/promise) is real and used internally by ProviderPlugins, but the documented local/npm plugin loader (.opencode/plugins/, ~/.config/opencode/plugins/) only accepts the older plugin shape (async ({project, client, $, directory, worktree}) => ({...hooks})), which has no hook capable of intercepting model-id resolution or the outgoing AI SDK request. So there is currently no way to work around this from user config or a user plugin — it requires a source fix.

Plugins

No response

OpenCode version

1.18.19

Steps to reproduce
  1. Configure the amazon-bedrock provider with region us-east-1 (or any us-* region; this is also the fallback default when no region is configured).
  2. Select the deepseek.v3.2 model (present in the built-in catalog: confirmed via opencode models amazon-bedrock, which lists amazon-bedrock/deepseek.v3.2 as a distinct bare-id entry alongside amazon-bedrock/us.deepseek.r1-v1:0).
  3. Send any message.
Screenshot and/or share link

No response

Operating System

Windows 11

Terminal

Windows Terminal

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.