Book a 30-min callBook a call

How LLM tool calling works: the agent loop, step by step

How LLM tool calling works: tool definitions, what the model returns, the agent loop, parallel calls, tool_choice, strict schemas, errors, safety and MCP.

A messages card and a tools card feeding a model box, a tool call going to a code box, and a dashed loop arrow carrying the result back.
Written by
BYD Tech
Published
Topic
Deep dives
Reading time
13 min read

Questions people ask

Does the model run the tool itself?

No. The model returns a request naming a tool and its arguments. Your code decides whether to run it, runs it and sends the result back. Hosted tools, such as a provider’s own web search, are the exception: the provider runs those on its side.

Is function calling the same as tool calling?

In practice, yes. OpenAI and Google say function calling, Anthropic says tool use, and MCP says tools. The mechanism is the same: a schema goes in, a structured call comes out, and a result goes back.

How many loop iterations should an agent allow?

Enough for the longest legitimate task you have measured, plus a margin, and no more. Start low, log how many steps real runs take, and raise the limit with evidence. When the limit is hit, return a clear message instead of a half-finished answer.

Do I still need validation with strict schemas?

Yes. Strict mode makes the arguments match the schema’s shape and types. It cannot tell whether a valid-looking ID belongs to the current user, whether a quantity is sensible or whether the action should happen at all. Those checks live in your code.

Is MCP a replacement for provider tool calling?

No. MCP standardizes how an app finds and calls tools that live in a server. The model still sees those tools through the provider’s tool-calling API, and your app still runs the loop.

Building something like this?