Prompting and tools · about 15 minutes of study

Tool calling

Tool calling lets a model propose a named operation with arguments. Application code validates and executes permitted operations, then returns the result.

Before you start: Review Structured output first. Python-like examples use variables, lists and functions.

Guided concept walkthrough

Follow the mechanism

Proposal

The model requests a named operation.

1 / 4

A conceptual animation, not a live model trace. Play advances every five seconds and stops at the final stage.

Start with an everyday explanation

An assistant can fill in a request slip. The service desk checks the slip and the requester before doing the work. A proposed operation is not an executed operation.

See a concrete example

lookup_policy({id:POL-42}) is checked against the signed-in user. A payment tool additionally requires explicit approval and a deduplication key.

A claim to question

The model does not safely execute arbitrary code just because it returned a tool name.

Try before revealing the answer

Sketch a dispatcher that rejects an unknown tool and a policy ID belonging to another user.

Show the worked answer

Check the allowlist, validate arguments, authorize the resource, execute with a timeout and return a typed result. Never use eval on model-provided text.

Now explain the idea to someone else using your own example. If you cannot explain a stage, revisit it before moving on.

Your explanation and revision notes

Loading local notes…

Read the primary reference

Attention Is All You Need

The explanation and exercises are original teaching material. The linked source provides background; examples and assumed numbers here are not claims about a particular company.