Forward variant to opencode agent registration (fixes variant use in opencode task() tool)#41
Merged
tctinh merged 1 commit intotctinh:mainfrom Feb 6, 2026
Conversation
The config hook was reading variant from ConfigService but not including it in the agent config objects registered with opencode. This meant opencode's built-in variant resolution in createUserMessage (prompt.ts:831-838) always saw agent.variant as undefined, making the chat.message hook the only path for variant injection. Now both paths work correctly.
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.
PR: Forward variant to opencode agent registration
Problem
After this implementaion anomalyco/opencode#11410
The
confighook inopencode-hivereadsvariantfromConfigService.getAgentConfig()but does not include it in the agent config objects registered with opencode. The agent configs setmodelandtemperaturebut omitvariant.This matters because opencode's built-in variant resolution in
createUserMessage(session/prompt.ts:831-838) checksagent.variant:Since
agent.variantwas alwaysundefined, this path never produced a value. Thechat.messagehook (introduced in the per-agent variant PR) was the only working path for variant injection.What changed
Added
variant: <agentUserConfig>.variantto all six agent config objects in theconfighook:hiveConfigarchitectConfigswarmConfigscoutConfigforagerConfighygienicConfigOne line per agent. No other changes.
How the two paths now interact
There are two paths for variant to reach the LLM request:
Built-in resolution (
prompt.ts:831): opencode readsagent.variantandagent.model, checks they match the model in use, and setsvarianton the message info. This now works becauseagent.variantis populated.chat.messagehook (index.ts:417): fires after built-in resolution. Checksoutput.message.variantand only sets it if currentlyundefined. Acts as a fallback for cases where the model guard in path 1 fails (e.g., model mismatch).Both paths agree. Path 1 sets the value when model matches; the hook's
if (output.message.variant !== undefined) returnguard skips it. When model doesn't match, path 1 producesundefinedand the hook fills it in.Scope
packages/opencode-hive/src/index.tsonly.hive-core,vscode-hive, tests, or schema.Verification
Manual verification
Requires both
agent_hive.jsonandopencode.jsonconfigured with a variant-capable model.agent_hive.json:{ "agents": { "forager-worker": { "model": "anthropic/claude-sonnet-4-20250514", "variant": "high" } } }opencode.json(model must define the variant key):{ "provider": { "anthropic": { "models": { "claude-sonnet-4-20250514": { "variants": { "high": { "thinking": { "type": "enabled", "budgetTokens": 16000 } } } } } } } }Prompt the hive-master agent:
Check opencode logs (
~/.local/share/opencode/log/) for the forager-worker session's LLM request. Thethinkingoptions should be present in the provider options. As a negative control, removevariantfromagent_hive.jsonand repeat -- the thinking block should disappear.