Lesson 13.01 · Phase 13 · Production Agents
From notebook to service
The agent loop doesn't change when it goes to production. Everything around it does: input you don't trust, traffic you don't control, runs that take too long, and a platform that restarts you whenever it likes.
Learning objectives
- Put an agent behind an HTTP API with asynchronous runs: POST returns 202 and a run id; GET polls the status.
- Validate every request and return a 400 with a reason. Bound the work with a worker pool and a queue, and shed load with 503 + Retry-After.
- Give every run a deadline, make retries safe with an Idempotency-Key, and write structured logs with a request id.
- Add health and readiness endpoints, and shut down gracefully: stop accepting, finish what's running.
The notebook version works: answer = runagent("What is our refund window?"). Then you wrap it in a web framework, one route, return runagent(request.json["task"]), and deploy it.
Loading the full lesson…