Skip to content

fix: custom tools with args tolerate undefined input (#30219, #20019) - #36760

Closed
pacificera wants to merge 1 commit into
anomalyco:devfrom
pacificera:fix/custom-tool-args-30219
Closed

fix: custom tools with args tolerate undefined input (#30219, #20019)#36760
pacificera wants to merge 1 commit into
anomalyco:devfrom
pacificera:fix/custom-tool-args-30219

Conversation

@pacificera

Copy link
Copy Markdown

Prevent p.split crash when AI SDK passes undefined args to custom plugin tools. Mirrors the MCP tools fix from #11203 that was never applied to the custom-tool code path.

Changes

Two changes in fromPlugin's execute wrapper (src/tool/registry.ts):

  1. Coerce undefined args to {} — prevents downstream p.split crash when the AI SDK omits optional args
  2. Validate through Zod schema — gives the LLM structured errors via InvalidArgumentsError so it can retry with valid input, matching the validation behavior built-in tools get through wrap()

Tests

  • 17/17 pass (15 existing + 2 new regression tests)
  • Optional Zod args: undefined input returns {} instead of crashing
  • Required Zod args: undefined input fails with InvalidArgumentsError
  • Build compiles cleanly, smoke test passes

Closes#30219, closes#20019

…anomalyco#20019)
Prevent crash when AI SDK passes undefined args to custom
plugin tools. Mirrors the MCP tools fix from anomalyco#11203 that was never
applied to the custom-tool code path.
Two changes in fromPlugin's execute wrapper:
1. Coerce undefined args to {} — prevents downstream crashes
2. Validate through Zod schema — gives the LLM structured errors
via InvalidArgumentsError so it can retry with valid input
Regression tests:
- Optional Zod args: undefined input returns {} instead of crashing
- Required Zod args: undefined input fails with validation error
@github-actions

Copy link
Copy Markdown
Contributor

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

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.

@github-actionsgithub-actionsBot added the needs:compliance This means the issue will auto-close after 2 hours. label Jul 13, 2026
@github-actions

Copy link
Copy Markdown
Contributor

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.

@github-actionsgithub-actionsBot removed the needs:compliance This means the issue will auto-close after 2 hours. label Jul 13, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant

@pacificera