Skip to main content
A Restate AI application has two main components:
  • Restate Server: Sits in front of your agents and takes care of orchestration and resiliency
  • Agent Services: Your agent logic using the Restate SDK for durability
Application Structure Your agent is a regular function, a handler, that makes LLM calls, executes tools, and coordinates work. Restate wraps this handler in durable execution: every step is recorded in a journal, so if the process crashes, the agent picks up exactly where it left off. You can use the Restate SDK alone or in combination with an Agent SDK.

Creating a durable agent

To run a durable agent end to end, follow the quickstart on the integration page of your SDK, such as the Vercel AI SDK or the OpenAI Agents SDK. A Restate agent has three building blocks:
  1. The handler: An HTTP handler containing your agent logic, exposed in a Restate service
  2. LLM calls: Persisted so responses are not re-fetched on recovery
  3. Tool executions: Wrapped in durable steps so side effects are not duplicated
To implement a durable agent, you use the Restate SDK in combination with the Vercel AI.Here’s a weather agent that looks up the weather for a city:
agent.ts
The agent logic lives in a handler of a Restate service (here the run handler).The main difference compared to a standard Vercel AI agent is the use of the Restate Context at key points:
  1. Restate service handler: The agent runs inside a Restate service handler, giving it a durable execution context. Restate exposes the handler as an HTTP endpoint you can call via curl, the Restate UI, or any HTTP client.
  2. Persisting LLM responses: Wrap the model with durableCalls(ctx) middleware so every LLM response is saved in the Restate Server and replayed during recovery. The middleware is provided via @restatedev/vercel-ai-middleware.
  3. Resilient tool execution: Tools use ctx.run() to make steps durable. The result is persisted and retried until it succeeds.