createTool only uses inputSchema for validation
Tool class accepts 4 schemas and it seems only inputSchema is used for actual validation.
My expectation was that that all schemas is used to enforce runtime safety and better error reporting.
6 Replies
Apparently
inputSchema is also used in kind of weird way.
I am concerned about runtime safety based on that caller side can't differentiate valid data from error state.Here typescript claims I'll get particular data shape in result which is QraphQL response.
But instead I get something completely different:
vs expected:

📝 Created GitHub issue: https://github.com/mastra-ai/mastra/issues/8530
GitHub
[DISCORD:1424455846188027965] createTool only uses inputSchema for ...
This issue was created from Discord post: https://discord.com/channels/1309558646228779139/1424455846188027965 Tool class accepts 4 schemas and it seems only inputSchema is used for actual validati...
Hmm I can't seem to reproduce this, if I add an
outputSchema I get the types for it
I'm also not sure I 100% follow what you're saying here, are you able to provide me a reproduction so I can understand what you're seeing vs what you're expecting?
exactly. you only have types inferred, without runtime validation. I see no value to construct zod schemas just for type inferring
poorly written execute function that uses assertions and any types inside would easely brake this contract
it isn't a blocker but it breaks developer experience with wrong expectations