Skip to content

fix: preserve tool argument descriptions in schema conversion#22080

Open
bensantora wants to merge 2 commits intoanomalyco:devfrom
bensantora:fix/zod-describe-metadata-schema-conversion
Open

fix: preserve tool argument descriptions in schema conversion#22080
bensantora wants to merge 2 commits intoanomalyco:devfrom
bensantora:fix/zod-describe-metadata-schema-conversion

Conversation

@bensantora
Copy link
Copy Markdown

Issue for this PR

Closes #4357

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Uses zodToJsonSchema instead of z.toJSONSchema when converting tool parameter schemas to JSON Schema. This preserves the .describe() metadata from zod schemas, matching the approach already used in server.ts (line 307).

The issue was that z.toJSONSchema() doesn't extract .describe() metadata from schema properties, so tool argument descriptions weren't being passed to the LLM.

How did you verify your code works?

The fix follows the same pattern used in server.ts for converting tool schemas, ensuring consistency.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Uses zodToJsonSchema instead of z.toJSONSchema to preserve .describe()
metadata from zod schemas, matching the approach in server.ts
@github-actions
Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Based on my search, I found several potentially related PRs addressing similar issues with tool argument descriptions and schema conversion:

Potential Duplicates/Related PRs:

  1. fix: preserve tool argument descriptions in schema conversion #14476 - "fix: preserve tool argument descriptions in schema conversion"

    • Same title as current PR, likely addressing the same issue previously
  2. fix(opencode): missing custom tool arg descriptions #15957 - "fix(opencode): missing custom tool arg descriptions"

    • Directly addresses missing tool argument descriptions
  3. fix(custom-tools): preserve arg descriptions and enforce validation #19916 - "fix(custom-tools): preserve arg descriptions and enforce validation"

    • Preserves argument descriptions in custom tools
  4. fix(opencode): replace zodToJsonSchema with z.toJSONSchema for Zod v4 compat #20809 - "fix(opencode): replace zodToJsonSchema with z.toJSONSchema for Zod v4 compat"

    • Related to zodToJsonSchema vs z.toJSONSchema conversion approach
  5. fix(opencode): preserve custom tool arg descriptions in LLM prompts #13417 - "fix(opencode): preserve custom tool arg descriptions in LLM prompts"

    • Addresses preserving descriptions in LLM prompts

These PRs appear to be addressing the same or very closely related issues with tool argument descriptions not being preserved during schema conversion. PR #14476 has the exact same title, suggesting this may be a re-opened or related issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tool argument descriptions lost in schema conversion

1 participant