opencode icon indicating copy to clipboard operation
opencode copied to clipboard

feat(plugin): add chat.variant hook for programmatic thinking/variant control

Open code-yeongyu opened this issue 2 weeks ago • 5 comments

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

code-yeongyu avatar Jan 02 '26 17:01 code-yeongyu