Build AI Agents from Scratch with Python
Tool calling, planning loops and memory — no framework required.
Taught by Rohan Maharjan · ML Engineer
What you'll learn
- Explain what distinguishes an agent from a chatbot and when an agent loop is worth the complexity
- Call a chat model from Python with system prompts, message history and structured JSON output
- Define tools with JSON Schema and dispatch model tool calls to real Python functions
- Implement a plan-act-observe loop with termination conditions and error handling
- Add short-term context management and long-term memory with a simple vector store
- Apply guardrails, budgets and an evaluation harness before shipping an agent
About this course
Build AI Agents from Scratch with Python teaches you how agentic AI actually works by having you write every part yourself: the model call, the tool schemas, the plan-act-observe loop, short- and long-term memory, guardrails and evaluation. Frameworks hide these mechanics; understanding them makes you a far better user of any framework later and lets you debug agents that misbehave. The course is for developers comfortable with Python functions, classes and JSON who have used a chat model API at least once. You will use the OpenAI Python SDK against a chat completions endpoint, but every pattern transfers to other providers. By the end you will have a working research-assistant agent with function calling, a persistent memory store, cost and safety limits, logging and a small evaluation suite, all in under a few hundred lines of code you fully understand.
Course content
8 lessons- 1What an Agent Is, and When You Need OneAgents versus chains versus chatbots, the plan-act-observe loop, and the anatomy of the agent you will build.Preview
- 2Calling a Model from PythonSet up the SDK, manage message history, control temperature and get reliable JSON out of the model.
- 3Tool Calling and JSON SchemasDescribe Python functions as tools, let the model request them, validate arguments and return results.
- 4The Agent Loop: Plan, Act, ObserveAssemble the loop with step limits, termination conditions, error recovery and readable traces.
- 5Memory: Context Management and Long-Term StorageTrim and summarise conversation history, and add a small embedding-based memory the agent can read and write.
- 6Guardrails: Limits, Validation and Safe ToolsBudgets, input and output checks, permissioned tools and prompt-injection defences that keep an agent inside bounds.
- 7Evaluating AgentsBuild a task suite with automatic checks, measure success and cost, and use traces to find and fix failures.
- 8Shipping: Logging, Tracing, Cost Control and StructurePackage the agent as a service with structured logs, run ids, cost tracking, streaming and a clean module layout.