Template library
Start from code that runs.
Only templates marked ✓ Tested have passed an end-to-end run.
“this is how resume works: a node that raised has no saved result, so it runs again, and side effects need an idempotency key (the tool call id works well).”
Approval + resume & tool error formatting
Pause tool calls for human approval, checkpoint the run to a string, approve/reject, and resume. Plus the new run-wide tool_error_formatter that scrubs secrets from crashed tools.
Approval + resume in a fresh process (TypeScript SDK)
@openai/agents 0.21.0: needsApproval pauses the run, RunState goes to disk, a new Node process restores, approves and resumes. The tool runs exactly once.
Human-in-the-loop approval graph
A propose → approval → execute StateGraph that pauses with interrupt(), saves the pause in a checkpointer under a thread_id, and resumes with Command(resume=...) down the approve or reject path.
Idempotent approval: no double charges on resume
Resume after interrupt() charged the card twice? LangGraph re-runs the paused node from the top. This template shows the bug and the fix: approval-only node, separate execute node, idempotency key derived from thread_id.
Idempotent approved side effects
The Agents SDK runs an approved tool once per resume, but side effects still repeat on a duplicate resume of the same RunState or a whole-run retry after a crash. Shows both failures (2 charges) and the fix (1 charge).
Multiple interrupts in one node
One node calls interrupt() three times and is answered one resume at a time (matched by position), plus two parallel nodes that interrupt in the same step and are resumed together with a dict keyed by Interrupt.id.
Minimal web UI to approve paused runs
A stdlib-only web page (plain HTML forms, no JavaScript) that lists paused LangGraph runs and approves or rejects them with Command(resume=...), with 409/400/404 handling.
Tool approval with generateText
generateText with the v7 toolApproval option: refunds over $100 pause as tool-approval-request, a human approves or denies, and the run resumes. Covers $50 auto-approved, $500 approved and $500 denied.
Tool confirmation step
An ADK agent whose transfer_money tool asks a human to confirm only large amounts (require_confirmation as a callable), then runs or rejects the original call in the same session.