Skip to content

About

A collection of Restate examples for AI use cases: agents, A2A, MCP, ...

Topics

Resources

Stars

97 stars

Watchers

4 watching

Forks

Repository files navigation

Documentation Discord Slack Twitter

Durable Agents and AI workflows with Restate

This repo contains a set of runnable examples of AI agents and workflows, using Durable Execution, state, and orchestration via Restate (Github)

Why Restate?

Restate is a durable runtime for agents and backends. It gives you:

  • βœ… Durable Execution: Retry and recover from failures without repeating completed steps.
  • βœ… Durable Coroutines: Run multiple tools, subagents, and sandbox commands in parallel with recovery and coordination.
  • βœ… State & session coordination: Built-in multi-turn, persistent sessions. Scale out to thousands of concurrent sessions with built-in concurrency control
  • βœ… Communication & flow control: Resiliently route tasks between distributed agents, humans, and MCP servers, and shape traffic with concurrency control
  • βœ… Observability & control: Inspect detailed execution journals, and pause, cancel, kill, or roll back stuck agents
  • βœ… Production safety: Approvals, timeouts, rollbacks, and escalation without callback plumbing

Restate UI - trace of agent with parallel tools


Restate UI showing an agent execution with parallel tool calls

How to build agents with Restate?

There are three ways to build durable agents with Restate. We recommend the first two:

  1. agentlib: Start here for initial proofs of concept, simple agents, or any agent whose logic fits agentlib's abstractions.
  2. Custom / DIY: Build directly on Restate when you need custom agent logic or more control. Use the agent reference architecture as a starting point.
  3. An agent SDK integration: Use Restate with frameworks such as Vercel AI, OpenAI Agents, Google ADK, Pydantic AI, or LangChain. See the templates and examples below.

The reference architecture is also useful for agents built with agentlib: its patterns for session management, queuing, steering, interruption, and approvals can help you build the surrounding application.

Using AI coding tools

The Restate plugin provides coding skills and the Restate docs MCP server. The repository root, all standalone templates, and the agentlib examples include configuration for Claude Code and Codex. The shared marketplace catalog points to the published plugin.

Codex enables the plugin after you trust the project. See the plugin installation instructions for details.

Quickstart Templates

Restate integrates with popular Agent SDKs and with all LLM SDKs (only abstracting away the LLM API).

Integration Quickstart Template
Restate agentlib Setup
TS DIY agents πŸ“–
Python DIY agents πŸ“–
Vercel AI SDK πŸ“–
OpenAI Agents SDK πŸ“–
Google ADK πŸ“–
Pydantic AI πŸ“–
LangChain πŸ“–

Getting Started - Basic Examples

Pattern Docs Restate agentlib TS DIY agents Python DIY agents Vercel AI OpenAI ADK Pydantic AI LangChain
Durable agents: Build AI agents that survive crashes and recover automatically πŸ“–
Durable Sessions: Persistent, isolated agent sessions πŸ“–
Human approvals with pause/resume: Human approval steps that suspend execution πŸ“–
Multi-agent orchestration: Route requests to specialized agents πŸ“–

Implementation Guides

Orchestration Guides

Pattern Docs Restate agentlib TS DIY agents Python DIY agents Vercel AI OpenAI ADK Pydantic AI LangChain
Parallel tool calls: Run multiple tools in parallel with recovery and coordination πŸ“–
Sequential LLM calls: Chain agents in multi-step pipelines πŸ“–
Parallel agents: Executing multiple agents in parallel πŸ“–
Orchestrator-worker: Break tasks into specialized subtasks πŸ“–
Evaluator-optimizer: Generate, evaluate, improve loop πŸ“–
Workflows as tools: Complex tool logic as separate durable services πŸ“–
Remote agents: Deploy/scale agents separately with resilient RPC and queuing πŸ“–
Competitive racing agents: Run parallel agents, use the fastest response, cancel others πŸ“– - - - - -
Interrupt & regenerate: Interrupt a running agent with new context; cancel in-flight task and restart - - - - - - -

Reliability Guides

Pattern Docs Restate agentlib TS DIY agents Python DIY agents Vercel AI OpenAI ADK Pydantic AI LangChain
Error handling: Retries and error handling for agents πŸ“– - -
Rollback: Saga pattern for compensating failed operations πŸ“– - - - - - -

Frontend Integration

Pattern Docs Restate agentlib TS DIY agents Python DIY agents Vercel AI OpenAI ADK Pydantic AI LangChain
Chat UI integration: Integrate agents with chat UIs πŸ“– - - - - - - -
Streaming responses: Stream agent responses to clients πŸ“– - - - - - - -
Notify when ready: Callback when agent completes πŸ“– - - - - - - -

Integrations

Protocols

Example Code
MCP: Using Restate for exposing tools and resilient orchestration of tool calls
A2A: Implement Google's Agent-to-Agent protocol with Restate as resilient, scalable task orchestrator

AI Observability

Integration Restate agentlib TS DIY agents Python DIY agents OpenAI Agents Google ADK Pydantic AI
Langfuse - -
Arize Phoenix - - - - -
Pydantic LogFire - - - - -
Braintrust - - - - -

Others

Example Code
NextJS Template: Minimal example of Restate + AI SDK + NextJS
NextJS Example App: Example app of Restate + AI SDK + NextJS with tools, chat, pubsub,...

Advanced Examples

Larger, end-to-end applications (in separate repos) showing how Restate holds up in real-world agentic systems.

Example Code
Agent reference architecture: Custom agents with session management, queuing, steering, interruption, approvals, and parallel tools and subagents
Coding agent: orchestrates multi-turn conversations and coordinates subagents over sandboxed task execution
Deep Research Agent: Autonomous multi-day research agent (news digests, human-approved plans, parallel investigations) with Restate + LangChain + Tavily
Supervisor Agent: Supervisor pattern with policy gates, audit trails, and escalation ladders for security remediation workflows

Supported Languages

Restate currently supports 6 languages:

TypeScript Python Java Kotlin Go Rust

The examples can be translated to any of the supported languages. Join our Discord/Slack to get help with translating an examples to your language of choice.

Learn more

About

A collection of Restate examples for AI use cases: agents, A2A, MCP, ...

Topics

Resources

Stars

97 stars

Watchers

4 watching

Forks

Releases

Used by

Contributors

Languages