How LLMs Call Tools
How LLMs use function calling and tool use — the mechanics behind tool-calling agents, from prompt engineering to structured output.
Last updated
After this section you can
- Trace the tool loop and say which steps the model does and which your code does
- Predict when a model can call tools in parallel and what that saves
- Name the common tool-calling failures, including poisoned results, and the mitigation for each
How LLMs Actually Call Tools
A model cannot run code, query a database or send an email. It can write a structured request for one. Learn who does what in that exchange and agents stop being magic.
The model never executes anything. It writes a request naming a tool and its arguments, then stops. Your code runs the tool and sends the result back as one more message, and the model carries on from there.