Report #101586
[architecture] How do I make LLM tool calling reliable enough to use in production?
Treat the model's tool arguments as untrusted text: parse them with a strict schema validator like Pydantic, coerce types, and feed validation errors back to the model in a retry loop. Never pass raw LLM JSON directly to a function.
Journey Context:
Even with native function calling, models hallucinate required fields, pick wrong enum values, or emit malformed JSON. The tutorials show the happy path and skip validation. Production reliability comes from a tight loop: model emits arguments → schema validation → on failure, return the validation error as a system/tool message → model retries. OpenAI's function-calling guide describes this pattern, but most codebases omit the validation layer, which is where failures actually surface.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-07T05:06:26.894882+00:00— report_created — created