Skip to content

restatedev/ai-examples

Repository files navigation

Documentation Discord Slack Twitter

Durable Agents and AI workflows with Restate

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

The goal is to show how you can easily add production-grade resilience, state persistence, retries, suspend/resume, human-in-the-loop, and observability to agentic workflows. So you can ship agents that stay alive and consistent without sprinkling retry-code everywhere and without building heavyweight infra yourself.

The Restate approach works independent of specific SDKs but integrates easily with popular SDKs, like the Vercel AI SDK, the OpenAI Agent SDK, Google ADK, and Pydantic AI. You can also use without any Agent SDK (roll your own loop) or for more traditional workflows.

Why Restate?

Use Case What it solves
Durable Execution Crash-safe model and tool calls, idempotent retries, agents that resume at the last successful step.
Detailed Observability Auto-captured trace of every step, retry, and message for easy debugging and auditing.
Human-in-the-loop & long waits Suspend while waiting for user approval or slow jobs; pay for compute, not wall-clock time.
Stateful sessions / memory Keep multi-turn conversations and other state isolated and consistent.
Multi-agent orchestration Reliable RPC, queuing, and scheduling between agents running in separate processes.

Restate UI - trace of agent with parallel tools


Restate UI showing an agent execution with parallel tool calls

Quickstart Templates

Integration Quickstart Template
Vercel AI SDK 📖 Image
OpenAI Agents SDK 📖 Image
Google ADK 📖 Image
Pydantic AI 📖 Image
Restate - Python - no agent SDK 📖 Image
Restate - TS - no agent SDK 📖 Image

Getting Started - Basic Examples

Pattern Description Docs Restate Vercel AI OpenAI ADK Pydantic AI
Durable agents Build AI agents that survive crashes and recover automatically 📖 Image Image Image Image Image Image
Durable Sessions Persistent, isolated agent sessions 📖 Image Image Image Image Image Image
Human approvals with pause/resume Human approval steps that suspend execution 📖 Image Image Image Image Image Image
Multi-agent orchestration Route requests to specialized agents 📖 Image Image Image Image Image Image

Implementation Guides

Orchestration Guides

Pattern Description Docs Restate Vercel AI OpenAI ADK Pydantic AI
Parallel tool calls Run multiple tools in parallel with recovery and coordination 📖 Image Image Image Image Image Image
Workflows: Sequential pipeline Chain agents in multi-step pipelines 📖 Image Image Image Image Image Image
Workflows: Parallel agents Executing multiple agents in parallel 📖 Image Image Image Image Image Image
Workflows: Orchestrator-worker Break tasks into specialized subtasks 📖 Image Image Image Image Image Image
Workflows: Evaluator-optimizer Generate, evaluate, improve loop 📖 Image Image Image Image Image Image
Workflows as tools Complex tool logic as separate durable services 📖 Image Image Image Image Image Image
Remote agents Deploy/scale agents separately with resilient RPC and queuing 📖 Image Image Image Image Image Image
Competitive racing agents Run parallel agents, use the fastest response, cancel others 📖 Image Image - - - -

Reliability Guides

Pattern Description Docs Restate Vercel AI OpenAI ADK Pydantic AI
Error handling Retries and error handling for agents 📖 - Image Image Image Image
Rollback Saga pattern for compensating failed operations 📖 - Image Image - -

Frontend Integration

Pattern Description Docs Restate Vercel AI OpenAI ADK Pydantic AI
Chat UI integration Integrate agents with chat UIs 📖 - Image - - -
Streaming responses Stream agent responses to clients 📖 - Image - - -
Notify when ready Callback when agent completes 📖 - - Image - -

More Examples & Integrations

Example Description Code
NextJS Template Minimal example of Restate + AI SDK + NextJS Image
NextJS Example App Example app of Restate + AI SDK + NextJS with tools, chat, pubsub,... Image
MCP Using Restate for exposing tools and resilient orchestration of tool calls Image
A2A Implement Google's Agent-to-Agent protocol with Restate as resilient, scalable task orchestrator Image
Langfuse Full observability over agentic workflows by combining Restate with Langfuse Image

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

Watchers

Forks

Contributors