From “Building AI Agents in Pure Python - Beginner Course” by Tech With Tim
Building an AI agent in pure Python
Three simple parts become a working coding agent.
Stages of the build
- Intro: what an agent is — The presenter introduces the video and the idea that an agent is a model, tools and a loop. 0:21
- An agent is three things — Slides explain that a model, tools and a loop make up what Claude Code, Codex and Cursor run on. 2:31
- First script: calling the model — The code in step1.py calls an OpenAI model, then adds a system rule and assistant message to shape its answer. 3:51
- Memory is just a list — Slides and step2.py show that the conversation is kept as a list of messages resent with each request. 12:01
- Step 3: tool calling — The model asks for a read_file tool call, a schema describes the tool, and Python runs it and returns the result. 17:51
- Looping until no tool calls remain — The loop runs repeatedly until the model stops requesting tools, and the guardrails and context are built up. 27:51
- Full coding agent with a snake game — agent.py adds list, read, write and run-command tools and a system prompt, then builds a snake game in the terminal. 32:51
Things on screen worth a look
- What the model doesn't do — A card reads 'It doesn't call a tool' under the heading 'What the model doesn't do'.
- read_file tool schema — The schema lists the name read_file, a path parameter of type string, and a required field.
- list_files schema in agent.py — A highlighted schema for list_files describes listing a directory with a path parameter.
Words the build depends on
- Term: Agent · What the video says: A model, some tools and a loop working together, as shown on the slide.
- Term: Context window · What the video says: The conversation list resent with every request; when it grows large, agents summarise it (compaction).
- Term: Schema · What the video says: A breakdown of how a tool works, its parameters and what it returns.
Setting up Claude Code and building games with itTech With Tim
Building an authenticated MCP server in PythonTech With Tim
CSS Cross-Page Transitions and Shared Image AnimationCoding2GO
Six CSS features that replace JavaScriptCoding2GO