AI Agent Tutorial#
A series on building a minimal AI Agent from scratch. Using the Anthropic Claude SDK + Python, we start from a minimal agent loop and progressively add real tools, MCP, multi-turn conversation, persistence, context management, and RAG long-term memory. No LangChain.
Full source code: github.com/codereindeer-dev/minimal-agent
Chapters#
- CH01: Core Concepts of an AI Agent
- CH02: Providing Tools
- CH03: MCP Tool Integration
- CH04: REPL and Multi-Turn Conversation
- CH05: Short-Term Memory — Context Window Management
- CH06: Medium-Term Memory — Conversation Persistence
- CH07: Long-Term Memory — RAG
What you will learn#
- The core architecture of an AI Agent — Executor + Message + Memory + Loop, derived from first principles so you can see why every piece has to exist.
- The truth about tool calling — not magic; just a JSON tool definition for the Model to read plus a Python function for the Executor to run.
- MCP (Model Context Protocol) — the “USB standard” for tools; community MCP servers are plug-and-play and reusable across clients.
- Multi-turn REPL — an
Agentclass that keeps a messages list across turns, plusasynciofor the interactive UI. - Context window management — Rolling Summary that compresses old turns into a summary message while keeping
tool_use/tool_resultpairs intact;/compactfor manual compression. - Conversation persistence —
/savewrites the messages list to a JSON file,/loadreads it back,--resumecontinues a conversation across sessions. - RAG long-term memory —
remember/recalltools accumulate facts across sessions: Voyage AI embedding + cosine similarity + JSONL append-only store.
Who this is for#
- You already know Python basics (if not, start with the Python Tutorial).
- You want to understand what’s actually happening under LangChain / LlamaIndex / AutoGen.
- You want to write your own agent without memorizing a pile of framework APIs.
- You want to understand the common core architecture behind Claude Code, Cursor, and ChatGPT plugins.