Skip to content

fix(opencode): add thinking variants support for SAP AI provider#14958

Merged
rekram1-node merged 40 commits intoanomalyco:devfrom
jerome-benoit:fix/sap-ai-gemini-thinking-variants
Mar 10, 2026
Merged

fix(opencode): add thinking variants support for SAP AI provider#14958
rekram1-node merged 40 commits intoanomalyco:devfrom
jerome-benoit:fix/sap-ai-gemini-thinking-variants

Conversation

@jerome-benoit
Copy link
Contributor

@jerome-benoit jerome-benoit commented Feb 24, 2026

Issue for this PR

Closes #14957

Type of change

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

What does this PR do?

Adds proper thinking/reasoning variant support for SAP AI provider (@jerome-benoit/sap-ai-provider-v2), harmonized with existing transverse variant handling.

Changes:

  • Claude 4.6 models: Uses isAnthropicAdaptive detection (transverse variable at line 336) to apply { thinking: { type: "adaptive" }, effort } config, matching @ai-sdk/anthropic and @ai-sdk/amazon-bedrock implementations
  • Gemini 2.5 models: Applies { thinkingConfig: { includeThoughts: true, thinkingBudget } } with budget values matching @ai-sdk/google provider
  • GPT/o-series models: Applies { reasoningEffort } for OpenAI-compatible reasoning
  • Other models: Returns {} instead of incorrect reasoningEffort fallback

The implementation reuses existing constants (adaptiveEfforts, WIDELY_SUPPORTED_EFFORTS) and follows the established pattern from other provider cases.

How did you verify your code works?

  • Added unit tests for SAP AI provider variants (Claude 4.6 adaptive, Gemini 2.5, GPT, o-series)
  • All 110 tests pass
  • TypeScript compilation passes

Screenshots / recordings

N/A - no UI changes

Checklist

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

Copilot AI review requested due to automatic review settings February 24, 2026 21:58
@github-actions github-actions bot added needs:compliance This means the issue will auto-close after 2 hours. contributor labels Feb 24, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds support for Gemini 2.5 models' reasoning capabilities when accessed through SAP AI providers (@mymediset/sap-ai-provider and @jerome-benoit/sap-ai-provider-v2). Previously, these models fell through to a generic reasoningEffort fallback which doesn't work for Gemini models, which require the thinkingConfig format instead.

Changes:

  • Added Gemini 2.5 detection logic for SAP AI providers that returns thinkingConfig with thinkingBudget values matching the native @ai-sdk/google provider
  • Enables proper reasoning support for Gemini 2.5 Pro/Flash models when proxied through SAP AI Core

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@jerome-benoit jerome-benoit force-pushed the fix/sap-ai-gemini-thinking-variants branch 3 times, most recently from 419fcc2 to e82a204 Compare February 24, 2026 22:08
…iders

SAP AI providers now correctly handle Gemini 2.5 models with thinkingConfig
instead of falling back to reasoningEffort which doesn't work for Gemini.

Fixes anomalyco#14957
@jerome-benoit jerome-benoit force-pushed the fix/sap-ai-gemini-thinking-variants branch from e82a204 to 374b84e Compare February 24, 2026 22:13
@github-actions github-actions bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Feb 24, 2026
@github-actions
Copy link
Contributor

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

Use word boundary (\b) instead of --o pattern to correctly match o1, o3, o3-mini models.
@jerome-benoit jerome-benoit force-pushed the fix/sap-ai-gemini-thinking-variants branch from 74ded42 to 7b72411 Compare February 25, 2026 00:04
jerome-benoit and others added 5 commits February 25, 2026 13:53
…ovider

- Add isAnthropicAdaptive detection for Claude 4.6 models
- Keep Gemini 2.5 thinkingConfig support
- Keep GPT/o-series reasoningEffort support
- Return empty object for unsupported models instead of fallback
- Add unit test for Claude 4.6 adaptive thinking
@jerome-benoit jerome-benoit changed the title fix(opencode): add Gemini 2.5 thinkingConfig variants for SAP AI providers fix(opencode): add thinking variants support for SAP AI provider Feb 26, 2026
jerome-benoit added a commit to jerome-benoit/dotfiles that referenced this pull request Mar 2, 2026
… and bun provider tracking

Cherry-pick three upstream PRs:
- anomalyco/opencode#14958: add thinking variant support for SAP AI provider
- anomalyco/opencode#12822: remove Env namespace, use direct process.env access
- anomalyco/opencode#10275: track provider packages with reference counting for cleanup
@jerome-benoit
Copy link
Contributor Author

@rekram1-node @nexxeln: could you please have a look at that PR, since anomalyco/models.dev#1020 have been already merged.

Thanks.

@rekram1-node
Copy link
Collaborator

been on vacation for 2 weeks just got back

@rekram1-node rekram1-node merged commit 4dce485 into anomalyco:dev Mar 10, 2026
9 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 thinking variants for Gemini 2.5 and Claude 4.6

4 participants