
Meet Nightshift, an agent with 600 support tickets and one night to clear them, and get the roadmap for the course.
How to read code cards, how the quizzes work, and where to download the pattern cards, map and checklist.
The pattern cards, the pattern map and the overnight checklist, with when to use each one.
The minimal agent loop and the idea of a harness: the foundation every later code card builds on.
One failed night shows the 5 failure modes: forgetting, dying, getting stuck, lying and acting recklessly.
Why long context gets slower, pricier and less accurate, and how to budget it.
When to summarize history, what to keep, and why a structured template beats a free-form summary.
Shrink tool outputs you no longer need into short placeholders and save most of your tokens.
Give the agent an index and search tools instead of stuffing everything into the prompt.
Send "read a lot, conclude a little" work to a sub-agent that returns only a short summary.
A shift handover log that tells a fresh session exactly where to pick up.
Track progress in a JSON work list the agent can update but never rewrite.
Log every action with real-world effects, and plan how to make up for what can't be undone.
One session sets up the scaffolding; every later session finishes one small batch.
What the first three sections fixed, what still breaks, and three questions to check your own agent.
Have the agent write a short plan before acting and update it as it goes.
Spot the signals that call for a new plan, like 120 tickets caused by one delayed carrier.
Keep the goal and a "do not" list fresh in context so the agent doesn't drift.
Size each session as one verifiable unit of work: not too big, not too fragmented.
Why processes die, what losing state costs, and what durable execution means.
Save state after every step and restart from the last one after a crash.
Rebuild state by replaying recorded events, the way workflow engines do.
Use idempotency keys so a tool called again after a crash never refunds twice.
When hand-rolled checkpoints are enough and when to adopt Temporal, Inngest or similar.
Options for running an agent on a server and on a schedule, safely sandboxed.
Suspend a ticket, free resources and let a webhook wake the agent up.
Design an agent driven by events, which only interrupts people when it really matters.
Process many tickets in parallel with leases, rate limits and per-customer locks.
Retry only temporary errors, with backoff, jitter and a timeout on every tool.
Detect repeated calls and errors automatically and break useless loops.
Cap token spend and real refunds per step, per ticket and per night.
Clear stop conditions, and how to give up responsibly by handing off to a human.
Keep running when a provider or API fails, with circuit breakers and fallback models.
The common ways agents claim work they didn't do, and why it happens.
Define "done" with code checks: policy rules, matching actions and the right customer.
Add an independent reviewer with a rubric for what code can't check.
Reconcile refunds and emails every hour to catch errors before 7 AM.
Rank tools by risk and put the dangerous ones behind an approval gate in code.
Protect an unattended agent from prompt injection hidden in customer emails.
Request approval, park the ticket and keep working until a human says yes.
When to escalate a ticket, and how to hand it off so nobody rereads everything.
An orchestrator assigns tickets to specialist workers running in parallel, then merges the results.
A compact handoff package that passes what matters without the whole context.
This course contains the use of artificial intelligence.
Building an AI agent that works for five minutes is easy. Building one that works for five hours, unattended, is a different problem.
Leave an agent running overnight and it breaks in predictable ways. Its context fills up and it starts mixing up customers. The server restarts at 2 AM and nobody knows whether that refund went through. It gets stuck in a loop and burns money until morning. It marks work as "done" when nothing was done. And sometimes it takes an action nobody can undo.
This course teaches the design patterns that prevent each of these failures. They are the same patterns behind today's coding agents, background agents and durable workflow engines, explained clearly enough that you can apply them in any stack.
One story, one night, one agent
The whole course follows Nightshift, an agent working the night shift at Pebblecart, a small online store with 600 support tickets left over from Black Friday. Nightshift has real tools: it looks up orders, reads the refund policy, emails customers and issues refunds.
The first night goes badly. Section by section, you give Nightshift the patterns it needs, and in the last lesson it finishes a full night: tickets resolved, risky refunds waiting for approval, hard cases handed to humans, and a sensible bill.
The 5 ways long-running agents break, and what you'll learn to fix them
Forgetting: compaction, clearing tool results, just-in-time retrieval, sub-agents, progress files, structured work lists, goal anchoring.
Dying: checkpoints, event logs and replay, idempotent tools, workflow engines, suspend and resume with webhooks, work queues with leases.
Getting stuck: retries with backoff, loop detection, token and money budgets, stop conditions, circuit breakers and fallback models.
Lying: verification with facts instead of the agent's word, evaluator–optimizer reviewers, overnight reconciliation.
Acting recklessly: approval gates, async human approval, escalation, and defending against prompt injection in customer emails.
You'll also learn when multiple agents beat one, how to hand off work between agents, how to trace an 8-hour run, and how to cut the cost of a night's work.
What makes this course different
Patterns, not a framework. Everything applies whether you use the Claude Agent SDK, LangGraph, Cloudflare Agents, Temporal, Inngest or your own loop. Each lesson ends with where the pattern already exists in popular platforms.
Short, focused lessons. Every video is 3 to 6 minutes and teaches one pattern.
Animated diagrams instead of slides. Every idea is drawn and animated step by step, so you can see the mechanism, not just hear about it.
Pseudocode code cards. Each pattern ends with a short pseudocode card you can translate into any language. The harness grows lesson by lesson, with new lines highlighted.
No setup, no repo to maintain. Watch on your phone, on the train, or between meetings.
Also included
A scenario quiz at the end of every section, based on real incidents from Nightshift's nights
A final assignment: design the harness for your own agent on one page
Pattern cards (PDF): one card per pattern with the problem, diagram, pseudocode and trade-offs
Pattern map (PDF): every pattern on one page, organized by failure mode
Overnight checklist (PDF): what to check before you let an agent run unattended
By the end of this course, you'll be able to look at any agent, predict how it will fail on a long run, and choose the patterns that keep it on track.
Enroll now and give your agent a night shift it can survive.
This course is independent and is not affiliated with or endorsed by any of the companies or products mentioned. Pebblecart and Nightshift are fictional names created for this course.