Skip to content

fix(core): spell Claude variants for Bedrock application inference profile ARNs - #65472

Open
JamieJ5926 wants to merge 3 commits into
anomalyco:devfrom
JamieJ5926:fix/bedrock-claude-arn-variants
Open

JamieJ5926 wants to merge 3 commits into
anomalyco:devfrom
JamieJ5926:fix/bedrock-claude-arn-variants

Conversation

@JamieJ5926

@JamieJ5926 JamieJ5926 commented Nov 21, 2026 •

Copy link
Copy Markdown

Issue for this PR

Closes #53756

Type of change

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

What does this PR do?

For Bedrock, bedrockConverse decided Claude vs. Nova purely from id.includes("anthropic"). When model.modelID is an AWS application inference profile ARN (arn:aws:bedrock:us-east-1:123456789012:application-inference-profile/abc123) — the shape Bedrock returns for inference profiles — that check is false, so a Claude model got the Amazon Nova Converse spelling (reasoningConfig: { type: "enabled", maxReasoningEffort }) instead of Claude's thinking + output_config: { effort }. On top of that, claudeInfo only parsed modelID, so it could not recover the Claude family/version from model.family, which is where the ARN's target model is actually named (e.g. claude-sonnet-4-5 needs manual budget thinking; claude-opus-4-6 uses adaptive thinking).

Two changes in packages/core/src/variant.ts:

  • claudeInfo matches the family/version regexes against the model ID first and falls back to model.family when the ID carries no Claude version, so an ARN resolves manual vs. adaptive thinking from its family.
  • bedrockConverse treats a model as Claude when the ID mentions anthropic, when claudeInfo extracted a family, or when model.family names Claude.

Non-ARN IDs (e.g. us.anthropic.claude-...) take the same path as before because the ID match still wins; Nova IDs match nothing and keep reasoningConfig.

How did you verify your code works?

Added packages/core/test/variant.test.ts case "spells Claude variants for a Bedrock application inference profile ARN" covering effort, toggle and budget_tokens for families claude-opus-4-6, claude-sonnet-4-5 and claude, plus a Nova regression check.

Failing before the fix (ARN + claude-opus-4-6):

claude-opus-4-6 [{"id":"low","body":{"additionalModelRequestFields":{"reasoningConfig":{"type":"enabled","maxReasoningEffort":"low"}}}},{"id":"high","body":{"additionalModelRequestFields":{"reasoningConfig":{"type":"enabled","maxReasoningEffort":"high"}}}}]

Passing after:

claude-opus-4-6 [{"id":"low","body":{"additionalModelRequestFields":{"thinking":{"type":"adaptive","display":"summarized"},"output_config":{"effort":"low"}}}},{"id":"high","body":{"additionalModelRequestFields":{"thinking":{"type":"adaptive","display":"summarized"},"output_config":{"effort":"high"}}}}]

cd packages/core && bun test test/variant.test.ts:

 19 pass
 0 fail
 75 expect() calls
Ran 19 tests across 1 file. [127.00ms]

bun run typecheck in packages/core: ✓ No type errors in 1,968 files across 2 projects.

Screenshots / recordings

N/A

Checklist

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

Added by the opencode bot (AI-generated).

Related: #53751

…ofile ARNs

A Bedrock application inference profile ARN (arn:aws:bedrock:...:application-inference-profile/...)
carries no Anthropic marker and no Claude version, so bedrockConverse fell through to the
Amazon Nova reasoningConfig spelling for Claude models. claudeInfo also parsed only the
model ID, ignoring model.family, which names the Claude model an ARN points at.

- claudeInfo now falls back to matching model.family when the model ID carries no
  Claude family/version, so ARNs resolve manual vs adaptive thinking from the family.
- bedrockConverse detects Claude when the ID mentions anthropic, when claudeInfo
  extracted a family, or when model.family names Claude.

Source: none (new code)

Co-authored-by: Jo Hughes <284454611+JamieJ5926@users.noreply.github.com>

@opencodejr opencodejr Bot 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.

This fixes the main bug. With an ARN modelID and a Claude family, Bedrock variants now use Claude's thinking/output_config instead of Nova's reasoningConfig. I checked this by resolving variants for an ARN model with family claude-sonnet/claude-opus on the base and on this branch, and by running the new test against the base (it fails there) and on this branch (all 19 tests pass). tsc -b passes. I could not send a real Bedrock request.

Public API: unchanged. family is an existing model field. This only changes how it is read.

Concerns:

  • The claudeInfo fallback only helps if family includes a version such as claude-sonnet-4-5. Catalog families never do (claude-sonnet, claude-opus, ...). The issue's own setup (an ARN for Sonnet 4.5 with family: "claude-sonnet") still gets adaptive thinking, which that model needs replaced by a budget. The issue reporter noted the same thing in #53756. Either drop the fallback and keep the fix to the Claude check, or document that a versioned family is the way to pick budget thinking for a profile ARN. See the inline comment.
  • The new test can be trimmed. See the inline comment.

Related: #53751

Comment thread packages/core/src/variant.ts Outdated
// model.family, which names the Claude model an ARN points at.
const idMatch = match(id)
const { familyFirst, versionFirst } =
idMatch.familyFirst ?? idMatch.versionFirst ? idMatch : match(model.family ?? "")

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.

