feat(plugin): add chat.variant hook for programmatic thinking/variant control#6662
Closed
code-yeongyu wants to merge 2 commits into
Closed
feat(plugin): add chat.variant hook for programmatic thinking/variant control#6662code-yeongyu wants to merge 2 commits into
code-yeongyu wants to merge 2 commits into
Conversation
… control Allow plugins to override the variant/thinking level used for LLM requests. This enables programmatic control over model variants (e.g., Anthropic's thinking budget, OpenAI's reasoning effort) via the plugin system. The hook receives: - sessionID, agent, model context - currentVariant: the variant selected via UI (ctrl+t) - availableVariants: list of variants supported by the model The hook can set: - variant: override the variant name - options: directly inject provider options (takes precedence) 🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
Tests: - variant override - options override - preserve unchanged variant - input parameter validation Generated with assistance of OhMyOpenCode
Collaborator
|
I don't think u need a brand new plugin for it.... See here: But maybe thats too weird... |
Collaborator
|
accidentally clicked close instead of comment oops |
Contributor
Author
|
Thanks for the feedback! I initially created this hook because I thought the variant changes wouldn't be reflected in the TUI. Let me do some more testing to verify this and get back to you. |
Collaborator
|
ah thats a fair point, I think u need to set the variant on the message then in that case |
Contributor
Author
|
I tried implementing it with "chat.params": async (input, output) => {
const agent = input.agent as unknown as { name: string }
const model = input.model as { variants?: Record<string, Record<string, unknown>> }
const maxVariant = model.variants?.["max"]
if (agent.name === "Sisyphus" && maxVariant) {
output.options = { ...output.options, ...maxVariant }
}
},But the TUI does not reflect the change (no "max" indicator shown). It would be pretty cool if the TUI could display "max" when the plugin sets it. Is doing this via plugin a bad approach? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add
chat.variantplugin hook that allows plugins to programmatically control the thinking/variant level (high, max) before LLM requests are made.Changes
chat.varianthook type definition in@opencode/pluginllm.tsbefore variant options are appliedoutput.variantoroutput.optionsUse Case
Plugins can now programmatically control:
This enables use cases like:
Example Usage
Generated with assistance of OhMyOpenCode