Common Function Calling Errors
What you'll learn: You'll identify the four most frequent error types that break function calling workflows and understand why they happen.
Function calling fails in predictable ways. Unlike traditional code errors that throw stack traces, LLM-generated function calls fail when the model produces output that doesn't match your expectations or constraints. Understanding these patterns helps you build defensive validation logic.
The Four Error Modes
1. Malformed JSON The LLM returns a response that isn't valid JSON at all. This happens when the model "hallucinates" text around the JSON structure or produces incomplete brackets. Think of it like receiving a form with scribbles in the margins—the structure itself is broken.
2. Missing Required Parameters
Your function schema defines required: ["city", "units"], but the LLM's response only includes {"city": "Paris"}. The model understood it should call a function but didn't provide all necessary information. It's like ordering pizza and forgetting to specify the size.
3. Invalid Parameter Types
Your schema expects temperature: integer, but the model sends temperature: "seventy" or temperature: 70.5. The right parameter exists, but the data type doesn't match your specification. This breaks downstream code expecting specific types.
4. Unknown Function Names
The model attempts to call get_weather_forecast() when you only defined get_weather(). Either the model misremembered the function name or hallucinated a tool that doesn't exist in your registry. This is like calling a phone extension that was never assigned.
Why This Matters
Each error type requires different handling strategies. Malformed JSON needs try-catch parsing. Missing parameters need validation against your schema's required fields. Type mismatches need casting or rejection. Unknown functions need registry lookups with fallbacks.
Key Takeaway: Function calling errors fall into four categories—malformed JSON, missing parameters, wrong types, and unknown functions—each requiring specific validation and error handling strategies before attempting execution.