CSE Roadmap

Core tier · about 1 hour · 9 parts

Part 3 of 9 · 2 min read

Tools and the loop

How a model gets hands and eyes, and how repeating one step turns into an agent.

Now open the door a little. Give the friend a phone, a notepad and a list of numbers they may call. When they need a fact, they can ask you to make a call for them. You do it and slide the result back under the door.

That list of numbers is a set of tools. Your program is the person at the door who actually makes the calls.

Tool

A tool is a function your program lets the model ask for, such as "search the web", "read this file" or "look up an order". The model does not run the tool itself. It writes a request, and your program runs it and sends back the result.

Example: the model writes look_up_order(4471). Your program runs it and replies "Order 4471: shipped on Monday."

One call is not yet an agent. An agent appears when you repeat the step. Think of a cook who tastes the soup, decides it needs salt, adds some and tastes again. Nobody gave the cook a fixed list of steps. The cook looks at the result and picks the next move.

Agent

An agent is a program in which the model chooses the next action, usually in a loop with tools, and decides when to stop. Your code keeps asking the model "what next?" until the model says it is done, or until a limit stops it.

Example: an agent for refunds looks up an order, sees it came in two parcels, checks both parcels, then decides how to reply. Nobody wrote those steps in advance.

Three plain pieces make this work:

  1. A history: a growing record of what was asked, what the model did and what came back.
  2. A loop: ask the model, run the tool it asked for, add the result to the history, ask again.
  3. Limits: a maximum number of steps, and a rule for when to stop or hand over to a person.

Loop and limit

The loop is the repeat described above. A limit is a rule that stops the loop when the model will not stop on its own, such as "at most 8 steps".

Example: if the model keeps looking up the same order over and over, the limit of 8 steps ends the run instead of letting it go on forever.

Check yourself:

  • In the order example, who runs look_up_order: the model or your program?