Skip to content

feat(ai): derive reasoning levels from provider metadata - #1258

Open
sethkarten wants to merge 3 commits into
mainfrom
feat/provider-thinking-level-metadata
Open

feat(ai): derive reasoning levels from provider metadata#1258
sethkarten wants to merge 3 commits into
mainfrom
feat/provider-thinking-level-metadata

Conversation

@sethkarten

@sethkarten sethkarten commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Summary

  • normalize OpenRouter reasoning metadata into exact model thinking-level maps, including sparse effort sets, mandatory reasoning, supported_efforts: null, and toggle-only models
  • apply those capabilities to both OpenRouter and Prime Inference generated models while preserving provider-specific transport overrides
  • distinguish omitted reasoning from explicit off, serialize OpenRouter effort/toggle payloads correctly, and keep explicit-off behavior safe across Anthropic, Bedrock, Google, and Vertex adapters
  • regenerate only reasoning-related catalog metadata and document the full off through max thinking-level surface

For qwen/qwen3.8-max, catalog generation now makes off unavailable, exposes xhigh, and keeps unsupported max hidden without a model-ID patch. It also fixes sparse Kimi/DeepSeek-style effort sets and models that expose only an enabled toggle.

Rebased after #1247; the committed Qwen 3.8 Max entry is retained as featured and now carries its provider-derived mandatory effort map.

Validation

  • npx tsgo --noEmit
  • AI suite excluding the separately occupied anthropic-oauth.test.ts: 323 passed, 727 skipped
  • agent suite: 70 passed
  • targeted reasoning/catalog/payload tests: 38 passed
  • npx biome check --error-on-warnings <modified files>
  • git diff --check

Scope

This PR covers reasoning capability discovery, UI level availability/clamping, and request selection. OpenRouter reasoning.max_tokens budgets and ordered reasoning_details replay are separate continuity/budget features and are intentionally not included here.


Note

Medium Risk
Changes how reasoning preferences are discovered and serialized for many OpenRouter/Prime Inference models, so incorrect maps or payload encoding could alter thinking behavior or break provider requests. No auth or data-handling changes.

Overview
Derives OpenRouter reasoning capabilities into exact thinkingLevelMaps, covering sparse effort sets, mandatory reasoning, toggle-only models, and supported_efforts: null. Generation applies this to both OpenRouter and Prime Inference catalogs, including supportsReasoningEffort: false where only an enabled toggle exists.

Fixes explicit off vs omitted reasoning. Agents now pass "off" through instead of dropping it. Anthropic, Bedrock, Google, and Vertex treat "off" as disabled. OpenAI-completions serializes OpenRouter payloads with effort when supported, otherwise { enabled: true/false }, and leaves omitted reasoning as the provider default.

Reviewed by Cursor Bugbot for commit 25cc883. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Derive reasoning levels and effort support from OpenRouter provider metadata

  • Adds getOpenRouterReasoningCapabilities which reads OpenRouter model metadata to produce a thinkingLevelMap, supportsReasoningEffort, and mandatory flag, replacing static per-model hardcoding.
  • Updates model generation scripts to call this function for both OpenRouter and Prime Inference models, populating thinkingLevelMap and setting supportsReasoningEffort: false where the provider does not expose effort selection.
  • Refactors buildParams in openai-completions.ts to correctly encode explicit reasoning on/off intent for OpenRouter-compatible models, using enabled toggles when effort selection is unsupported.
  • Fixes reasoning "off" handling across Anthropic, Google, and Bedrock providers, which previously treated explicit "off" as enabled.
  • Passes "off" reasoning through Agent.createLoopConfig to providers instead of dropping it silently.
  • Behavioral Change: models without effort selector support now send an enabled toggle rather than a reasoning_effort value; "off" now correctly disables thinking across all providers.

Changes since #1258 opened

  • Modified buildParams utility in the OpenAI completions provider to omit reasoning_effort parameter when reasoning is not explicitly disabled [25cc883]
  • Added test case in the OpenAI completions tool choice test suite to verify reasoning effort parameter behavior for Prime-inference models [25cc883]

Macroscope summarized c3b6e56.

@sethkarten
sethkarten force-pushed the feat/provider-thinking-level-metadata branch from 07ecc8e to c3b6e56 Compare August 11, 2026 20:21
eliebak
eliebak previously approved these changes Aug 11, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit c3b6e56. Configure here.

Comment thread packages/ai/src/providers/openai-completions.ts
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.

2 participants