fix: parse plugin tool args with Zod schema before execute - #49289
CodeAlex52 wants to merge 1 commit into
Conversation
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
Please edit this PR description to address the above within 2 hours, or it will be automatically closed. If you believe this was flagged incorrectly, please let a maintainer know. |
|
The following comment was made by an LLM, it may be inaccurate: Potential Related PR FoundPR #43460: fix(core): decode plugin tool input with the schema's own instance This PR is potentially related because it also addresses plugin tool input handling with schema validation. Both PRs deal with ensuring plugin tool arguments are properly validated against their schemas before execution. Your PR (49289) extends this by specifically handling Zod schema parsing with default values and constraint validation (like |
|
This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window. Feel free to open a new pull request that follows our guidelines. |
Fixes #49279.
fromPlugin() built the Zod object for the JSON schema but handed raw LLM args to def.execute(), so .default() never applied and constraints like .min() never rejected. Now it safe-parses with the existing zodParams first (legacy JSON-schema tools unchanged) and raises Tool.InvalidArgumentsError on violation, matching Tool.define() behavior.
Verified: new regression test in test/tool/registry.test.ts covers the issue repro (defaults filled, min violation rejected, mutation-checked against unfixed code). Full registry suite: 16 pass locally except one pre-existing flaky timeout on 'does not expose execute unless code mode is enabled', which also times out on pristine dev. tool-define suite: 5 pass. bun typecheck clean.