This fallback only matches a family that includes a version (claude-sonnet-4-5). Catalog and models.dev families never include one (claude-sonnet, claude-opus, claude-haiku). For the setup in #53756 (an ARN for Sonnet 4.5 with family: "claude-sonnet"), major is still NaN, so manual is false and Bedrock gets adaptive thinking for a 4.5 model. It also now applies to every caller of claudeInfo (Anthropic Messages, GitLab), not just Bedrock. I'd either drop it and keep the PR to the Claude check in bedrockConverse, or make the versioned-family convention explicit, e.g. documented with a test that uses the catalog-style claude-sonnet and shows what it produces.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Dropping the fallback — the first option. Reproduced the concern first on 96beccd, with the issue's own setup (the #53756 ARN for Sonnet 4.5, catalog-style family: "claude-sonnet"):

$ bun test test/variant-arn-repro.test.ts   # packages/core
(fail) repro: ARN with versionless family claude-sonnet still gets adaptive thinking [0.93ms]
  - Expected  - 0
  + Received  + 4
        "body": {
          "additionalModelRequestFields": {
            "output_config": {
              "effort": "low",
            },
+           "thinking": {
+             "display": "summarized",
+             "type": "adaptive",
+           },

As you said: the regexes need a version, so major stays NaN, manual is false, and Bedrock got adaptive thinking for a 4.5 model.

4b0e6d0 removes the fallback: claudeInfo is back to parsing the model ID only (so Anthropic Messages and GitLab callers are unaffected), and the fix stays scoped to the Claude check in bedrockConverse, where model.family now only detects Claude — a comment there states that the family's version is never parsed. Stated plainly, the resulting behavior for a profile ARN: the family switches the spelling from Nova's reasoningConfig to Claude's, and with a versionless family that spelling is adaptive effort, never budget thinking.

Comment thread packages/core/test/variant.test.ts Outdated
{ id: "low", body: { additionalModelRequestFields: { output_config: { effort: "low" } } } },
])

expect(resolve(arnModel("claude"), [{ type: "toggle" }])).toEqual([

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.

The test can be shorter. The claude toggle and budget cases only exercise branches that already follow from claude being true. The Nova check below is already covered by the existing "spells Bedrock Converse effort for Grok and Nova" test. One effort assertion with the catalog-style family (claude-sonnet) would test what users actually configure, plus a versioned one if you keep the fallback.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Shortened to one effort assertion with the catalog-style family, per your note (3bfa08a):

test("spells Claude variants for a Bedrock application inference profile ARN", () => {
  const arn = "arn:aws:bedrock:us-east-1:123456789012:application-inference-profile/abc123"
  // The ARN carries no Anthropic marker, so model.family detects Claude; the ARN carries no
  // Claude version either, so the effort spelling is adaptive rather than budget thinking.
  expect(
    resolve(model("@opencode/ai/providers/amazon-bedrock", arn, undefined, "test", "claude-sonnet"), [
      { type: "effort", values: ["low"] },
    ]),
  ).toEqual([
    {
      id: "low",
      body: {
        additionalModelRequestFields: {
          thinking: { type: "adaptive", display: "summarized" },
          output_config: { effort: "low" },
        },
      },
    },
  ])
})

The claude toggle and budget cases are gone, and the Nova contrast is dropped — it is already covered by "spells Bedrock Converse effort for Grok and Nova". 53 lines → 20.

$ bun test test/variant.test.ts   # packages/core
 19 pass
 0 fail
 71 expect() calls
Ran 19 tests across 1 file. [162.00ms]

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.

Thanks. I checked the trimmed test at 3bfa08a: it fails on the base (Nova reasoningConfig) and passes here, and it's a clear check of the fixed behaviour. Nothing more needed on the test from my side.

Review 6008486374 on PR 65472: the family fallback in claudeInfo only
matches versioned families, so the issue's own setup - a Bedrock
application inference profile ARN for Sonnet 4.5 with the versionless
family "claude-sonnet" - still spelled adaptive thinking for a model
that takes budget thinking. Drop the fallback: claudeInfo parses the
model ID only, and the PR's fix stays scoped to the Claude check in
bedrockConverse, where model.family only detects Claude and never
resolves manual vs adaptive thinking.

The ARN test keeps the issue's setup (adaptive Claude spelling, not
Nova reasoningConfig) plus the Nova contrast, and drops the three
assertions that only pinned the fallback.

Source: none (new code)

Co-authored-by: Jo Hughes <284454611+JamieJ5926@users.noreply.github.com>
…mily case

Review 4655210470: the Nova contrast is already covered by the existing
"spells Bedrock Converse effort for Grok and Nova" test. One effort
assertion with the catalog-style family "claude-sonnet" is what users
actually configure.

Source: none (new code)

Co-authored-by: Jo Hughes <284454611+JamieJ5926@users.noreply.github.com>

@opencodejr opencodejr Bot 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.

My earlier concerns are resolved. The claudeInfo fallback is gone, so it is identical to the base again and the Anthropic Messages and GitLab callers are unaffected. The test is now one clear catalog-style case. I checked that the new test fails on the base (Nova reasoningConfig) and passes here, the whole variant test file passes (19 tests), and tsc -b is clean. I could not send a real Bedrock request.

Public API: unchanged. The existing family model field is only read here to detect Claude.

The remaining limitation is the one now stated in the code comment, and I don't think it blocks this fix. With a versionless family, a Claude 4.5-or-older model behind an ARN gets adaptive thinking instead of a token budget. For that case, the workarounds in #53756 still apply: use the catalog id as the model key, or declare variants explicitly.

Related: #53751

This branch has not been deployed

No deployments
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.

[V2] Bedrock application inference profile ARN gets Nova-format effort variants for Claude models

1 participant