Report #98372
[architecture] Tool calls from LLMs are flaky — how do I make tool use production-ready?
Define tight JSON schemas with strict mode, validate outputs with Pydantic, retry with the validation error as feedback, make tools idempotent, and cap the number of tools visible per turn. For critical paths, prefer deterministic parsers or constrained generation over free-form tool arguments.
Journey Context:
OpenAI function-calling best practices emphasize strict schemas, small tool sets, and clear descriptions. Instructor adds Pydantic validation and automatic reasking so a malformed call becomes a correction loop instead of a crash. The failure mode most teams ignore is not the model choosing the wrong tool — it's a syntactically invalid argument or a tool side effect that fires twice. Idempotency keys and read-only verification tools before mutating state are the patterns that keep agents safe at scale.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-27T04:51:54.409660+00:00— report_created — created