Skip to content

fix(opencode): support sap-ai-core anthropic opus 4.7+ adaptive reasoning#29991

Merged
rekram1-node merged 7 commits into
anomalyco:devfrom
jerome-benoit:fix/sap-ai-core-opus-47-adaptive
May 30, 2026
Merged

fix(opencode): support sap-ai-core anthropic opus 4.7+ adaptive reasoning#29991
rekram1-node merged 7 commits into
anomalyco:devfrom
jerome-benoit:fix/sap-ai-core-opus-47-adaptive

Conversation

@jerome-benoit
Copy link
Copy Markdown
Contributor

Issue for this PR

Closes #29990

Type of change

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

What does this PR do?

SAP AI Core (@jerome-benoit/sap-ai-provider-v2) uses an inverted Anthropic naming convention anthropic--claude-{N}.{M}-opus (family at the end), confirmed in SAP/ai-sdk-java (OrchestrationAiModel.CLAUDE_4_7_OPUS), SAP/ai-sdk-js (scripts/sap-models.json, model-types.ts), and models.dev (reasoning = true). The existing anthropicOpus47OrLater regex required opus- BEFORE the version, so SAP Opus 4.7+ never matched, and the @jerome-benoit/sap-ai-provider-v2 branch in variants() never spread display: "summarized".

Three minimal in-place changes in packages/opencode/src/provider/transform.ts:

  • Extend anthropicOpus47OrLater regex with a second alternation arm matching claude-{N}.{M}-opus (and dash form). Single shared major > 4 || (major === 4 && minor >= 7) comparison preserved.
  • Extend anthropicAdaptiveEfforts substring list with 4-6-opus, 4.6-opus, 4-6-sonnet, 4.6-sonnet so SAP 4.6 also reaches the 4-effort adaptive path.
  • Add ...(adaptiveOpus ? { display: "summarized" } : {}) to the SAP anthropic adaptive branch, mirroring @ai-sdk/anthropic and @ai-sdk/amazon-bedrock.

No new helpers extracted (style guide: no preemptive abstraction). The version-comparison logic stays in one place.

How did you verify your code works?

  • bun typecheck from packages/opencode — clean
  • bun test test/provider/transform.test.ts — 234/234 pass
  • 6 new tests in the existing describe("@jerome-benoit/sap-ai-provider-v2", ...) block:
    • opus 4.6 dot + dash → 4-effort adaptive without display
    • opus 4.7 dot + dash → 5-effort adaptive with display: "summarized" and xhigh
    • opus 4.8 dot → forward-compat regression
    • non-anthropic id with opus-4.7 substring → empty (defensive guard test)

To reproduce locally: configure SAP AI Core with anthropic--claude-4.7-opus, select reasoning. Before: budget-tokens fallback, 2 keys. After: adaptive, 5 keys, display: "summarized".

Screenshots / recordings

N/A — no UI changes.

Checklist

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

…ning

SAP AI Core uses inverted naming `anthropic--claude-{N}.{M}-opus` (family
at the end), which never matched the existing `opus-(\d+)[.-](\d+)` regex
or the `anthropicAdaptiveEfforts` substring list, and the SAP branch in
`variants()` did not spread `display: "summarized"` on opus 4.7+.

- Extend `anthropicOpus47OrLater` regex with a second alternation arm
  matching `claude-{N}.{M}-opus` (and dash form). Single shared
  major/minor comparison preserved.
- Extend `anthropicAdaptiveEfforts` substring list with the SAP-style
  `4-6-opus`, `4.6-opus`, `4-6-sonnet`, `4.6-sonnet` markers.
- Add `...(adaptiveOpus ? { display: "summarized" } : {})` spread to
  the `@jerome-benoit/sap-ai-provider-v2` anthropic adaptive branch,
  mirroring `@ai-sdk/anthropic` and `@ai-sdk/amazon-bedrock`.

Closes anomalyco#29990
Refactor the @jerome-benoit/sap-ai-provider-v2 describe block to use a
local sapModel() helper and parameterized loops, mirroring the
cloudflare-ai-gateway pattern in the same file. Reduces ~159 lines of
createMockModel boilerplate while preserving coverage.

- Adaptive cases (sonnet 4.6, opus 4.6/4.7/4.8, dot/dash formats)
  collapsed into a single parameterized loop with xhigh assertion gated
  on testCase.efforts.
- gpt / o-series collapsed into a small loop.
- sonar / mistral collapsed into a small loop.
- Non-anthropic opus-substring guard kept standalone to preserve its
  intent as a regression guard for the id.includes("anthropic") gate.
- sonnet 4 (budget tokens) and gemini 2.5 (thinkingConfig) kept
  standalone since their assertion shapes are unique.

No production code changes.
Mirror the dot+dash symmetry already in place for opus 4.6 and 4.7.
Addresses asymmetry flagged in PR anomalyco#29991 review.
@rekram1-node rekram1-node merged commit f4f508e into anomalyco:dev May 30, 2026
7 of 8 checks passed
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.

SAP AI provider missing adaptive reasoning + display:"summarized" for Anthropic Opus 4.7+

2 participants