DEV Community

Cover image for Tool calls that looked correct and still failed — schema drift I should have caught in review
InApp
InApp

Posted on Originally published at imapp.blogspot.com

Tool calls that looked correct and still failed — schema drift I should have caught in review

Three weeks into shipping an agent, a tool call started returning empty results. No 4xx, no exception — a clean 200 with []. I assumed the upstream had no data and moved on. It had data; my tool definition had drifted.

The schema I'd handed the model still named a parameter query, but the endpoint had quietly renamed it to q two releases earlier. The LLM faithfully emitted query. The server ignored the unknown field and returned an unfiltered empty set. Complete silent contract break.

What I learned, the hard way:

  • A successful response is not proof the call was right. Empty-200 is a failure mode, not a status.
  • Tool schemas rot faster than code. I now diff the served tool definitions against the actual handler params in CI, and fail the build on any mismatch.
  • Default-empty fields are a lie. Where possible I make the server reject unknown params with a 400 instead of silently accepting them.
  • I log the raw emitted args next to the raw result for a sample of calls, so drift shows up before a user notices.

Stabilizing the model side was the easy part; I ended up standardizing my tool-calling client on the same OpenAI-compatible request shape that https://x402.freeq.one/tools/llm_chat.html exposes, so model routing and tool plumbing share one schema I can actually inspect. The expensive lesson was that validation lives at the boundary, not at the model.

Top comments (0)