Tutorials
Building things,
explained slowly.
Long-form, code-heavy deep dives on AI agents, voice systems, and observability — the kind of writing I wish existed when I was figuring this out.
The State Machine You Were About to Write Already Exists — LiveKit Voice Agents
Phone agents need dates, room types, and callback numbers. The instinct is a CallState dataclass and next_question(). LiveKit Agents already solved that with AgentTask and TaskGroup — here's the hotel receptionist that shows how.
livekitvoice-aipythonBuild a Mastra Agent From Scratch — Tools, Memory, and the Loop (Part 1)
Every new agent project starts with the same hand-rolled loop. Part 1 of the Mastra series: define a typed agent, wire tools with createTool, and add memory so it survives the next turn — without rebuilding the plumbing again.
mastraagentstypescriptWhen Your Agent Skips the Eligibility Check — Mastra Workflows (Part 2)
Agents decide. Workflows guarantee. Part 2: typed multi-step pipelines with sequencing, parallelism, branching, loops, and human-in-the-loop suspend & resume — for the steps where order isn't up for a vote.
mastraworkflowstypescriptAn Agent Loop Is Not an App — Mastra's Harness (Part 3)
Refresh the tab. Approve a delete. Hand off a subtask. Part 3: Mastra's AgentController adds sessions, modes, subagents, and tool approvals — the layer that turns a loop into something users can depend on.
mastraagentsharnessWhy Users Think Your Agent Is Frozen — Streaming to a Real UI (Part 4)
Ten seconds of silence looks identical to a crash. Part 4: wire agent.stream() into a UI — tokens, tool calls, and custom progress events — so users watch the work happen instead of staring at a spinner.
mastrastreamingtypescriptYour Agent Is Still Guessing — Mastra RAG With Citations (Part 5)
A confident answer with no source is still a hallucination waiting to happen. Part 5: chunk, embed, store, query — wire a retrieval pipeline under your agent so it answers from your documents, with citations.
mastraragembeddingsSome Agent Work Outlives the HTTP Request — Durable Agents (Part 6)
Forty-page scrape. Human approval that takes a day. A cron job at 3am. Part 6: background tasks, crash-proof durable agents, and heartbeats — machinery for work that doesn't fit in one request.
mastradurablebackground-tasksAn Agent Without Evals Is a Vibe With a Deploy Button (Part 7)
The demo sounds sharper. Production quietly gets worse. Part 7 — the series finale: deterministic checks, model-graded scorers, CI gates, and live sampling so 'it seems better' becomes '0.86, up from 0.71'.
mastraevalstestingBuild a Harness Agent From Scratch
Picture the demo — model, tools, while loop, done. Then someone refreshes the browser and it's gone. This tutorial builds the layer around the loop: sessions, persistence, approvals, and a UI contract — by hand, with the OpenAI SDK.
agentsarchitecturetypescript