# When an agent fails at step three, Inngest reruns only that step

> There is no Redis to run, and an agent can pause for hours waiting on a human approver without keeping a process alive.

Original: https://fdetimes.net/en/tools/inngest-durable-agent-steps-approval/

Every `step.run()` call in Inngest has its own retry counter, so when one step fails, the steps that already finished do not run again.

For an agent that calls an LLM to draft a reply before emailing a customer, that small detail decides whether you pay for the draft's tokens once or four times, and whether you get one draft or four different ones.

Inngest describes itself as a platform for workflows and agents that "keep running through failures", and its homepage files it under durable execution for workflows and AI. The promise that matters most to an FDE is a durable queue without operating Redis or a message broker yourself, with flow control built in.

The reason to care is practical. On a client site, an agent that ran smoothly as a demo on a laptop will meet client APIs that time out, model-provider rate limits, and a manager who must sign off before the agent does anything with consequences.

Inngest wraps saving results, retrying and waiting for outside signals into a handful of primitives, so you do not have to build a queue and a state table for each of those problems.

## Why a failure at step three does not drag step one with it

Inngest's documentation describes the core mechanism concisely: run each step, save its result, and on failure retry from the exact step that failed. When the handler runs again, the SDK returns the saved result instead of calling the inner function again. Your code looks like an ordinary async function, but each `step.run()` is a checkpoint.

Take a concrete case. By default Inngest retries four times after the first attempt, so each step gets at most five runs. Say an agent has three steps: load the ticket, call the LLM to draft a reply, send the email.

If the email service goes down and recovers only on the fourth attempt, the send step runs four times while the first two steps each run exactly once. Write all three in a single function with no steps, and you call the LLM four times and may get four different drafts.

Retrying is not always good, though. Permanent errors, such as a ticket that does not exist or a customer who has revoked access, will not be fixed by five attempts, and the documentation advises throwing `NonRetriableError` for those cases. The habit worth building from day one is classifying errors: let the ones that can heal themselves retry, and stop early with a clear message on the ones that cannot.

## Waiting for an approver without keeping a process alive

This is where Inngest is most useful for agents inside companies. Charly Poly of Inngest argues that human-in-the-loop is hard because the latency is unbounded: an approver might answer in five minutes or in two days. Durable execution solves it by having the workflow stop at a defined point, save its full state and wait for an external signal.

The matching primitive is `step.waitForEvent()`. The documentation is explicit that a sleep or a wait for an event pauses the run without keeping the function's process active, so an agent waiting two days burns no resources. When the approver clicks a button in Slack, email or a dashboard, that system sends an event to Inngest and the wait ends.

A minimal sketch of an agent that drafts customer replies and needs approval before sending:

```ts
export const replyAgent = inngest.createFunction(
  { id: "reply-agent" },
  { event: "support/ticket.created" },
  async ({ event, step }) => {
    const ticket = await step.run("load-ticket", () => loadTicket(event.data.ticketId));
    const draft = await step.run("draft-reply", () => draftWithLLM(ticket));

    await step.run("ask-approval", () => postToSlack(ticket.id, draft));

    const decision = await step.waitForEvent("wait-approval", {
      event: "support/reply.reviewed",
      match: "data.ticketId",
      timeout: "24h",
    });

    if (!decision) return await step.run("escalate", () => escalate(ticket.id));
    if (!decision.data.approved) return { status: "rejected" };
    return await step.run("send-reply", () => sendEmail(ticket, draft));
  }
);
```

The three closing branches are not decoration. The documentation on durable agents calls for handling all three outcomes: approved, rejected and no response. The third branch deserves the most care: before letting an agent touch real data, ask what it will do if the approver is on holiday.

**Key point:** An agent that needs an approver is safe only once you have written the code for the case where nobody answers.

## The limit lies in how you split steps

Inngest handles durability, but it does not decide where your step boundaries go. Put the LLM call and the email send inside the same `step.run()` and a failed send triggers a fresh LLM call, wiping out the benefit described above. The practical rule: every outbound call, especially one that costs money or has real effects, gets its own step.

A further consequence: retries mean a step can run more than once, so actions such as sending email or writing to a CRM should be designed so that running them again does not create duplicates.

And because run state is stored outside your code, ask the client's security team early which data is allowed to sit in step results.

Inngest also offers AgentKit, a separate framework for building agents, from a single model call to multi-agent systems using tools. Learn core Inngest first: understand `step.run()`, retries and `waitForEvent()`, then decide whether you need another framework layer on top.

## What to learn first, and what to put on your CV

A sensible order: write a function with three steps, deliberately make the last one fail to watch the first one stay put, then add `NonRetriableError`, and finally add an approval wait with a timeout. One evening is enough to see the whole mechanism.

When reading FDE job ads, look for requirements about taking agents to production or about workflows with human approval; that is where this experience is worth mentioning. On your CV, do not write "used Inngest".

Write that you designed an agent with a human approval step, handled the case where the wait times out, and avoided re-calling the model when a downstream service failed.

Employers are buying the ability to get an agent through its first day in production; the tool's name is a detail.

**Try this week:**

- Take an agent you are building and wrap every LLM call and every external API call in its own step.run()
- Add a step.waitForEvent() before any action with real effects (sending email, writing to a CRM) and write code for the timeout branch too
- List the permanent errors in your agent (bad input, permission denied) and switch them to NonRetriableError

## Sources

- [Inngest Documentation](https://www.inngest.com/docs)

- [Durable Execution for Workflows & AI | Inngest](https://www.inngest.com/)

- [Retries (Inngest docs)](https://www.inngest.com/docs/features/inngest-functions/error-retries/retries)

- [Inngest steps (Inngest docs)](https://www.inngest.com/docs/learn/inngest-steps)

- [Human-in-the-loop (HITL) – Inngest docs](https://www.inngest.com/docs/ai-patterns/human-in-the-loop)

- [Durable Agents – Inngest docs](https://www.inngest.com/docs/learn/durable-agents)

- [Durable Execution: The Key to Harnessing AI Agents in Production](https://www.inngest.com/blog/durable-execution-key-to-harnessing-ai-agents)

- [AgentKit | AgentKit by Inngest](https://agentkit.inngest.com/)
