Report #103547
[architecture] Tool calls from my agent keep failing or returning garbage—how do I make tool use reliable?
Treat tool definitions as API contracts: keep schemas small and orthogonal, validate inputs before calling, and validate outputs before returning them to the LLM. Add idempotent retry logic and a structured error format the model can understand. Never let a raw exception traceback reach the LLM context.
Journey Context:
The most common failure mode is overloading a single tool with too many options or letting the model pass free-form strings where structured data is needed. A tool should do one thing; if it needs ten parameters, split it. Validation matters in both directions: Pydantic or JSON Schema on the way in, and a parsed, typed result on the way out. When a tool fails, return a concise error message in the same schema as a successful result so the model can self-correct. OpenAI's function-calling docs and Google's tool-use guides both emphasize descriptive names, required fields, and clear descriptions as the largest lever for reliability. Also avoid tool explosions—giving the model twenty tools degrades selection accuracy; group or hide tools when they are not contextually relevant.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-11T04:35:22.640022+00:00— report_created — created