Skip to content

feat(core): generate Anthropic thinking variants for reasoning models - #34333

Closed
kitlangton wants to merge 2 commits into
devfrom
anthropic-thinking-variants
Closed

feat(core): generate Anthropic thinking variants for reasoning models#34333
kitlangton wants to merge 2 commits into
devfrom
anthropic-thinking-variants

Conversation

@kitlangton

Copy link
Copy Markdown
Contributor

Problem

In the V2 TUI, reasoning-capable Anthropic models (e.g. opencode/claude-opus-4-8) showed no thinking-level control. The /variants command, the variant picker, and the reasoning UI hint are all gated on model.variant.list().length > 0, and Claude models had zero variants.

Root cause:

  • The console config sends Claude models with "reasoning": true and no variants — thinking was never expressed as variants on the console side.
  • v1 had reasoning as a first-class capability flag that drove a dedicated Anthropic thinking pathway.
  • v2 intentionally dropped that flag (per the config spec: provider/request behavior belongs in model variants), but the only variant generator was hardcoded to GLM-5.2. Anthropic reasoning models got nothing, so the control was silently hidden.

Fix

Port the v1 behavior properly instead of hardcoding model names:

  1. Add reasoning: boolean to Model.Capabilities (where v1 had it).
  2. Thread the reasoning flag from every catalog source (models.dev, console config, local config) onto the model.
  3. Generate Anthropic thinking variants (high/max) gated on capabilities.reasoning, lowering to { thinking: { type: "enabled", budget_tokens } } — the only shape the v2 AnthropicMessages protocol accepts (it rejects v1's adaptive/effort). Budgets scale with model.limit.output like v1.
  4. Regenerate SDK/client/openapi types; update fixtures; add variant tests.

The TUI needs no changes — once these variants exist, /variants and the picker light up automatically.

Verification

  • bun typecheck passes for schema, core, sdk, client.
  • 32 relevant core tests pass, including 3 new variant tests covering generation, output-limit clamping, and the non-reasoning exclusion (e.g. claude-3-5-haiku).

@github-actions

Copy link
Copy Markdown
Contributor

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

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.

1 participant