CodeBaobab
COURSE 14 OF 21

Agents and Tool Use

Learn the published mechanisms for reasoning, tool use, planning, reflection, memory, search, and multi-agent interaction.

Background reading
Free course preview

Introduction to Agents and Tool Use

An AI agent is a system in which a model can choose an action, receive the result, and use that new information to choose what happens next. Tools give those actions an effect outside the model’s text generation.

Suppose the task asks for a fact the model does not know. A single model call can guess, but an agent can search, read the result, and decide what to do next.

Reasoning and Acting (ReAct) organizes that process as a sequence of thoughts, actions, and observations. A thought records what information is needed. An action asks the environment to do something, such as search. The observation is the result returned by that action.

The task and everything produced so far form the context. After a search result is added, the next model step can use that new evidence. It is not choosing from the original question alone.

A thought changes only the text in the context. It does not call a tool or change the outside environment. An action is different: software executes it and returns an observation.

The loop repeats until the model produces a finishing action or reaches a step limit. The pseudocode below shows that control flow directly.

Planning, retrieval, memory, and communication with other agents can be added around this loop. They are additional capabilities, not part of the definition of every agent.

ct=(o1,a1,…,ot−1,at−1,ot)A^=A∪La^t∼π(a^t∣ct)c_t=(o_1,a_1,\ldots,o_{t-1},a_{t-1},o_t)\qquad \hat{A}=A\cup L\qquad \hat{a}_t\sim\pi(\hat{a}_t\mid c_t)
Continue learning

Continue with Pro

Get Pro on codebaobab.com.

See Pro plans
Complete course

What you will learn next

  1. 01The Agent Around the Model
  2. 02The Reason–Act–Observe Loop
  3. 03What a ReAct Thought Does
  4. 04Where ReAct Still Fails
  5. 05Tool Schemas and Function Calling
  6. 06Learning When to Use a Tool
  7. 07Training Across Many APIs
  8. 08Planning Independent and Dependent Tool Calls
  9. 09Delegating Tasks to Specialist Models
  10. 10Retrying With a Stored Reflection
  11. 11Searching More Than One Trajectory
  12. 12Using Executable Code as the Action
  13. 13Memory and State
  14. 14When Agents Work Together
  15. 15Evaluating Accuracy and Cost
  16. 16The Agent Threat Model
  17. 17Follow the ReAct Trajectory
  18. 18Keep the API Call That Helps Prediction
  19. 19Run Two Independent Searches Together
  20. 20Turn a Failed Trial Into the Next Attempt’s Memory
  21. 21Use an Execution Result in the Next Turn
  22. 22Containing a Tool-Using Agent
  23. 23Comparing Agents by Accuracy and Cost
  24. 24Review
  25. 25References