[PR #6662] feat(plugin): add chat.variant hook for programmatic thinking/variant control #12026

Closed
opened 2026-02-16 18:16:57 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/6662

State: closed
Merged: No


Summary

Add chat.variant plugin hook that allows plugins to programmatically control the thinking/variant level (high, max) before LLM requests are made.

Changes

  • Add chat.variant hook type definition in @opencode/plugin
  • Trigger hook in llm.ts before variant options are applied
  • Plugin receives current variant state and can override via output.variant or output.options

Use Case

Plugins can now programmatically control:

  • Anthropic's thinking budget (high/max)
  • OpenAI's reasoning effort
  • Other provider-specific variant options

This enables use cases like:

  • Always use high thinking for specific models
  • Dynamic thinking level based on conversation context
  • Conditional variant selection based on session/agent type

Example Usage

const myPlugin: Plugin = async () => ({
  "chat.variant": async (input, output) => {
    // Always use high thinking for Claude
    if (input.model.id.includes("claude")) {
      output.variant = "high"
    }
  }
})

Generated with assistance of OhMyOpenCode

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/6662 **State:** closed **Merged:** No --- ## Summary Add `chat.variant` plugin hook that allows plugins to programmatically control the thinking/variant level (high, max) before LLM requests are made. ## Changes - Add `chat.variant` hook type definition in `@opencode/plugin` - Trigger hook in `llm.ts` before variant options are applied - Plugin receives current variant state and can override via `output.variant` or `output.options` ## Use Case Plugins can now programmatically control: - Anthropic's thinking budget (high/max) - OpenAI's reasoning effort - Other provider-specific variant options This enables use cases like: - Always use high thinking for specific models - Dynamic thinking level based on conversation context - Conditional variant selection based on session/agent type ## Example Usage ```typescript const myPlugin: Plugin = async () => ({ "chat.variant": async (input, output) => { // Always use high thinking for Claude if (input.model.id.includes("claude")) { output.variant = "high" } } }) ``` --- Generated with assistance of [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
yindo added the pull-request label 2026-02-16 18:16:57 -05:00
yindo closed this issue 2026-02-16 18:16:57 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#12026