Skip to content
Wilson Gichuhi
Go back

Demystifying LLM Tool Calling: The Engine of Agentic Workflows

Large Language Models (LLMs) are incredibly powerful at reasoning, writing, and understanding intent. However, they are naturally confined to their training weights. They cannot check the live weather, query a real-time database, or deploy a server by themselves.

This is where Tool Calling comes in. It is the core mechanism that transitions static LLMs into dynamic, agentic systems capable of executing actions in the physical world.

How Tool Calling Works

Contrary to popular belief, the LLM does not execute the tool itself. Instead, the process is a structured dialogue between the model and the application hosting it:

  1. Declaration: The application registers a list of tools with the model. Each tool is described using a structured schema (like JSON Schema), outlining its name, description, and required parameters.
  2. Intent & Argument Generation: During a conversation, if the model decides it needs external information, it stops generating standard text. Instead, it outputs a structured payload (typically JSON) containing the tool name it wishes to call and the specific arguments to pass.
  3. Execution: The application intercepts this payload, runs the corresponding function locally or via an API, and captures the output.
  4. Feedback: The application packages the output into a special “tool response” message and feeds it back into the model’s conversation history.

The Crucial Role of Post-Processors

Between steps 3 and 4 sits one of the most critical parts of agentic infrastructure: post-processors.

Raw tool outputs are rarely optimized for model consumption. A database query might return 10MB of raw JSON, or a web scraper might dump thousands of lines of messy HTML. Sending this directly to the LLM wastes context window, inflates token costs, and introduces noise that degrades reasoning.

Post-processors act as a sanitization and transformation layer. They:

Completing the Loop

Once the post-processor sanitizes the output, it is packaged as a tool role message (or equivalent in APIs like OpenAI’s tool_calls/tool or Anthropic’s tool_result).

When the LLM receives this result, it performs a new inference step. It analyzes the tool’s output in the context of the user’s original query and decides whether:

This structured turn-taking creates a reliable, auditable execution loop. It shifts the burden of execution away from the model and onto deterministic code, ensuring the model only does what it does best: reason and decide.


Share this post: