Defining Input and Output Contracts for AI Tool Calls
An LLM may send a tool request with a vague value like "a few" where the backend needs an integer, raising the question of how to handle it. The author argues that tool contracts resolve this by separating tool selection, argument generation, and execution, since a fluent model response doesn't prove correct tool use. Using JSON Schema, a document search tool can require a non-blank query, an integer limit from 1 to 10, and no unexpected fields, with the example cases presented as illustrative rather than measured results. The piece also distinguishes coercing a string like "3" into an integer from rejecting it under strict validation, recommending a deliberate, tested policy. Finally, it notes that MCP's optional outputSchema helps validate structured results but does not confirm accuracy or relevance, and suggests distinguishing a search with no matches from a search that failed to run.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in