fix(opencode): surface workflow descriptions to LLM via tool description#280
Merged
Merged
Conversation
Documents all 13 investigated approaches to obtaining host's globalRegistry, Zod v4 internals (how descriptions are stored/read), and why the dynamic import approach was chosen as the production-viable solution.
…ribe() OpenCode does not propagate Zod parameter .describe() text to the LLM. Confirmed by canary test - descriptions are invisible regardless of zod instance or registry. The tool description IS propagated, so embed the workflow enum choices and their descriptions there directly. Also removes the tool.definition hook and globalRegistry bridging code which were solving the wrong problem.
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.
Problem
OpenCode does not propagate Zod parameter
.describe()text to the LLM. This meant the AI had no guidance on whichworkflowenum value to pick when callingstart_development, leading to wrong workflow selection.Root cause confirmed: Hardcoding a canary string via
.describe()was completely invisible to the LLM — parameter descriptions are simply never surfaced by OpenCode, regardless of Zod version or registry.Solution
Embed the workflow enum choices and their descriptions directly in the tool description string — the only channel confirmed to reach the LLM:
Changes
start-development.ts: Build tool description with inline workflow list; remove.describe()fromworkflowarg; remove unusedgenerateWorkflowDescriptionimportplugin.ts: Removetool.definitionhook (was attempting to bridge Zod registries — wrong approach)Testing
All 286 tests pass. Verified the description is visible to the LLM after restart.