Function Calling Is All You Need

Ilan Bigio, OpenAI1:42:54 · Apr 2025 · 34K views
Thumbnail for Function Calling Is All You Need Watch on YouTube
TL;DR
  1. 1

    Function calling gives a model a way to request data or actions while the application remains responsible for executing the code.

  2. 2

    An agent can be implemented as a loop that sends messages and tools to a model, executes returned tool calls, appends the results, and repeats until there are no more calls.

  3. 3

    Delegation, routing, memory, and asynchronous work can all be built from the same function-calling primitives.

Summary

Ilan Bigio presents function calling as the basic building block behind many language-model applications. He traces the path from text completion through instruction following, roles, WebGPT, and OpenAI's general function calling launch in June 2023. The workshop then builds a function-calling loop from scratch. The model chooses a function and supplies arguments, while the application parses the request, runs the code, and sends the result back. From there, Bigio implements simple memory, delegates difficult work to another model, routes requests through specialist agents, and runs independent tasks asynchronously. He explains why asynchronous work needs task IDs and status checks, and why shared conversation history must be protected from concurrent updates. The final coding example lets an agent write Python functions and add them to its own tool list, although Bigio calls the approach unsafe. He also discusses real-time voice patterns, including a function that checks whether a user has finished speaking.

Key ideas
01:38

Function calling grew from text completion into model-directed actions

Bigio describes a progression from GPT, GPT-2, and GPT-3 completing text, through instruction following and role-based conversations, to models that can use tools. WebGPT was an early example: a GPT-3 model used a specific set of web-search functions, generated actions, received the search results back in context, and used them in its response. He also discusses Meta's work on learning tool use by examining log probabilities and inserting function calls where they reduced sentence perplexity. OpenAI launched general function calling in June 2023, allowing models to use a wider range of supplied functions without task-specific training.

10:12

The application executes the function because the model only expresses intent

Bigio's crash course separates the model's decision from the application's work. The application supplies the model with function definitions and user input. The model returns a requested function and its arguments, but it does not run that function itself. The application parses the call, executes the code, appends the result to the conversation, and asks the model for another completion. He recommends clear function descriptions, documented parameters, examples, enums, and object structures that prevent invalid states. He also distinguishes functions from tools: functions are interfaces whose execution the developer handles, while tools can include hosted capabilities such as code interpreter and file search.

20:17

An agent loop is a small repeated cycle around tool calls

Bigio implements an agent as a loop. Each cycle specifies the available tools, calls the model, checks for tool calls, executes them, appends the tool results, and continues. The loop stops when the model returns no more tool calls. His example converts ordinary Python functions into the required schemas, which lets the developer write a function such as get_weather and pass it directly to the agent. He presents this as a first-principles implementation with little surrounding machinery, then uses the Swarm implementation because it provides convenient looping and handoff behavior.

26:16

Simple memory can be built with functions that read and write a list

For memory, Bigio starts with a plain list and two functions, add to memory and get memory. A function description tells the model to call the memory function when the user shares a factual detail, life information, or preference. In the live example, the user says, "I am 6 feet tall," the agent stores that statement, and a later question about the user's height retrieves it. Bigio then suggests more advanced retrieval with semantic similarity or search instead of loading every memory. For inconsistent memories, he proposes finding similar entries, asking a model whether the new entry updates or contradicts an older one, and linking the entries with timestamps.

34:16

Delegation and routing are different ways to give work to another agent

Bigio shows nested calls, handoffs, and manager-style tasks as related delegation patterns. A simple delegation function can call a stronger model, such as o1, with a task description. Handoffs replace the current agent's system prompt and tools with those of another agent. For routing, he creates a triage agent and specialist agents for email and calendar work. The triage agent receives transfer functions and hands the conversation to the appropriate specialist. Bigio calls this a convenient way to manage many functions, while advising developers to first test whether a single agent can handle the full set.

41:06

Asynchronous tasks need parallel execution and a way to check results later

Bigio compares synchronous and asynchronous work with weather requests for several cities. Blocking functions run one after another, so five one-second waits take more than five seconds. Async functions can run together when they are waiting on network calls or other non-blocking operations. He then adds task creation and status checking: the model creates a task, receives a short task ID, continues the conversation, and later calls check_task to retrieve the result. A message queue prevents multiple generations from modifying the same conversation history at once, even while independent tool calls run in parallel.

01:17:40

An agent can write and install its own tools, although executing generated code is unsafe

In the final coding section, Bigio responds to a question about generated-code agents by building a Bootstrap agent that can create Python implementations. The add_tool function parses a string containing a function definition, obtains the resulting function object, and appends it to the agent's functions. The agent then creates a tool that prints hello and later makes a small calculator. Bigio is pleased that the implementation is short, but repeatedly warns that executing generated Python is dangerous. He places the example in the category of fun experiments rather than a safe production pattern.

01:26:20

Real-time voice systems can use functions to manage turn-taking and delayed results

Bigio describes two real-time API patterns. A stay_silent function lets the model decide whether a user who paused is actually finished speaking, rather than relying only on voice activity detection. He also describes giving the model a script with XML tags so it can follow a specified speaking format. In the real-time API, a function can return no immediate response, allowing the user to keep talking while the function runs. Bigio says this asynchronous behavior had to be taught to the real-time models because a voice conversation cannot simply stop until every function result arrives.

"We now have a system where we can give it tasks and it'll queue them up and then we can check on their progress."59:02
Who should watch
  • You are building an agent and want to understand the request, execute, append, and repeat cycle without adopting a large framework.
  • Your application has many tools and you need practical options for routing, handoffs, dynamic loading, or specialist agents.
  • You are adding background work or voice interaction and need patterns for task IDs, status checks, queues, and asynchronous function results.