Repository navigation
feat(one-reason): support configuring model reasoning effort - #11
Merged
Merged
Conversation
Add REASONING_EFFORT (off/low/medium/high) to the env/config surface so callers can control model thinking without editing code. Resolved values are forwarded per provider: OpenAI-compatible gets the standard reasoning_effort body field (off -> none), native OpenAI gets reasoningEffort (off -> minimal), and Anthropic disables extended thinking or sets the reasoning effort parameter. ACP is explicitly unsupported. The CLI auth flow can persist REASONING_EFFORT and help/doc text documents the best-effort semantics and provider caveats.
Resolve both review findings in the Anthropic branch of the reasoning-effort
mapping:
- low/medium/high now enable thinking instead of only forwarding effort.
Claude 4.6+ and Claude 5 models get adaptive thinking plus the effort
parameter, while older Claude models get the legacy enabled + budgetTokens
form (2048/8192/16384 tokens per level). Effort never leaks into legacy
requests.
- off now reaches the API: bump @ai-sdk/anthropic to ^3.0.116 (>= 3.0.93) so
thinking: { type: "disabled" } is serialized instead of being dropped.
Add request-body regression tests that stub fetch and assert what the AI SDK
actually sends for anthropic, openai-compatible, and openai, and document the
per-generation Anthropic behavior in the README, .env.example, and --help.
Collaborator
Author
|
Addressed both P2 findings from the review. 1.
2.
Regression tests
|
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.
What
Adds support for configuring a model's reasoning/thinking effort through environment variables and
reason.json, without code changes:ONE_REASON_REASONING_EFFORT(fallbacks:ONE_REASONING_EFFORT, thenREASONING_EFFORTinreason.json)off,low,medium,high(unset = provider default)reason authcan now persistREASONING_EFFORT, and--help/README/.env.exampledocument itWhy
Most OpenAI-compatible reasoning APIs expose
reasoning_effort(plus vendor-specific fields), but the package previously had no way to set it. The fields are not universal, so the mapping is provider-aware and deliberately best-effort:low/medium/highreasoning_effort: low|medium|highreasoningEffort: low|medium|higheffort; older Claude models:enabled+ fixedbudgetTokens(2048/8192/16384)offreasoning_effort: "none"reasoningEffort: "minimal"thinking: { type: "disabled" }Anthropic handling is split by model generation because the two thinking modes are not interchangeable:
type: "enabled"+budgetTokensis rejected on Claude Opus 4.7+ / Claude 5, while Claude 4.6 and earlier have noeffortparameter, so each effort level maps to a fixed thinking budget.offalso requires@ai-sdk/anthropic>= 3.0.93 — earlier versions silently droppedthinking: { type: "disabled" }from the request, so thinking-stopped-by-default models like Sonnet 5 would keep thinking.Caveats documented in the README: some providers ignore
reasoning_effort(e.g., Zhipu GLM gates thinking via its ownthinking.type), and always-reasoning models (e.g., MiniMax M2) may reject or ignore the parameter. Use a non-thinking model when thinking must be guaranteed off.Verification
fetchand assert what the AI SDK actually sends foranthropic,openai-compatible, andopenai, coveringoff/low/medium/high, adaptive vs legacy Anthropic models, and gateway-prefixed model ids. TheoffAnthropic test fails against the previously locked@ai-sdk/anthropic@3.0.68.low/medium/high→ forwarded verbatim;off→"none"; genericONE_REASONING_EFFORTfallback works; uppercase values normalized; invalid values fail fast with a clear error.reason.jsonREASONING_EFFORT: "high"sendsreasoning_effort: "high"; settingONE_REASON_REASONING_EFFORT=offoverrides it to"none".kimi-k2.6:off≈ 2s,low/high≈ 21–25s, all returning schema-valid JSON.reasoning_effort=none, while Kimi K2.6 honors it; native OpenAI mapping verified against the pinned AI SDK schemas.pnpm --recursive typecheck,vitest run,oxfmt --check, and the one-reason build all pass.