# Practical and Useful Patterns for OpenAI Agent SDK
🌍 What happens when your agent workflow takes hours or days — and the process crashes midway?
Durable execution integrations let you build resilient long-running and human-in-the-loop workflows.
📌 Title: Running agents – Durable execution integrations
🔗 URL:
🧩 Overview
Durable execution integrations persist agent execution state so that workflows can resume from the last checkpoint after process crashes or server restarts. This is essential for human approval workflows (waiting hours to days) and long-running batch processes. The SDK supports integration with Temporal, Dapr, Restate, and DBOS.
🛠 Usage
This example combines DBOS with the Agent SDK. Initialize with `DBOS()`, then define an agent via `Agent(name="approval-agent", instructions="...")`. Inside a `
@DBOS.workflow()`-decorated async function `expense_approval_workflow(report_id)`, call `await input=...)` to analyze the expense report, then `await DBOS.recv(f"approval-{report_id}", timeout_seconds=86400 * 7)` to wait up to 7 days for approval. If `approval["approved"]` is `True`, call ` again to process the approved report.
🏗 Practical Patterns
**Human Approval Workflows**
For processes requiring human sign-off — expense reports, content publishing, contract reviews — durable execution preserves state while waiting for approval. Even if the server restarts during the wait, processing resumes automatically when approval arrives.
**Auto-Recovery from Failures**
Temporal, Dapr, Restate, and DBOS all automatically resume from the last checkpoint after crashes. If a failure occurs mid-LLM call, already-completed steps are not re-executed, preventing duplicate work and wasted tokens.
**DBOS for Small-Medium Projects**
Temporal and Dapr require dedicated orchestration infrastructure. DBOS works with just SQLite (local dev) or Postgres (production) — no separate orchestration server needed. This makes it the pragmatic choice for teams that want durability without operational overhead.
**Staged Agent Pipelines**
Multi-step pipelines (research, analyze, generate report, review, approve) can checkpoint after each step. If step 4 fails, you resume from step 4 — not from scratch.
💡 Use Cases
📋 Expense approval flows waiting days for manager sign-off
📝 Content publishing pipelines with editor review and approval gates
🔄 Long-running batch processing with crash recovery (hundreds of documents)
🏢 Contract review workflows waiting for legal team confirmation
⚠️ Caveats
- Framework choice depends on your infrastructure. Use Temporal if you already run it; choose DBOS for a lightweight start on new projects.
- Persisting full LLM responses increases storage costs. Design your checkpoints to save only the information needed for resumption.
- Always set timeouts on human approval steps. Indefinitely waiting workflows cause resource leaks.
- DBOS with SQLite is great for local development but use Postgres in production for reliability and concurrency.
✨ With durable execution, build long-running workflows without fearing process failures!
#
OpenAIAgentSDK# #
AIAgent#