Uh oh!
There was an error while loading. Please reload this page.
fix(tool): bridge custom tool zod metadata - #27770
Merged
Merged
Conversation
rekram1-node
commented
May 15, 2026
CollaboratorAuthor
/review |
Contributor
lgtm |
Uh oh!
There was an error while loading. Please reload this page.
zenoda pushed a commit
to zenoda/opencode
that referenced
this pull request
May 16, 2026
khimaros
commented
May 17, 2026
Contributor
@rekram1-node thank you for merging this. however, there is still an issue with invalid enum values compared with my original PR. |
Contributor
the simplest fix i can come up with (to properly validate enums and return an error to the LLM when invalid): diff --git a/packages/opencode/src/tool/registry.ts b/packages/opencode/src/tool/registry.ts
index 879855c36..b0f927053 100644
--- a/packages/opencode/src/tool/registry.ts+++ b/packages/opencode/src/tool/registry.ts@@ -156,13 +156,22 @@ export const layer: Layer.Layer<
description: def.description,
execute: (args, toolCtx) =>
Effect.gen(function* () {
+ let input: unknown = args+ if (zodParams) {+ const validated = zodParams.safeParse(args)+ if (!validated.success)+ throw new Error(+ `The ${id} tool was called with invalid arguments: ${validated.error}.\nPlease rewrite the input so it satisfies the expected schema.`,+ )+ input = validated.data+ }
const pluginCtx: PluginToolContext = {
...toolCtx,
ask: (req) => toolCtx.ask(req),
directory: ctx.directory,
worktree: ctx.worktree,
}
- const result = yield* Effect.promise(() => def.execute(args as any, pluginCtx))+ const result = yield* Effect.promise(() => def.execute(input as any, pluginCtx))
const output = typeof result === "string" ? result : result.output
const metadata = typeof result === "string" ? {} : (result.metadata ?? {})
const attachments = typeof result === "string" ? undefined : result.attachments |
6 tasks
AIALRA-0 pushed a commit
to AIALRA-0/opencode-turn-engine
that referenced
this pull request
Jun 10, 2026
AIALRA-0 pushed a commit
to AIALRA-0/opencode-turn-engine
that referenced
this pull request
Jun 10, 2026
avion23 pushed a commit
to avion23/opencode
that referenced
this pull request
Jun 10, 2026
isaacfinnegan pushed a commit
to isaacfinnegan/whispercode
that referenced
this pull request
Jun 15, 2026
MarsQiu007 referenced
this pull request
in MarsQiu007/openNovel
Jul 31, 2026
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 freeto 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
jsonSchemapath added in fix(tool): preserve custom tool arg descriptions #27750 so stale installed plugin packages are handled too@opencode-ai/pluginpackage that only returns raw Zod argsCloses#4357
References #27750 and #19916.
Testing
bun test test/tool/registry.test.ts