How does Restate help?
Restate provides durable execution for both the main workflow and compensation actions:- Guaranteed compensation: If the main workflow fails, compensation handlers are reliably executed
- No state management: No manual state tracking or extra infra required
- Observability: Track both forward progress and rollback operations in the Restate UI
- Works with any AI SDK and any programming language supported by Restate
Example
Track the rollback actions as you go, let the agent raise terminal tool errors, and execute the rollback actions in reverse order. Here is an example of a travel booking agent that first reserves a hotel, flight and car, and then either confirms them or rolls back if any step fails with a terminal error (e.g. car type not available). We let tools add rollback actions to the list for each booking step the do. Therun handler catches any terminal errors and runs all the rollback actions.

Run the example
Run the example
1
Requirements
- AI SDK of your choice (e.g., OpenAI, LangChain, Pydantic AI, LiteLLM, etc.) to make LLM calls.
- API key for your model provider.
2
Download the example
3
Start the Restate Server
4
Start the Service
Export the API key of your model provider as an environment variable and then start the agent. For example, for OpenAI:
5
Register the services
- UI
- CLI

6
Send a request
In the UI (
http://localhost:9070), click on the book handler of the BookingWithRollbackAgent to open the playground and send a default request:7
Check the Restate UI
You can see in the Invocations Tab how the workflow executes forward steps, encounters a failure, then executes compensation actions in reverse order:
