Hands-on course
Agentic AI, End to End
Build a production-shaped AI agent from scratch in plain Python: the loop, tools, memory, tracing, evals, guardrails and retrieval. No framework, so when you later use LangGraph or CrewAI you already know what they do for you.
- 24 lessons in 6 parts
- ~4 hours of reading, plus exercises
- 116 tests you run yourself
- Runs offline, no API key
How each lesson works
- 1. Read what you will buildEvery lesson opens with a card naming the file it builds, its tests and the command to run.
- 2. Open the code beside itClick the file in the card. The lesson walks through it section by section.
- 3. Run the tests, do the exerciseEach lesson ends with an exercise and a checkpoint, so you know you have it.
Get the code first
One zip with the library, the demo and all tests. Python 3.10+, standard library only. Unzip, then run python3 demo.py.
Syllabus
Six parts. Do them in order: each part uses the code from the one before.
Build an Agent From Scratch
Make It Not Break
Give It Knowledge
Scale the Pattern
Run It in Production
Ship Something
What you actually build
from agentic import Agent, FakeModel, Registry, tool, tool_call
@tool(description="Look up an order by id.", order_id="The order id.")
def get_order(order_id: str) -> dict:
return {"id": order_id, "status": "delivered"}
model = FakeModel([
tool_call("get_order", {"order_id": "4471"}),
"Order 4471 was delivered.",
])
run = Agent(model, Registry([get_order])).run("Where is order 4471?")
run.output # "Order 4471 was delivered."
run.trajectory() # ["get_order"] - tools that actually RAN
run.stop # Stop.ANSWERED
By the end you have added budgets, tracing, an eval suite, a judge, hybrid retrieval, injection containment, and a capstone you can put in front of an interviewer.
Three ideas the whole course turns on
A loop with no budget is not an agent. It is a while loop with a credit card attached. Every run in this course ends with a named stop reason — answered, step budget, cost budget, repeated call, fatal tool error. There is no unnamed terminal state, because “it just stopped” is how you get a surprise invoice.
Requested is not executed. run.trajectory() lists tools that actually ran. run.requested_tools() lists what the model asked for. Conflating them makes a working guardrail look like a breach — a blocked injection would fail a never_used("refund") assertion even though the defense held. Writing the tests for this course is what surfaced that bug in my own code.
Prompt injection is contained, not prevented. Instructions and data share one channel, so no phrasing makes a document’s text non-instruction. The course therefore removes capability rather than trying to detect attacks: a context that has read untrusted text loses its mutating tools. Demo scenario 3 shows a fully compromised model that still cannot issue the refund.
The library you build
Eight modules, each short enough to read in one sitting. Click a file to read it; every lesson page links the file it builds.
| File | What it is | The lesson it teaches |
|---|---|---|
model.py |
Model boundary, FakeModel, HTTP adapter |
Why one seam makes everything testable |
tools.py |
Schemas, validation, authorization, dispatch | This is the security boundary |
loop.py |
The loop, budgets, named stop reasons | What every framework wraps |
memory.py |
History, summarization, fact store | Memory poisoning is the real risk |
trace.py |
Spans, token and cost accounting, redaction | The trace is the bug report |
evals.py |
Golden cases, trajectory scoring, judge | The skill that gets you hired |
guard.py |
Fencing, policy, egress, confirmation | Containment when prevention fails |
retrieval.py |
Cosine, vector store, BM25, RRF, rerank | Why hybrid beats dense-only |
Tests as the curriculum
The test names tell you what the course is really about:
test_step_budget_stops_a_runaway_agent
test_repeated_identical_call_is_detected
test_internal_exception_does_not_leak_details_to_the_model
test_unknown_tool_does_not_reveal_hidden_tools
test_missing_confirm_handler_crashes_rather_than_degrading
test_permission_filter_runs_before_ranking
test_rrf_combines_by_rank_not_score
test_always_pass_judge_has_zero_kappa_despite_high_agreement
test_injected_document_cannot_reach_a_mutating_tool
test_protected_keys_cannot_be_written_by_an_agent
Each encodes a failure mode that costs real money. Two of them exist because writing them found genuine design bugs in the library.
Honest limitations
Stated up front, because a course that hides its simplifications teaches you to trust the wrong things.
HashingEmbedderis a bag-of-words hash, not a semantic model. It cannot tell “cheap” and “inexpensive” are related. It exists so the retrieval mechanics run offline. Swap in a real embedding model for anything real — and note that doing so means re-indexing your whole corpus, never a config flip.VectorStoreis exact brute-force search, linear in corpus size. Real systems use approximate indexes and treat recall as a tunable SLO. Brute force is the baseline you measure those against.guard.scanis a pattern matcher and will always be incomplete — an attacker needs one phrasing you did not think of. Use it for triage, never as the thing standing between an attacker and a tool.- No async. The library stays synchronous so the control flow is readable.
Prerequisites
Working Python and comfort with HTTP APIs. You do not need a maths background, a PhD, an ML background, or a GPU. If you want the conceptual grounding first, the AI Engineer track covers the vocabulary; this course is the hands-on half.
Related on SystemCraft
- Become an AI Engineer — the 36-topic reference track this course implements
- Design ChatGPT — the system-design view of an AI product
- System Design Concepts — idempotency, queues, caching, observability
- DSA Problemset — the coding round is still an ordinary coding round