Skip to content

fix: preserve Bedrock DeepSeek model ids - #34441

Merged
rekram1-node merged 5 commits into
anomalyco:devfrom
YeEmrick:bedrock-deepseek-id
Sep 8, 2026
Merged

rekram1-node merged 5 commits into
anomalyco:devfrom
YeEmrick:bedrock-deepseek-id

Conversation

@YeEmrick

@YeEmrick YeEmrick commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Issue for this PR

Closes #34412
Related #18812

Type of change

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

What does this PR do?

Bedrock DeepSeek model IDs were being treated like generic cross-region model IDs. That changed deepseek.v3.2 into us.deepseek.v3.2, which Bedrock rejects for the on-demand model.

This PR keeps explicit Bedrock model identifiers intact:

  • deepseek.v3.2 stays deepseek.v3.2
  • arn:aws:bedrock:...:foundation-model/... stays unchanged
  • already-prefixed profile IDs like us.deepseek.r1-v1:0 still pass through unchanged

How did you verify your code works?

Tested:

  • cd packages/opencode && bun test test/provider/amazon-bedrock.test.ts
  • cd packages/core && bun typecheck
  • git diff --check

Reviewer can confirm by configuring amazon-bedrock/deepseek.v3.2 and checking that the provider receives deepseek.v3.2, not us.deepseek.v3.2.

Local note: cd packages/core && bun test test/plugin/provider-amazon-bedrock.test.ts currently fails before this PR assertions with Cannot access 'AmazonBedrockPlugin' before initialization.

Screenshots / recordings

N/A, provider behavior only.

Checklist

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

If you do not follow this template your PR will be automatically rejected.

@github-actions github-actions Bot added needs:issue needs:compliance This means the issue will auto-close after 2 hours. labels Jun 29, 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:

Potential Duplicate Found

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

This appears to be directly related to the current PR #34441. Both PRs address the same issue of preserving Bedrock DeepSeek model IDs (preventing prefixing/normalization that shouldn't happen).

You should check if PR #18948 was previously closed or if this is addressing a regression or incomplete fix.

@github-actions github-actions Bot removed needs:compliance This means the issue will auto-close after 2 hours. needs:issue labels Jun 29, 2026
@github-actions

Copy link
Copy Markdown
Contributor

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

@YeEmrick

Copy link
Copy Markdown
Contributor Author

Updated after rechecking the Bedrock DeepSeek R1 profile behavior.

This PR now preserves the intended split:

  • deepseek.v3.2 passes through unchanged.
  • Bedrock foundation-model ARNs pass through unchanged.
  • Already-prefixed profiles like us.deepseek.r1-v1:0 pass through unchanged.
  • Unprefixed deepseek.r1-v1:0 in us-* regions still resolves to us.deepseek.r1-v1:0.

This is related to #18948, but this PR also covers the current packages/core/src/plugin/provider/amazon-bedrock.ts plugin path in addition to the legacy packages/opencode/src/provider/provider.ts path.

Verified locally:

  • cd packages/opencode && bun test test/provider/amazon-bedrock.test.ts
  • cd packages/core && bun typecheck
  • git diff --check

Known unrelated local blockers while testing broader gates:

  • cd packages/core && bun test test/plugin/provider-amazon-bedrock.test.ts still fails before assertions with Cannot access 'AmazonBedrockPlugin' before initialization.
  • cd packages/opencode && bun typecheck fails in unchanged src/bus/global.ts EventEmitter typing.

@Robin1987China Robin1987China left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. The narrowing from "deepseek" to "deepseek.r1" correctly distinguishes cross-region inference profiles (R1) from on-demand models (V3.2). The arn: guard is a solid defensive addition — foundation-model ARNs should never be region-prefixed.

One non-blocking note: if Bedrock adds DeepSeek R2 models that also require cross-region profiles, the requiresPrefix list will need updating. The narrow match is the safer choice for now.

@github-actions

Copy link
Copy Markdown
Contributor

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

@marc-jan

marc-jan commented Aug 1, 2026

Copy link
Copy Markdown

Can this be re-opened and merged? It was already reviewed, but now closed. It is still a problem if you are stuck with AWS and need to use bedrock.

@rekram1-node rekram1-node reopened this Sep 6, 2026
@rekram1-node
rekram1-node merged commit ac1758c into anomalyco:dev Sep 8, 2026
8 checks passed
1056674754 added a commit to 1056674754/opencode that referenced this pull request Sep 9, 2026
Upstream v1.18.29 (1674747, merged at 18a4845) -> v1.18.30 (3104c14),
28 commits / 105 files. Staged delta vs pre-merge fork HEAD is identical to
the upstream tag-to-tag diff (105 files, +1676/-403), confirming a clean
adoption.

