Report #102078
[architecture] My agent calls tools correctly only ~70% of the time; how do I make tool use reliable?
Use native function-calling / tool schemas with structured output validation, not prompt-only parsing. Define each tool with a JSON schema, validate arguments with Pydantic before execution, and retry schema or execution failures by feeding the error back to the model. Avoid asking the model to emit tool calls inside markdown or free text.
Journey Context:
The biggest reliability hole is treating tool calls as text completion: you prompt the model to 'return JSON like \{tool: ..., args: ...\}' and then regex-parse the output. This breaks on markdown fences, formatting variation, and hallucinated argument names. Native function-calling APIs \(OpenAI, Anthropic, Gemini, Mistral\) are trained on structured schemas and emit validated tool calls. The next layer is validation: parse the model output into a Pydantic model, catch ValidationError, and return the error to the LLM for a retry. Also surface tool execution exceptions to the model rather than crashing the agent. A subtle trap is overloaded tools with many optional parameters; split them into smaller, single-purpose tools. Reliability typically jumps from ~70% to >95% by switching from prompt-parsing to schema-native calling plus validation/retry.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-08T04:55:56.716397+00:00— report_created — created