fix(tool): preserve custom tool arg descriptions (#27750)

Co-authored-by: khimaros <231498+khimaros@users.noreply.github.com>
This commit is contained in:
Aiden Cline
2026-05-15 10:11:01 -05:00
committed by GitHub
parent eb630075c3
commit ef7d801271
3 changed files with 81 additions and 3 deletions

View File

@@ -145,7 +145,14 @@ export const layer: Layer.Layer<
const entries = Object.entries(def.args)
const allZod = entries.every((entry) => isZodType(entry[1]))
const zodParams = allZod ? z.object(def.args) : undefined
const jsonSchema = zodParams ? zodJsonSchema(zodParams) : legacyJsonSchema(entries)
// Newer @opencode-ai/plugin versions precompute JSON Schema with the
// Zod instance that owns arg metadata. Fall back for older/manual
// custom tools that only expose raw Zod args.
const jsonSchema = zodParams
? isJsonSchemaDefinition(def.jsonSchema)
? (def.jsonSchema as JSONSchema7)
: zodJsonSchema(zodParams)
: legacyJsonSchema(entries)
const parameters = zodParams
? Schema.declare<unknown>((u): u is unknown => zodParams.safeParse(u).success)
: Schema.Unknown