Functional changes:
- feat(opencode): port Astra system prompt from v2 (anomalyco#48057) — new
  session/prompt/gpt-astra.txt wired through system.ts; fork's system
  transforms live in the openchamber plugin, no overlap.
- fix: preserve Bedrock DeepSeek model ids (anomalyco#34441) — provider.ts Bedrock
  loader passes arn: model ids through unmodified and tightens the
  cross-region prefix match from "deepseek" to "deepseek.r1"; inside the
  custom Azure/Bedrock loader region, disjoint from the fork snapshot
  architecture.
- fix(provider): preserve explicit OpenAI service tiers (anomalyco#47671).
- fix(opencode): add GitLab reasoning variants (anomalyco#47306) — transform.ts
  reasoningEffort now routes gitlab gpt-family to reasoningEffort and
  claude-family to adaptive thinking; disjoint from the fork GLM/ZhiPu
  normalization block, which remains intact (+77 fork-only lines).
- SDK bumps: @ai-sdk/openai 3.0.88, @ai-sdk/azure 3.0.93,
  gitlab-ai-provider 6.15.0 (8 packages installed via bun install).
- console: oauth client metadata document (anomalyco#47737), Chatwoot enterprise
  form (anomalyco#47488), openai usage normalization + tier threshold (anomalyco#47342),
  localized refund FAQs, zen model table updates (muse spark); go.mdx
  client session compatibility docs incl. zh translation.

Conflicts resolved: 29 package.json version bumps (rebranded 1.18.30-sscity
with a version-generic pattern after the v1.18.27 incident), bun.lock (took
upstream, rebranded workspace entries via bun install). Fork deltas
verified intact vs v1.18.30: ProviderSnapshot architecture (+492 in
provider.ts), deferred snapshot init, GLM normalization (+77 in
transform.ts), config getFresh/commitFresh (+14). Tests: provider,
transform, bedrock, config, v2, azure plugin, session retry/llm — 1058
pass / 0 fail across 15 files (22 new upstream tests included); typecheck
clean.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
alltomatos added a commit to alltomatos/opencode that referenced this pull request Sep 15, 2026
…ck ARN/DeepSeek ids

Two small upstream fixes to the opencode/provider/provider.ts "custom"
loaders and shared wrapSSE helper, both completing partial ports that
this fork's core-package copies already received but this file's
duplicated logic missed:

1. wrapSSE(): the timeout path called `void reader.cancel(err)`,
   leaving an unhandled promise rejection when the underlying stream
   had already errored. core/aisdk.ts's copy of this function was
   already fixed (commit ac3b15b); this completes the port for the
   near-duplicate copy here. Ported from upstream ac1758c -> no,
   from upstream 69c172e ("fix(provider): handle SSE reader cancel
   rejections (anomalyco#44944)").

2. amazon-bedrock custom loader's getModel(): double-prefixed full
   Bedrock ARNs (`arn:...`, which Bedrock rejects with a prefix) and
   over-matched "deepseek" (prefixing non-R1 DeepSeek models that
   don't support cross-region inference). The core Bedrock plugin
   (packages/core/src/plugin/provider/amazon-bedrock.ts) already got
   this fix (commit d66cefe); this completes the port for the
   legacy "custom" loader's own copy of the same logic. Ported from
   upstream ac1758c ("fix: preserve Bedrock DeepSeek model ids
   (anomalyco#34441)").

Verified via manual `tsgo --noEmit` on packages/core and
packages/opencode (clean) and oxlint on the changed file (0 errors,
pre-existing warnings only, none on changed lines). Full monorepo
`bun turbo typecheck` cannot run in this sandbox because three
unrelated packages (console-support, console-app, stats-app) depend
on `@solidjs/start` pinned to a pkg.pr.new preview build blocked by
this environment's network policy — a known, previously-documented
sandbox limitation (see fork-expert skill's upstream-sync.md), not a
regression from this change. The equivalent "typecheck" GitHub Actions
check passed clean on PR #234, which hit the same sandbox limitation
for its own real-code changes.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SHQKcGH7ayRe8UHJ9CAPQJ
logic10492 added a commit to coding-chimera/chimera that referenced this pull request Sep 17, 2026
Port upstream opencode ac1758c0e6 (anomalyco/opencode#34441), provider.ts
hunks only: pass arn: model references through untouched, and narrow the
us-region cross-region prefix list from bare "deepseek" to
"deepseek.r1" so non-r1 DeepSeek ids (e.g. deepseek.v3.2) are no longer
over-prefixed into us.deepseek.v3.2. Upstream's second landing site
(core/src/plugin/provider/amazon-bedrock.ts resolveModelID) does not
exist in this fork; the fork's mantle path
(selectBedrockMantleLanguageModel) does no region prefixing, so no
mantle-side change applies. Adds the upstream test matrix (bare v3.2,
r1 prefixing, pre-prefixed profile id, arn passthrough) adapted to the
fork's WithInstance/AppRuntime test shape.

Upstream-Sha: ac1758c0e6
rossigee pushed a commit to rossigee/opencode that referenced this pull request Sep 18, 2026
Co-authored-by: yeqisong <yeqisong@authing.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bedrock DeepSeek V3.2 uses incorrect model ID (us.deepseek.v3.2) instead of deepseek.v3.2 in v1.17.11

4 participants