fix(tool): tolerate plugin tool defs with missing args (#28357)
This commit is contained in:
@@ -145,9 +145,12 @@ export const layer: Layer.Layer<
|
||||
function fromPlugin(id: string, def: ToolDefinition): Tool.Def {
|
||||
// Plugin tools still expose Zod args publicly; keep that compatibility
|
||||
// boxed at the registry boundary and give the LLM the original JSON Schema.
|
||||
const entries = Object.entries(def.args)
|
||||
// Normalize missing args to `{}` once — pre-1.14.49 the code was
|
||||
// `z.object(def.args)` and Zod silently tolerated undefined (#27451, #27630).
|
||||
const args = def.args ?? {}
|
||||
const entries = Object.entries(args)
|
||||
const allZod = entries.every((entry) => isZodType(entry[1]))
|
||||
const zodParams = allZod ? z.object(def.args) : undefined
|
||||
const zodParams = allZod ? z.object(args) : undefined
|
||||
const jsonSchema = zodParams ? zodJsonSchema(zodParams) : legacyJsonSchema(entries)
|
||||
const parameters = zodParams
|
||||
? Schema.declare<unknown>((u): u is unknown => zodParams.safeParse(u).success)
|
||||
|
||||
Reference in New Issue
Block a user