fix(tool): preserve custom tool arg descriptions (#27750)
Co-authored-by: khimaros <231498+khimaros@users.noreply.github.com>
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user