AI agents from the ground up
Loops that act, stop and stay inside their permissions
- Intermediate
- 10 chapters
- 157 min read
What an agent actually is: a loop of observe, decide and act with a budget and three exits. Build one from scratch — tools with schemas, planning and replanning, working and long-term memory, permission checks the model cannot edit, delegation with a contract, and a capstone research agent with a trace.
What You'll Learn
- Explain the loop that makes a program an agent
- Design a small action space with validated arguments
- Bound a loop with step, time and progress exits
- Plan a task, and replan only the unfinished tail
- Separate scratchpad, transcript and long-term memory
- Write a policy that decides who may call what, and when a human must approve
- Delegate to a sub-agent with a contract, a budget and no escalation
- Build a bounded research agent with a readable trace
Prerequisites
- Comfortable with Python functions, dictionaries and classes
- The LangChain course is useful but not required
- No API key is needed — every example uses a scripted model
Vocabulary
The terms the chapters assume, in plain words.
- action space
- The full set of moves an agent can choose from, usually the list of tools it is given.
- agent
- A program that repeats a loop: read the state, choose a move, look at the result, then decide again.
- budget
- A hard limit on how many steps, seconds or moves a run may spend before it must stop.
- delegation
- Handing a smaller task to another agent, with its own instructions, tools, budget and required result shape.
- guardrail
- Code that checks a proposed move against the rules before it runs, and can refuse it or ask a person.
- loop
- The repeated cycle of choosing a move, carrying it out and reading the result, which makes a program an agent.
- model
- The trained program that reads text and chooses what to say or do next.
- observation
- What came back from a tool or a step, added to the state for the next decision.
- plan
- A written list of steps for the task, which can be revised when a step fails or the facts change.
- scratchpad
- The working notes for one run: the plan, what was tried and what came back, discarded when the run ends.
- state
- The record of the question, the plan and the observations so far, passed to the model on every turn.
- sub-agent
- A separate agent given one bounded job, its own tools and its own budget, whose answer returns to the caller.
- tool
- A named function an agent may ask to run, with declared inputs and a result the loop can read.
- trace
- The ordered record of every decision, tool use and result in a run, used to explain what happened.
Course Content
- 01What an agent isNot started
A chain answers once. An agent acts, looks at what happened, and decides again. The difference is a loop and a budget, not a smarter model.
- 02Tools and the action spaceNot started
The tool list is what an agent can do, and therefore what an attacker can make it do. Every tool needs a name, a schema, a validation rule and a failure path.
- 03The loop and its limitsNot started
Every agent loop needs three exits: answered, out of budget, and going nowhere. The third one is the one people forget.
- 04Planning and replanningNot started
A plan is a list of steps with a check after each one. Its value is not the list — it is knowing which step failed and being able to change only that step.
- 05Memory for agentsNot started
Three kinds of memory, three jobs: the scratchpad for this run, the transcript for this conversation, and a store for facts that outlive both.
- 06Permissions and guardrailsNot started
An agent with a tool can be talked into using it. The guardrail is a policy the model cannot edit: who may call what, with which values, and when a person must approve.
- 07Delegation and handoffsNot started
A sub-agent is a function call with a prompt. It earns its cost when the subtask has its own tools and its own context — and it needs a contract, a budget and a way to fail.
- 08Agent evaluationNot started
An agent is judged by its trajectory as well as its answer. Score the tools it chose, the steps it took and the budget it used, then watch the pass rate over time.
- 09Failure recoveryNot started
Tools time out and providers rate-limit; that is ordinary weather, not an exception. Classify the error, retry only what is safe, then replan or stop with a trace that says what happened.
- 10Capstone: a bounded research agentNot started
A complete agent in one file: tools with schemas, a plan, three exits, a permission check, an approval, a budget and a trace. Every idea in the course, once.
