How AI Agents Work
Planner, Tools, Memory, and the ReAct Loop
AI agents are software systems that do more than generate one response. They can break a goal into steps, use outside tools, store useful information, and update their next action based on results. This matters because many real tasks, such as scheduling, coding, research, and robotics, require a loop of thinking, acting, and checking rather than a single answer.
A typical AI agent starts with an input goal, builds a plan, chooses tools, performs actions, reads feedback, and revises its next step. Memory helps the agent keep track of past interactions, important facts, and intermediate results across the task. Reasoning helps it compare options and detect errors, while the action loop lets it continue until it reaches a stopping condition such as success, timeout, or human approval.
Key Facts
- Agent loop: observe -> plan -> act -> evaluate -> repeat
- A planner decomposes a goal G into subgoals {g1, g2, g3, ...}
- Tool use extends capability: output = model(input, tool_results, memory)
- Working memory stores short term state, while long term memory stores reusable facts and past outcomes
- A simple score for choosing an action can be written as U(a) = expected benefit - expected cost
- The loop ends when goal_reached = true, max_steps reached, or confidence drops below a safety threshold
Vocabulary
- AI agent
- An AI agent is a system that can perceive information, make decisions, and take actions to pursue a goal.
- Planner
- A planner is the part of an agent that breaks a large task into ordered steps or subgoals.
- Tool use
- Tool use means the agent calls external resources such as calculators, search systems, databases, or code runners to get results.
- Working memory
- Working memory is the short term information the agent keeps active during the current task.
- Feedback loop
- A feedback loop is the cycle in which the agent checks the result of an action and uses that result to decide the next step.
Common Mistakes to Avoid
- Thinking the model alone is the whole agent, which is wrong because an agent usually includes planning, memory, tool access, and control logic around the model.
- Assuming memory means perfect recall, which is wrong because stored information can be incomplete, outdated, or retrieved at the wrong time.
- Using tools without verification, which is wrong because tool outputs can contain errors or irrelevant data that should be checked before the next action.
- Treating the first plan as fixed, which is wrong because effective agents revise plans when feedback shows failure, new constraints, or better options.
Practice Questions
- 1 An agent has a goal that it breaks into 4 subgoals. Each subgoal requires 3 tool calls and 1 evaluation step. How many total tool calls and evaluation steps are needed if all subgoals are completed once?
- 2 A memory system stores 12 facts from earlier tasks. During a new task, the agent retrieves 5 facts, but 2 are irrelevant. What fraction and percentage of the retrieved facts are useful?
- 3 Explain why an agent that can use tools but has no memory may perform worse on a multi step task than an agent with both tools and memory.