Build an AI Agent from Scratch in Python
You write one agent by hand, with no framework: a customer support agent for a small online shop, on the command line. Given a customer's message, it searches and reads the shop's help pages, looks up the order, decides what to do and saves an action with a reply to the customer. Each lesson adds one part: the loop, the tools, the final result, the limits, the tests, the memory. You can already call a model from Python and use tool calling; every check runs on saved model replies, so you need no key.
What this course covers
- What an Agent Is: the Loop in a Few Lines: Explain what makes a program an agent, decide whether a task needs one, and write the loop that lets a model use a tool as often as it chooses before it answers.
- Tools the Agent Can Use Well: Give an agent several tools through one registry, shape their descriptions and results so the model chooses well, and return failures the model can recover from.
- Instructions and a Result Your Code Can Use: Write instructions that tell an agent its goal and when it is done, and make it finish by handing over a validated result that the program saves.
- Stop Conditions: Keep the Loop Under Control: Bound an agent loop with a step limit and a repeated-call check, and make every run end with a named reason and a result the caller can act on.
- Test the Agent with a Fake Model: Write fast, repeatable tests of an agent loop by scripting a fake model, and check both the steps the agent took and the result it produced.
- Short-Term Memory: Keep a Long Run Small: Measure how the transcript of a run grows, and keep it small by clearing old tool results without breaking the conversation or losing what the agent still needs.
- Long-Term Memory: Notes That Outlive a Run: Give an agent a memory that outlives a run: notes it writes to a file, loaded into later runs, and kept small and correct.