fix(opencode): support sap-ai-core anthropic opus 4.7+ adaptive reasoning#29991
Merged
rekram1-node merged 7 commits intoMay 30, 2026
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #29990
Type of change
What does this PR do?
SAP AI Core (
@jerome-benoit/sap-ai-provider-v2) uses an inverted Anthropic naming conventionanthropic--claude-{N}.{M}-opus(family at the end), confirmed inSAP/ai-sdk-java(OrchestrationAiModel.CLAUDE_4_7_OPUS),SAP/ai-sdk-js(scripts/sap-models.json,model-types.ts), andmodels.dev(reasoning = true). The existinganthropicOpus47OrLaterregex requiredopus-BEFORE the version, so SAP Opus 4.7+ never matched, and the@jerome-benoit/sap-ai-provider-v2branch invariants()never spreaddisplay: "summarized".Three minimal in-place changes in
packages/opencode/src/provider/transform.ts:anthropicOpus47OrLaterregex with a second alternation arm matchingclaude-{N}.{M}-opus(and dash form). Single sharedmajor > 4 || (major === 4 && minor >= 7)comparison preserved.anthropicAdaptiveEffortssubstring list with4-6-opus,4.6-opus,4-6-sonnet,4.6-sonnetso SAP 4.6 also reaches the 4-effort adaptive path....(adaptiveOpus ? { display: "summarized" } : {})to the SAP anthropic adaptive branch, mirroring@ai-sdk/anthropicand@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 typecheckfrompackages/opencode— cleanbun test test/provider/transform.test.ts— 234/234 passdescribe("@jerome-benoit/sap-ai-provider-v2", ...)block:displaydisplay: "summarized"andxhighopus-4.7substring → 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