Debuly

Guide · Developer platforms · Automation and agents

How to run durable background workflows for AI agents

Run long AI agent jobs that survive crashes and waits: how durable workflows for AI agents work, the setup steps, seven tools compared and mistakes to avoid.

By the end of this guide you will have an AI agent job running as a durable background workflow: a multi-step task that retries failed steps, can wait for hours or for a human approval, and picks up where it stopped if a server restarts. The tool that does this is a workflow or job orchestration platform, either a hosted service or software you run yourself.

Agent tasks are a poor fit for a single web request, because model calls are slow, flaky and expensive to repeat. This guide explains how durable workflows for AI agents work, walks through the build in order, and compares seven options from our Developer platforms category.

Key takeaways

  • Break an agent job into steps whose results are saved. When a step fails, the platform retries only that step instead of the whole run.
  • The main decision is the programming model: step functions triggered by events, tasks with no timeout, queue-based workflows, or a visual builder.
  • Check the limits that matter for long agent runs: step duration, concurrency, steps per function and log retention.
  • Make steps safe to repeat, and put a human approval in front of any action that spends money, sends messages or changes data.

What you need before you start

  • A job worth making durable. For example a research agent that takes ten minutes, a document pipeline, or an agent that waits for a person to approve a step.
  • A codebase and a language. Inngest lists TypeScript, Go and Python examples. Trigger.dev is for TypeScript. Inferable lists TypeScript and Go.
  • Model provider keys. Your agent calls a model, and you pay that provider separately.
  • A place for code to run. Some platforms run your code on their workers, and others call code you host.
  • Time. A first durable function takes under an hour. Production hardening takes longer.
  • Difficulty. Moderate; most options expect you to write code.

Which kind of AI tool fits this job

Step functions triggered by events. Inngest is an open-source SDK with a managed cloud. You split work into steps, trigger functions from events, and it handles retries, sleeping, resuming and fan-out. A run that fails midway continues from the failed step, and a run can wait for another event.

Long-running tasks without timeouts. Trigger.dev is an open-source platform for TypeScript tasks that run as durable jobs with no maximum run duration, with queues, retries, cron schedules and checkpointing. Its Realtime feature streams run status and LLM output to your frontend.

Queue-based orchestration. Hatchet queues tasks, schedules them with cron or one-time runs, retries failures and keeps intermediate state so a workflow resumes if a worker crashes. It offers pay-as-you-go cloud pricing and can be self-hosted.

Workflows that run on your own compute. Inferable registers workflows with a control plane that tracks executions, while the code runs on your machines and connects out by long polling, so you open no inbound ports. AgentField is an open-source control plane that exposes agent functions as REST endpoints, with async execution, retries and pause-for-approval steps. DeepStructure runs durable TypeScript workflows with managed Postgres and blob storage.

A visual builder with code and AI steps. n8n connects apps in a visual editor, supports webhooks and schedules as triggers, has an AI Agent node and code steps, and lists automatic retries and execution logging. It suits workflows that mix many app integrations with some AI steps.

Step 1: Map the agent job into steps

Durability works at the step level, so design the steps first.

  1. Write the job as a list of actions: fetch data, call a model, call a tool, wait for approval, write results.
  2. Mark which steps are slow, which are expensive and which have side effects, such as sending an email or charging a card.
  3. Mark where the job must wait: for a person, a webhook or a timer.
  4. Decide what a retry should do for each step, and which failures should stop the run.

Check it worked by walking through the list and finding the point where a crash would hurt most.

Step 2: Choose a platform and programming model

Pick by language, hosting preference and run length.

  1. Choose event-driven steps if your system already emits events. Inngest fits this model.
  2. Choose long-running tasks if jobs run for a long time and you work in TypeScript. Trigger.dev lists no maximum run duration.
  3. Choose a queue-style engine if you want to self-host or pay per run. Hatchet lists pay-as-you-go pricing after a free allowance.
  4. Choose a visual builder if non-developers will maintain the flow. n8n is the visual option in this guide.
  5. Check limits against your job. Inngest lists a function limit of 1000 steps and step timeouts capped at 2 hours.

Check it worked by confirming your longest step fits within the platform's timeout.

Step 3: Write the first durable function

Get one small workflow running before you add an agent.

  1. Install the SDK and start the local development setup if one is provided. Inngest lists local development before moving to its Cloud.
  2. Write a function with two or three steps, such as fetch, model call and save.
  3. Keep each step's result small and serializable, since it is stored between steps.
  4. Trigger the function and watch the run in the dashboard.

Check it worked by seeing every step appear with its own trace or log.

Step 4: Add the agent logic

Now wire in the model and tools.

  1. Put each model call and each tool call in its own step so a retry repeats only that work.
  2. Return structured results where you can, and validate them before the next step uses them.
  3. Set a maximum number of loop iterations for the agent, so it cannot run indefinitely.
  4. Stream progress to the user if the job is long. Trigger.dev lists Realtime streaming of run status and LLM output to the frontend.

Check it worked by running the full agent once and confirming each model call is logged as its own step.

Step 5: Add retries, limits and idempotency

Failures are normal with models and third-party APIs.

  1. Configure retries with backoff for steps that call external services.
  2. Set concurrency and rate limits so a burst of runs does not exhaust your model quota. Inngest lists rate limiting, throttling and concurrency controls, and Hatchet lists rate limiting and fairness strategies.
  3. Make side-effecting steps idempotent, for example by using a unique request ID. Inferable lists the execution ID as an idempotency key.
  4. Decide what happens after the final retry: alert someone, or move the job to a review queue.

Check it worked by making a step fail twice on purpose and watching the run continue from that step.

Step 6: Add waits and human approval

