SESSION 3 · ~60M
The agentic loop: tools & context
An agent is just a loop — read, act, observe, repeat — and managing what fills that loop is the whole job.
An agent is a model wrapped in a loop: it reads its task, chooses a tool, takes an action, observes the result, and repeats until done. Understanding this loop is the difference between using AI as a chat box and using it as a worker.
The loop, step by step
- Read — the model takes in the task plus whatever context you've provided (files, prior steps, tool results).
- Decide — it chooses the next action: call a tool, ask you a question, or declare the task done.
- Act — the harness runs the chosen tool (edit a file, run a command, search) and returns the output.
- Observe — the tool output joins the context, and the loop repeats from Read.
Permissions: the safety rail
Because agents can take real actions — write files, run shell commands, call APIs — every serious agent has a permission layer. You decide what's auto-approved (read a file) versus what needs confirmation (run a deploy, delete anything). Treat permissions as your brake pedal, not bureaucracy.
Context is the real bottleneck. Everything the agent has seen fills a finite window; when it fills with stale output or irrelevant files, performance drops even though the model hasn't changed. The skill is curating context — feeding less, better-chosen information beats dumping everything in.
This is why agents degrade on long tasks: the context window clogs with intermediate results. Counter it by giving the agent a clear goal, asking it to summarize progress periodically, and starting fresh sub-tasks in clean contexts rather than one giant thread.
TRY IT
In Claude Code, give an agent a small multi-step task ('read this file, find the bug, fix it, run the tests'). Watch the loop in the output: you will literally see read, decide, act, observe cycling. Once you can see the loop, you can steer it.
CHECK YOUR UNDERSTANDING
What are the four steps of the agentic loop, in order?
According to the module, what is the real bottleneck that causes agents to degrade on long tasks?
What role do permissions play in an agentic system?
NOTEBOOKLM
Connect your notebook
Paste a NotebookLM share link to embed your notebook for this module.