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 as reasoning: { effort } on the Responses API models and as reasoning_effort on the Chat Completions models, so the option applies to every OpenAI model family rather than being silently dropped on Chat Completions.

Anthropic Messages models

  • thinking as a discriminated union:
    • { type: 'disabled' }
    • { type: 'enabled', budgetTokens } -> thinking: { type: 'enabled', budget_tokens }
    • { type: 'adaptive', effort } -> thinking: { type: 'adaptive' } plus a sibling output_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 (enabled or adaptive), temperature is dropped and an out-of-range top_p is omitted, since Anthropic rejects those while thinking is engaged and would otherwise return a 400.
  • Anthropic thinking and redacted_thinking response blocks are surfaced as reasoning content, carrying the block signature under providerOptions.gitlab, and replayed unmodified on later turns as required during tool-use loops.
  • camelCase options (budgetTokens) are translated to the upstream snake_case fields at the provider boundary.
  • Documented in the README; committed distribution artifacts regenerated.

Verification

  • npm test (679 tests passing across 25 files)
  • npm run type-check
  • npm run lint
  • npm run format:check
  • npm run build
  • Live authenticated Duo calls through OpenCode:
    • GPT-5.6 with reasoningEffort variants (for example, xhigh)
    • Claude Sonnet 4.6 with budget-based enabled thinking
    • Claude Opus 4.8 and Claude Opus 5 with adaptive effort thinking (low through xhigh), confirming higher effort produces more thinking/output tokens
    • Invalid effort and unsupported enabled thinking return the gateway's validation 400, confirming the fields reach upstream

Notes

  • The Anthropic SDK version pinned in this package predates the public adaptive thinking type, so the provider defines its own GitLabThinkingConfig union 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 max reasoning 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 expose max for GPT-5.6 Sol, Claude Opus 4.8, Claude Opus 5, and Claude Sonnet 5, and to remove the unsupported minimal variant from Sol.
Edited by far-ouq

Merge request reports

Loading
Loading