Loading
feat(agentic): add configurable reasoning controls
This supersedes !32 (closed). I am resubmitting the change from my personal GitLab account so the contribution is associated with the correct account. This MR includes the fixes for all four review threads resolved on the original MR, plus the follow-up model support updates described below.
Summary
Adds configurable reasoning/thinking controls to agentic chat models, with model-level defaults and per-call overrides through providerOptions.gitlab.
OpenAI models
reasoningEffort(none|minimal|low|medium|high|xhigh|max). Serialized asreasoning: { effort }on the Responses API models and asreasoning_efforton the Chat Completions models, so the option applies to every OpenAI model family rather than being silently dropped on Chat Completions.
Anthropic Messages models
thinkingas a discriminated union:{ type: 'disabled' }{ type: 'enabled', budgetTokens }->thinking: { type: 'enabled', budget_tokens }{ type: 'adaptive', effort }->thinking: { type: 'adaptive' }plus a siblingoutput_config: { effort }
Adaptive is required by effort-based models such as Claude Opus 4.8, which reject thinking.type.enabled with: "thinking.type.enabled" is not supported for this model. Use "thinking.type.adaptive" and "output_config.effort" to control thinking behavior.
Behavior
- Model defaults plus per-call overrides via
providerOptions.gitlab(per-call wins). - Controls serialized in both streaming and non-streaming requests.
- OpenAI and Anthropic controls stay isolated to their model families.
- When Anthropic thinking is active (
enabledoradaptive),temperatureis dropped and an out-of-rangetop_pis omitted, since Anthropic rejects those while thinking is engaged and would otherwise return a400. - Anthropic
thinkingandredacted_thinkingresponse blocks are surfaced asreasoningcontent, carrying the block signature underproviderOptions.gitlab, and replayed unmodified on later turns as required during tool-use loops. camelCaseoptions (budgetTokens) are translated to the upstreamsnake_casefields at the provider boundary.- Documented in the README; committed distribution artifacts regenerated.
Verification
npm test(679 tests passing across 25 files)npm run type-checknpm run lintnpm run format:checknpm run build- Live authenticated Duo calls through OpenCode:
- GPT-5.6 with
reasoningEffortvariants (for example,xhigh) - Claude Sonnet 4.6 with budget-based
enabledthinking - Claude Opus 4.8 and Claude Opus 5 with
adaptiveeffort thinking (lowthroughxhigh), confirming higher effort produces more thinking/output tokens - Invalid effort and unsupported
enabledthinking return the gateway's validation400, confirming the fields reach upstream
- GPT-5.6 with
Notes
- The Anthropic SDK version pinned in this package predates the public
adaptivethinking type, so the provider defines its ownGitLabThinkingConfigunion rather than depending on the SDK type. The adaptive request shape matches the current Anthropic API contract and the gateway error guidance. - The OpenAI SDK version pinned in this package predates the
maxreasoning effort type. A narrow compatibility cast is isolated at request serialization while the provider's public API exposes the current value. - OpenCode already routes selected variant values through
providerOptions.gitlab. Its model-specific variant lists still need a separate configuration update to exposemaxfor GPT-5.6 Sol, Claude Opus 4.8, Claude Opus 5, and Claude Sonnet 5, and to remove the unsupportedminimalvariant from Sol.
Edited by far-ouq