Agents often need to pause.

  1. Use a wait or sleep step for timers and external events. Inngest lists sleep and wait-for-event steps.
  2. Add an approval step before any irreversible action. AgentField lists app.pause() for durable human approval, and Trigger.dev lists human-in-the-loop approval flows.
  3. Understand billing during waits. Trigger.dev says a task waiting on a subtask or approval is checkpointed and not billed for the wait.
  4. Set an expiry for approvals so jobs do not wait forever.

Check it worked by starting a run, leaving it waiting for an hour, approving it, and seeing it finish.

Step 7: Deploy, monitor and review runs

Production needs visibility.

  1. Deploy to the platform's cloud or your own infrastructure. Trigger.dev, Hatchet, Inferable and AgentField can be self-hosted.
  2. Set alerts for failed runs. Trigger.dev lists alerts by email, Slack or webhooks.
  3. Review traces for slow and failing steps. Hatchet lists an OpenTelemetry collector, and Trigger.dev lists run traces with AI SDK token and cost data.
  4. Check plan limits against real traffic. Hatchet's free tier drops tasks when limits are exceeded, so watch usage.
  5. Review a sample of agent runs by hand each week to catch quiet failures.

Check it worked by inspecting a failed run and seeing exactly which step failed and why.

Tools for this job compared

Tool Good fit for Pricing Stated limits
Inngest Event-driven step functions with web, CLI and self-hosted options Freemium, paid from $99/mo (checked 24 Oct 2026) Free plan: 50k executions, 5 concurrent steps, 24 hours of traces; step timeouts capped at 2 hours
Trigger.dev Long-running TypeScript tasks with realtime streams Freemium, paid from $10/mo (checked 24 Oct 2026) Free plan: 20 concurrent runs, 1 day of log retention; tasks are written in TypeScript
Hatchet Queued tasks and durable workflows, cloud or self-hosted Freemium Free tier: 2,000 task runs a day; exceeding it drops tasks; SSO, RBAC and HIPAA on Custom only
Inferable Workflows in TypeScript or Go that run on your own compute Freemium, paid from $10/mo (checked 24 Oct 2026) Free tier: 2 registered workflows, 1000 executions; SOC certifications listed as coming soon
DeepStructure Durable TypeScript workflows with managed Postgres and storage Free trial, paid from $99/mo (checked 24 Oct 2026) Self-hosting, Startup and Enterprise pricing arranged by email; workflows written in TypeScript
AgentField Exposing agents as REST endpoints with retries and approvals Open source You run the control plane yourself; routing adds roughly 100-200ms per cross-agent hop
n8n Visual workflows with AI nodes, cloud or self-hosted Freemium, paid from €20/mo (checked 24 Oct 2026) Cloud plans have fixed concurrency; Business plan is self-hosted only

Prices and plan limits change, so confirm the current terms on each vendor's site before you build around them.

Common mistakes to avoid

  • Putting the whole agent in one step. A failure then repeats every model call and tool call. Fix it by giving each model call and side effect its own step, so retries repeat only what failed.
  • Retrying steps that are not safe to repeat. A retried email or payment can happen twice. Fix it by using idempotency keys and checking whether the action already happened.
  • Letting agents loop forever. A confused agent can burn tokens for hours. Fix it by capping iterations, time and spend per run.
  • Skipping human approval. Agents can take actions no one intended. Fix it by pausing for approval before irreversible steps, and logging who approved.
  • Ignoring platform limits. Step timeouts, step counts and free-tier caps can stop long jobs. Fix it by checking limits against your longest run and watching usage as traffic grows.

How we put this together

This is an evidence-based guide built from each tool's listing in our directory, which is compiled from the vendor's own site and pricing page. It is not a review based on using the tools. We don't rank tools, and nobody paid to be included. Some outbound links may be affiliate links; see our disclosure.

Frequently asked questions

Is there a free way to run durable workflows for AI agents?

Yes. Inngest, Trigger.dev, Hatchet and Inferable all list free tiers or plans, and Trigger.dev, Hatchet, Inferable, AgentField and n8n can be self-hosted. Free plans have caps, such as Inngest's 50k executions and Hatchet's 2,000 task runs a day. You also pay your model provider.

What does durable execution mean?

It means the platform saves the result of each step, so if a worker crashes or a step fails, the run resumes from the last saved point instead of starting over. Hatchet describes keeping intermediate state so a workflow resumes where it left off if a worker crashes.

Do I need this, or is a simple job queue enough?

A plain queue is fine for short, simple jobs. Durable workflows help when a job has several slow steps, waits for people or events, or costs real money to repeat. Agent runs usually fall in the second group.

Can a workflow wait for a human to approve a step?

Yes, on several platforms. Trigger.dev lists human-in-the-loop approval flows, AgentField lists durable approval pauses, and n8n lists human approval for tool calls. Set an expiry and decide what happens if nobody responds.

Can I keep my code and data on my own infrastructure?

Yes, with some options. Inferable runs workflows on your own compute with outbound-only connections, and Trigger.dev, Hatchet and AgentField can be self-hosted. Hosted platforms store run data on their systems, so read their data terms.

Compare more options in our Developer platforms category.

Related guides

Developer platforms · Automation and agents

How to build a browser automation agent with AI

Build an AI browser automation agent that logs in, clicks and extracts data: the steps, seven tools compared on pricing and limits, and mistakes to avoid.

Debuly Editorial · Published

Developer platforms · Automation and agents

How to build a multi-agent system: a step-by-step guide

Build a multi-agent system where specialised AI agents split a job: pick a framework, define roles and handoffs, add guardrails and test. Seven tools compared.

Debuly Editorial · Published

Related categories