"Durable execution" sounds like something you adopt after a six-week platform evaluation. It isn't. Here's an agent that survives being killed, in roughly twenty lines of Python.
The trick is that durability isn't a feature you code – it's a property of where the agent's loop runs. With Dapr Agents, the loop runs as a durable workflow, so every LLM call and tool call is journaled automatically:
from dapr_agents import DurableAgent, tool
@tool
def search_flights(destination: str) -> list:
"""Search available flights."""
return flights_api.search(destination)
@tool
def book_flight(flight_id: str) -> str:
"""Book a flight. Real money involved."""
return flights_api.book(flight_id)
agent = DurableAgent(
name="TravelBuddy",
role="Travel planning assistant",
instructions=["Find options first. Confirm before booking."],
tools=[search_flights, book_flight],
)
agent.start()
That's the whole thing. Now the fun part – try to break it:
- Ask it to plan a trip. Watch it call search_flights.
- Kill the process while it's mid-task. Not gracefully, kill the entire process.
- Start it again.
The agent picks up the same task where it left off.
The search results it already gathered come back from the workflow's execution history instead of being fetched (and paid for) again. And if the crash happened around book_flight, the journal knows whether that step confirmed – so recovery doesn't book a second seat. LLM calls are slow, costly, and non-deterministic; re-running everything after a crash burns money and can change the answer. Replaying from history does neither.
Under the hood this is a durable workflow – the same durable execution machinery you'd use for order processing or payment flows, wrapped around an agent loop. No extra database to run: state goes to whatever Dapr state store you configure (Redis locally, Postgres or others in production).
Honest caveats, as always: the agent's reasoning is only as repeatable as your model, tools with side effects still deserve idempotency keys for the truly paranoid path, and you should read up on workflow versioning before changing an agent that has long-running tasks in flight.
The longer version of this, with the full runnable sample, lives in The Tiniest Durable Agent. If you want the structured path, the Dapr Agents track at Dapr University is free, and the quickstarts get you a running example in a few minutes.
Top comments (0)