fix: preserve tool argument descriptions in schema conversion#14476
fix: preserve tool argument descriptions in schema conversion#14476Hemanshu-Upadhyay wants to merge 1 commit intoanomalyco:devfrom
Conversation
Use zodToJsonSchema() instead of z.toJSONSchema() for converting tool parameter schemas, which correctly preserves .describe() metadata on Zod schema properties. This ensures custom tool argument descriptions are passed through to the LLM. Fixes anomalyco#4357
|
The following comment was made by an LLM, it may be inaccurate: Based on my search, I found a potentially related PR: Related PR Found:
This PR appears to address the same issue—preserving custom tool argument descriptions. It may be worth checking if it was already merged or closed, and whether the current PR (#14476) is a follow-up, alternative approach, or if they're addressing different aspects of the same problem. |
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
a1abc1a to
755f98b
Compare
|
Heads up — switching from The actual root cause for plugin tools losing descriptions is cross-Zod-instance metadata loss (Zod v4 stores |
Issue for this PR
Closes #4357
Type of change
What does this PR do?
Custom tools using
.describe()on Zod schema properties lose those descriptions before they reach the LLM. This happens becausesession/prompt.tsusesz.toJSONSchema()which strips description metadata from schema properties.The fix swaps it for
zodToJsonSchema()from thezod-to-json-schemapackage, which correctly preserves.describe()metadata. This is the same function already used inserver/routes/experimental.tsfor the same purpose, andzod-to-json-schemais already a dependency.How did you verify your code works?
bun turbo typecheck— all 12 packages pass)bun devstarts without issueszodToJsonSchema()output includesdescriptionfields for properties with.describe(), whilez.toJSONSchema()drops themScreenshots / recordings
Not a UI change.
Checklist