An AI agent harness, built by hand

A public video series building an agent harness from scratch in Python and SQLite, with no frameworks, to show what is actually happening underneath.

Why build it by hand

Agent frameworks are useful, and they also hide the parts that matter most when something goes wrong. When an agent forgets a fact, loops, or burns through tokens, you need to know what the loop, the context window and the tools are actually doing.

This series builds a customer service agent from nothing: no libraries, no frameworks, and no AI writing the code. The goal is to make agentic systems understandable.

The agent loop sends the conversation to the model, runs the tools it asks for, and keeps history in SQLite, compacting old turns and searching them when needed.CustomerThe agent loopcall, act, observe, repeatModelToolsContext windowwhat the model seesSaved historyevery turn, in SQLiteasksanswerscompactsearch_historyOld turns leave the context, but nothing is lost: the agent can look them up.
The harness as it stands after lesson five.

Lessons so far

  • Lessons 1 and 2: the agentic loop. Setting up the project and writing the loop that calls the model, runs tools and feeds results back.
  • Lesson 3: saving conversations. Persisting sessions to SQLite so the agent can pick up where it left off.
  • Lesson 4: context compression. Counting tokens, deciding when to compress and when not to, and keeping the conversation's context separate from its full history.
  • Lesson 5: retrieval on demand. After enough compaction, the agent no longer remembered why a customer's refund was rejected two months earlier. The fix was one tool, search_history, so the agent looks things up when it needs them instead of trying to remember everything.

What it shows

Each lesson starts from a concrete failure, explains why it happens, and fixes it in plain code. The series is ongoing. Watch it on YouTube.