Temporal AI Cookbook
by Temporal
Thirteen runnable recipes for the question no agent framework answers: what happens when your agent's process dies halfway through.
Overview
The Temporal AI Cookbook is a free collection of thirteen self-contained, runnable Python projects showing how to make LLM agents survive process crashes, restarts and multi-day pauses using Temporal's durable execution. The premise is that a Temporal workflow reads like ordinary async code, but every step is recorded in an append-only event history held by the Temporal service; when a worker dies, a new one replays that history, skips the activities that already completed, and resumes exactly where the run stalled. The Foundations recipes start at hello world with the OpenAI Responses API, then cover structured outputs, multi-provider calls through LiteLLM, and retry policies driven by HTTP response codes from flaky model endpoints. The Agents recipes build a basic agentic tool-calling loop against both Claude and OpenAI, then show durable agents wrapping the OpenAI Agents SDK and the Strands Agents SDK with activity-backed tools, plus a human-in-the-loop agent that can block on an approval for as long as the human takes. Two infrastructure recipes cover a durable MCP weather server implemented as a Temporal workflow, and the claim-check pattern for keeping large payloads out of event history. A deep-research recipe assembles planning, web search and synthesis into a multi-agent system. Every recipe lives in the temporalio/ai-cookbook GitHub repository as a complete project rather than a snippet, and Temporal itself is the durable-execution layer behind production systems at Netflix, Snap and NVIDIA, so the patterns are not toy-scale.
At a Glance
- Topic
- Agentic
- Level
- Intermediate
- Format
- Tutorial
- Cost
- Free
- Duration
- 13 self-contained recipes, ~30-60 min each (~4-6 hours end to end), self-paced
- Provider
- Temporal
- Hands-on
- Yes — code/exercises
- Certificate
- None
What You’ll Learn
- ✓Make an LLM call durable so a worker crash resumes the run instead of restarting it
- ✓Reason about append-only event history and replay, and why completed activities are skipped
- ✓Wrap an OpenAI Agents SDK agent in a Temporal workflow with minimal changes to agent code
- ✓Build a durable agentic tool-calling loop against Claude and against OpenAI from scratch
- ✓Pause an agent for human-in-the-loop approval and resume it hours or days later
- ✓Serve a durable MCP server whose tool handlers are backed by Temporal workflows
- ✓Apply the claim-check pattern to keep large payloads out of workflow event history
- ✓Set retry policies driven by HTTP response codes from rate-limited or flaky model APIs
Highlights
- •Fills the gap every agent framework leaves open: reliability when the process dies mid-run, not just orchestration when it doesn't
- •Recipes are self-contained runnable projects in temporalio/ai-cookbook, not fragments you have to assemble yourself
- •Covers both framework-level integration (OpenAI Agents SDK, Strands Agents SDK) and raw OpenAI, Claude and LiteLLM calls, so it is useful whatever you already run
- •The durable MCP server recipe is genuinely rare — nearly all MCP material assumes a stateless, short-lived server
- •Human-in-the-loop as a first-class durable pattern rather than a polling hack, which is what long-running enterprise agents actually need
Who It’s For
Best For
- ✓Engineers whose long-running or multi-step agents fail halfway and have to start over
- ✓Teams adding human approval gates to agents that may wait hours or days for a decision
- ✓Backend engineers responsible for turning an agent prototype into something on-call can support
Prerequisites
- •Working Python and comfort reading and writing async code
- •Familiarity with LLM tool calling, either raw or through one agent framework
- •No prior Temporal experience needed — the Foundations recipes start at hello world
FAQ
What is Temporal AI Cookbook?
A free, code-first cookbook for making LLM agents durable. Each recipe is a working Python project showing how Temporal's append-only event history lets an agent survive worker crashes, flaky model APIs and multi-day human approvals without losing state. Covers raw OpenAI and Claude tool loops, the OpenAI Agents SDK and Strands Agents SDK, durable MCP servers, and a multi-agent deep-research system.
Is Temporal AI Cookbook free?
Temporal AI Cookbook is free to access.
What level is Temporal AI Cookbook for?
Temporal AI Cookbook is aimed at a intermediate audience. Recommended background: Working Python and comfort reading and writing async code, Familiarity with LLM tool calling, either raw or through one agent framework, No prior Temporal experience needed — the Foundations recipes start at hello world.
How long does Temporal AI Cookbook take?
Expect roughly 13 self-contained recipes, ~30-60 min each (~4-6 hours end to end), self-paced. Most learners work through it at their own pace.
What will I learn from Temporal AI Cookbook?
You'll learn: Make an LLM call durable so a worker crash resumes the run instead of restarting it; Reason about append-only event history and replay, and why completed activities are skipped; Wrap an OpenAI Agents SDK agent in a Temporal workflow with minimal changes to agent code; Build a durable agentic tool-calling loop against Claude and against OpenAI from scratch; Pause an agent for human-in-the-loop approval and resume it hours or days later; Serve a durable MCP server whose tool handlers are backed by Temporal workflows; Apply the claim-check pattern to keep large payloads out of workflow event history; Set retry policies driven by HTTP response codes from rate-limited or flaky model APIs.
Topics
Sources
This page was written from 2 sources, 1 on domains other than docs.temporal.io.