Function Calling
How a model asks your code to do something — the mechanism underneath every agent, and it's the model requesting, never executing.
When not to use it
- When the model can answer from context. Adding a function for something already in the prompt is latency and a chance to be wrong.
- For anything irreversible without confirmation. Refunds, deletions, sends. The model's confidence is not evidence.
- When you have dozens of tools and no retrieval step. Selection accuracy is already gone; a bigger model won't restore it.
- When a deterministic rule would do. If the logic is
if status == X then Y, write theif. A model call to decide it is slower, costlier, and occasionally wrong.
Reach for something else instead
- Structured output — when you need the model to return shaped data rather than trigger an action.
- Retrieval — when the need is knowledge rather than action.
- Deterministic code paths — for anything with clear rules. Most of what people build agents for.
- Human confirmation steps — for irreversible actions, this is a design, not a fallback.
Read more on the blog
- What is MCP? The standard that wired AI into everythingThe Model Context Protocol went from a November 2024 announcement to the connective tissue of the entire agent era in under two years. Here's what it actually is, the problem it solved, how it works under the hood, and why every major AI lab adopted it, explained plainly, without the sales pitch.
- Why AI agents fail: the seven failure modesGartner predicts over 40% of agentic AI projects will be canceled by 2027. The failures follow patterns, seven of them. The taxonomy: what breaks, why, which real incident proved it, and which control would have prevented it.
Further reading
- Schick et al. (2023), Toolformer: Language Models Can Teach Themselves to Use Tools — models learning when to call, not just how.
- Yao et al. (2022), ReAct: Synergizing Reasoning and Acting in Language Models — the interleaved reason-then-act loop underneath most agent designs.
- Patil et al. (2023), Gorilla: Large Language Model Connected with Massive APIs — what happens to selection accuracy as the tool count grows.
Primary sources, listed so you can check the claims on this page rather than take them on trust.
Where people go wrong
- Treating the model as the permission layer. It decides what to request; your code decides what to allow.
- Writing function descriptions for humans. They're the selection prompt — vague descriptions produce wrong calls.
- Exposing too many tools and blaming the model when selection degrades.
- Passing raw tool errors back without sanitising them, opening an injection surface through the result channel.
- Assuming per-step accuracy is end-to-end accuracy. 95% per step over five steps is 77%.
At a glance
Often compared with
Where this sits
26 concepts come first. Understanding it opens up 1 more.
Computed from the prerequisite graph, not assigned. How this works