Function Calling
Captured source
source ↗Fireworks AI
GLM 5.2 is live! Opus-level intelligence at open-source rates. Pay per token on serverless. Try it today.
Blog
Function Calling Understanding Function Calling: The Bridge to Agentic AI
PUBLISHED 7/11/2025
Table of Contents What is Function Calling? Technical Underpinnings The Path to Agentic AI Model Context Protocol (MCP): Enhancing Function Calling
Why MCP Matters Applications and Use Cases Building Effective AI Agents The Future of Function Calling Conclusion
Table of Contents
Large language models (LLMs) have revolutionized natural language processing by generating impressive text based on massive pretraining and strategic alignment with user preferences during post training. However, their inherent limitation is that, while they excel at generating human-like language, they lack the ability to access or update real-world information on demand. This is where function (or tool) calling comes into play. What is Function Calling?
Function calling refers to the process by which an LLM detects that a user request requires external data or action and then produces a structured output (typically in JSON) that specifies which function to call along with the necessary arguments. For example, instead of simply generating text to answer "What is the weather in London?" an LLM equipped with function calling can output a JSON object that triggers a weather API call. Once the external tool returns the relevant data, the LLM integrates this information into its final response. This paradigm is sometimes also called tool calling, and it fundamentally transforms LLMs from static knowledge generators into dynamic, interactive agents capable of real‐world tasks. Technical Underpinnings
At its core, function calling involves the following key steps: • Tool Specification and Prompting: Developers define a set of external functions, each with a name, description, and a JSON schema for its parameters. For example, a weather retrieval function might be specified with parameters such as location and temperature unit. The LLM is then prompted with both the user query and the tool definitions. By passing in the tool definitions as part of the prompt context, the model learns to generate structured calls when it identifies that a user query requires external data. • Detecting and Generating Function Calls: When the LLM processes a user query, it decides whether to answer directly or issue a function call. If the latter is chosen, the model outputs a JSON string with the name of the function and the relevant arguments. This output does not execute the function, it merely indicates what external call should be made. The ability to output a function call in a structured format is critical; it lets developers safely and reliably integrate external APIs into the LLM's workflow. The execution of the functions happens in the LLM agent module. • Function Execution and Feedback Loop: An external system or middleware detects the structured function call, executes the specified function (e.g., calls a weather API), and retrieves the result. This result is then fed back into the conversation context for the LLM to generate a comprehensive answer. In many implementations, a second round of prompting uses both the original query and the function's output to produce the final response. This two-step process, first generating the function call, then using the result to refine the final output, forms the backbone of interactive LLM systems.
The Path to Agentic AI
Function calling represents a crucial stepping stone toward truly agentic AI systems. While traditional LLMs are reactive, responding to prompts with generated text- agentic systems take initiative, plan multi-step workflows, and autonomously execute complex tasks. The evolution from simple function calling to agentic behavior involves several key capabilities: • Multi-Step Planning: Agentic AI doesn't just call a single function; it orchestrates entire workflows. When asked to "schedule a meeting with the engineering team," an agent might check multiple calendars, find optimal time slots, book meeting rooms, create agenda documents, and send invitations, all through coordinated function calls.
Multi-Step Planning • Adaptive Decision Making: Unlike simple function calling where the model follows a predefined pattern, agentic systems make dynamic decisions based on intermediate results. If one approach fails, they automatically try alternatives rather than simply returning an error.
Adaptive Decision Making • Memory and Context: Agentic systems maintain state across interactions, learning from past experiences and building contextual understanding over time. This enables sophisticated behaviors like remembering user preferences and tracking ongoing projects.
Memory and Context Model Context Protocol (MCP): Enhancing Function Calling
As the ecosystem of AI agents grows, standardization becomes critical. The Model Context Protocol (MCP) is an open standard that enables developers to build secure, two-way connections between data sources and AI-powered tools. Think of MCP like a USB-C port for AI applications. Just as USB-C provides a standardized way to connect devices to peripherals, MCP provides a standardized way to connect AI models to various data sources and tools. Why MCP Matters
Before MCP, developers faced the "N×M problem"- building custom connectors for each combination of AI applications and data sources. With numerous AI applications needing to connect to numerous tools, complexity grew exponentially. MCP solves this by providing: • Standardized interfaces for reading files, executing functions, and handling prompts • Universal compatibility allowing any MCP-compliant AI to connect to any MCP server • Security boundaries with proper authentication and permission management
Following its introduction, MCP was rapidly adopted by major AI providers, creating a rich ecosystem of compatible tools and services. This broad adoption establishes MCP as the emerging standard for AI interoperability. Applications and Use Cases
The convergence of function calling and emerging standards enables powerful applications: • Real-Time Data Retrieval: LLMs can fetch up-to-date information such as weather forecasts, stock prices, or news updates, overcoming the limitations of static pretraining data. • Task Automation: By invoking functions, LLMs can perform tasks like scheduling meetings, managing databases, or...
Excerpt shown — open the source for the full document.
Notability
notability 3.0/10Routine blog post on function calling