fix(opencode): missing custom tool arg descriptions#15957
fix(opencode): missing custom tool arg descriptions#15957ashleytowner wants to merge 3 commits intoanomalyco:devfrom
Conversation
Use plugin-provided parameters when available, restore .describe metadata for older plugin definitions, and validate custom tool inputs before execute.
Rehydrate plugin arg schema metadata into core Zod registry before JSON Schema export so descriptions/meta survive cross-instance loading. Keep plugin tool definitions minimal while preserving runtime validation in registry.
|
Hey! Your PR title Please update it to start with one of:
Where See CONTRIBUTING.md for details. |
|
The following comment was made by an LLM, it may be inaccurate: Based on my search results, I found 2 potentially related PRs:
Note: These PRs may have been previously opened and closed/merged attempts at fixing the same issue (issue #15956). You should check their status and whether they fully addressed the problem or if there are unresolved aspects that PR #15957 is now fixing. |
Both of these linked PRs use the same solution (using Here is a screenshot from #14476 showing the issue |
Cherry-picked from upstream PR anomalyco#15957. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
rebased against dev and small cleanup here: #19916 |

Issue for this PR
Closes #4357 & #15956
Type of change
What does this PR do?
The issue is mostly described in the attached issue, but very simply it is twofold:
The root problem is that Zod metadata from
.describe()/.meta()is tied to Zod’s runtime registry. Custom tools can be loaded from a different runtime context than core, so metadata can be dropped during schema export unless it is re-registered in the core runtime beforez.toJSONSchema(). Preserving that metadata restores argument descriptions in the model-visible schema.The code I've added walks through the schema and re-registers metadata fields with the zod runtime in opencode, so that they actually get passed to the model. My code then also adds a step to actually check that args passed in from the model match the schema, so that invalid args can be rejected consistently.
How did you verify your code works?
Wrote an automated test (included in this PR) and tested manually by running opencode myself & seeing improvements, and seeing that it could quote me exactly the descriptions that I passed in.
Screenshots / recordings
This isn't applicable
Checklist