Chapter 13

Tool Use & Function Calling

How assistant behavior expands once the model can call external tools instead of only emitting plain language.

Foundations 1-3
SFT 4
Reward Signals 5
Policy Optimization 6-9
Preferences & Data 10-13
Controls & Product 14-17

Tool use changes what generation means

A tool-using model is not simply predicting the next word. It is deciding when to speak, when to call a function, and how to integrate the result back into the conversation.

That means the policy now operates over a mixed action space: text actions and tool actions.

This is why tool use is conceptually adjacent to RL even when trained with supervised traces.

Tool use interleaves model generation with external execution: the model generates tokens until it emits a tool call (orange), an external system executes the tool and injects the output (purple) into the sequence, then the model continues generating. Models can emit multiple tool calls in a single generation. During training, tool call and output tokens are typically masked from the loss.
Chapter 13 Tool use interleaves model generation with external execution: the model generates tokens until it emits a tool call (orange), an external system executes the tool and injects the output (purple) into the sequence, then the model continues generating. Models can emit multiple tool calls in a single generation. During training, tool call and output tokens are typically masked from the loss.

The hard part is interleaving reasoning and execution

Tool calls matter because they interrupt pure generation. The model has to maintain state across external execution boundaries.

Training data therefore needs to show not just the final answer, but the sequencing logic of when tools are invoked and how outputs are consumed.

The educational point is that tool use is choreography, not only API syntax.

Protocols become part of alignment

Once tools are involved, schemas, function signatures, and context protocols constrain what the model can do.

These interfaces act like alignment scaffolding because they define safe and unsafe pathways for action.

A model with tools is partly aligned by training and partly aligned by the software contract around it.

Review

5 quick checks

Questions with revealed answers.

1 Why does tool use change the nature of generation?

Because the model is no longer only producing text; it is also choosing external actions and integrating their results.

2 What is the key sequencing challenge in tool-use training?

The model must learn when to emit a tool call, how to wait for the tool result, and how to continue generation afterward.

3 Why are function schemas and protocols important?

They define the action contract, shaping what the model can safely and effectively do with external systems.

4 How is tool use related to alignment?

The surrounding software interface constrains behavior, so safe tool use depends on both model training and protocol design.

5 What is the shortest useful intuition for tool-using assistants?

They are language models that learn to alternate between talking and acting.