https://github.com/restatedev/ai-examples
A collection of Restate examples for AI use cases: agents, A2A, MCP, ...
https://github.com/restatedev/ai-examples
ai artificial-intelligence durable-execution resilience restate
Last synced: about 2 months ago
JSON representation
A collection of Restate examples for AI use cases: agents, A2A, MCP, ...
- Host: GitHub
- URL: https://github.com/restatedev/ai-examples
- Owner: restatedev
- Created: 2025-03-12T15:37:05.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2026-04-21T15:07:52.000Z (about 2 months ago)
- Last Synced: 2026-04-21T17:05:45.645Z (about 2 months ago)
- Topics: ai, artificial-intelligence, durable-execution, resilience, restate
- Language: Python
- Homepage: https://ai.restate.dev
- Size: 15.3 MB
- Stars: 69
- Watchers: 4
- Forks: 6
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[](https://docs.restate.dev)
[](https://discord.restate.dev)
[](https://slack.restate.dev)
[](https://x.com/intent/follow?screen_name=restatedev)
# 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](https://restate.dev/) ([Github](https://github.com/restatedev/restate))
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](https://ai-sdk.dev/), the [OpenAI Agent SDK](https://openai.github.io/openai-agents-python/), [Google ADK](https://google.github.io/adk-docs/), and [Pydantic AI](https://ai.pydantic.dev/). 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 showing an agent execution with parallel tool calls
## Quickstart Templates
| Integration | Quickstart | Template |
|------------------------------------|------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------|
| **Vercel AI SDK** | [📖](https://docs.restate.dev/ai-quickstart) | [
](vercel-ai/template/README.md) |
| **OpenAI Agents SDK** | [📖](https://docs.restate.dev/ai-quickstart) | [
](openai-agents/template/README.md) |
| **Google ADK** | [📖](https://docs.restate.dev/ai-quickstart) | [
](google-adk/template/README.md) |
| **Pydantic AI** | [📖](https://docs.restate.dev/ai-quickstart) | [
](pydantic-ai/template/README.md) |
| **Restate - Python - no agent SDK** | [📖](https://docs.restate.dev/ai-quickstart) | [
](python-restate-only/template/README.md) |
| **Restate - TS - no agent SDK** | [📖](https://docs.restate.dev/ai-quickstart) | [
](typescript-restate-only/template/README.md) |
## 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 | [📖](https://docs.restate.dev/ai/patterns/durable-agents) | [
](python-restate-only/template/agent.py) [
](typescript-restate-only/template/src/agent.ts) | [
](vercel-ai/template/src/app.ts) | [
](openai-agents/template/agent.py) | [
](google-adk/template/agent.py) | [
](pydantic-ai/template/agent.py) |
| **Durable Sessions** | Persistent, isolated agent sessions | [📖](https://docs.restate.dev/ai/patterns/sessions) | [
](python-restate-only/tour-of-agents/app/chat_agent.py) [
](typescript-restate-only/tour-of-agents/src/chat-agent.ts) | [
](vercel-ai/tour-of-agents/src/chat-agent.ts) | [
](openai-agents/tour-of-agents/app/chat_agent.py) | [
](google-adk/tour-of-agents/app/chat_agent.py) | [
](pydantic-ai/tour-of-agents/app/chat_agent.py) |
| **Human approvals with pause/resume** | Human approval steps that suspend execution | [📖](https://docs.restate.dev/ai/patterns/human-in-the-loop) | [
](python-restate-only/tour-of-agents/app/human_approval_agent.py) [
](typescript-restate-only/tour-of-agents/src/human-approval-agent.ts) | [
](vercel-ai/tour-of-agents/src/human-approval-agent.ts) | [
](openai-agents/tour-of-agents/app/human_approval_agent.py) | [
](google-adk/tour-of-agents/app/human_approval_agent.py) | [
](pydantic-ai/tour-of-agents/app/human_approval_agent.py) |
| **Multi-agent orchestration** | Route requests to specialized agents | [📖](https://docs.restate.dev/ai/patterns/multi-agent) | [
](python-restate-only/tour-of-agents/app/multi_agent.py) [
](typescript-restate-only/tour-of-agents/src/multi-agent.ts) | [
](vercel-ai/tour-of-agents/src/multi-agent.ts) | [
](openai-agents/tour-of-agents/app/multi_agent.py) | [
](google-adk/tour-of-agents/app/multi_agent.py) | [
](pydantic-ai/tour-of-agents/app/multi_agent.py) |
## 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 | [📖](https://docs.restate.dev/ai/patterns/parallelization) | [
](python-restate-only/tour-of-agents/app/workflow_parallel.py) [
](typescript-restate-only/tour-of-agents/src/workflow-parallel.ts) | [
](vercel-ai/tour-of-agents/src/workflow-parallel.ts) | [
](openai-agents/tour-of-agents/app/workflow_parallel.py) | [
](google-adk/tour-of-agents/app/workflow_parallel.py) | [
](pydantic-ai/tour-of-agents/app/workflow_parallel.py) |
| **Workflows: Sequential pipeline** | Chain agents in multi-step pipelines | [📖](https://docs.restate.dev/ai/patterns/workflow-sequential) | [
](python-restate-only/tour-of-agents/app/workflow_sequential.py) [
](typescript-restate-only/tour-of-agents/src/workflow-sequential.ts) | [
](vercel-ai/tour-of-agents/src/workflow-sequential.ts) | [
](openai-agents/tour-of-agents/app/workflow_sequential.py) | [
](google-adk/tour-of-agents/app/workflow_sequential.py) | [
](pydantic-ai/tour-of-agents/app/workflow_sequential.py) |
| **Workflows: Parallel agents** | Executing multiple agents in parallel | [📖](https://docs.restate.dev/ai/patterns/workflow-parallel) | [
](python-restate-only/tour-of-agents/app/workflow_parallel.py) [
](typescript-restate-only/tour-of-agents/src/workflow-parallel.ts) | [
](vercel-ai/tour-of-agents/src/workflow-parallel.ts) | [
](openai-agents/tour-of-agents/app/workflow_sequential.py) | [
](google-adk/tour-of-agents/app/workflow_parallel.py) | [
](pydantic-ai/tour-of-agents/app/workflow_parallel.py) |
| **Workflows: Orchestrator-worker** | Break tasks into specialized subtasks | [📖](https://docs.restate.dev/ai/patterns/workflow-orchestrator) | [
](python-restate-only/tour-of-agents/app/workflow_orchestrator.py) [
](typescript-restate-only/tour-of-agents/src/workflow-orchestrator.ts) | [
](vercel-ai/tour-of-agents/src/workflow-orchestrator.ts) | [
](openai-agents/tour-of-agents/app/workflow_orchestrator.py) | [
](google-adk/tour-of-agents/app/workflow_orchestrator.py) | [
](pydantic-ai/tour-of-agents/app/workflow_orchestrator.py) |
| **Workflows: Evaluator-optimizer** | Generate, evaluate, improve loop | [📖](https://docs.restate.dev/ai/patterns/workflow-evaluator) | [
](python-restate-only/tour-of-agents/app/workflow_evaluator_optimizer.py) [
](typescript-restate-only/tour-of-agents/src/workflow-evaluator-optimizer.ts) | [
](vercel-ai/tour-of-agents/src/workflow-evaluator-optimizer.ts) | [
](openai-agents/tour-of-agents/app/workflow_evaluator_optimizer.py) | [
](google-adk/tour-of-agents/app/workflow_evaluator_optimizer.py) | [
](pydantic-ai/tour-of-agents/app/workflow_evaluator_optimizer.py) |
| **Workflows as tools** | Complex tool logic as separate durable services | [📖](https://docs.restate.dev/ai/patterns/tools) | [
](python-restate-only/tour-of-agents/app/parallel_tools_agent.py) [
](typescript-restate-only/tour-of-agents/src/parallel-tools-agent.ts) | [
](vercel-ai/tour-of-agents/src/parallel-tools-agent.ts) | [
](openai-agents/tour-of-agents/app/parallel_tools_agent.py) | [
](google-adk/tour-of-agents/app/parallel_tools_agent.py) | [
](pydantic-ai/tour-of-agents/app/parallel_tools_agent.py) |
| **Remote agents** | Deploy/scale agents separately with resilient RPC and queuing | [📖](https://docs.restate.dev/ai/patterns/remote-agents) | [
](python-restate-only/tour-of-agents/app/remote_agents.py) [
](typescript-restate-only/tour-of-agents/src/remote-agents.ts) | [
](vercel-ai/tour-of-agents/src/remote-agents.ts) | [
](openai-agents/tour-of-agents/app/remote_agents.py) | [
](google-adk/tour-of-agents/app/remote_agents.py) | [
](pydantic-ai/tour-of-agents/app/remote_agents.py) |
| **Competitive racing agents** | Run parallel agents, use the fastest response, cancel others | [📖](https://docs.restate.dev/ai/patterns/competitive-racing) | [
](python-restate-only/tour-of-agents/app/racing_agents.py) [
](typescript-restate-only/tour-of-agents/src/racing-agents.ts) | - | - | - | - |
| **Interrupt & regenerate** | Interrupt a running agent with new context; cancel in-flight task and restart | - | [
](python-restate-only/examples/interrupt-regenerate/agent.py) [
](typescript-restate-only/examples/interrupt-regenerate/src/agent.ts) | - | - | - | - |
### Reliability Guides
| Pattern | Description | Docs | Restate | Vercel AI | OpenAI | ADK | Pydantic AI |
|---------|-------------|------|---------|-----------|--------|-----|-------------|
| **Error handling** | Retries and error handling for agents | [📖](https://docs.restate.dev/ai/patterns/error-handling) | - | [
](vercel-ai/tour-of-agents/src/errorhandling) | [
](openai-agents/tour-of-agents/app/error_handling.py) | [
](google-adk/tour-of-agents/app/error_handling.py) | [
](pydantic-ai/tour-of-agents/app/error_handling.py) |
| **Rollback** | Saga pattern for compensating failed operations | [📖](https://docs.restate.dev/ai/patterns/rollback) | - | [
](vercel-ai/tour-of-agents/src/rollback-agent.ts) | [
](openai-agents/examples/rollback) | - | - |
### Frontend Integration
| Pattern | Description | Docs | Restate | Vercel AI | OpenAI | ADK | Pydantic AI |
|---------|-------------|------|---------|-----------|-------------------------------------------------------------------------------------------------------------------------------------------|-----|-------------|
| **Chat UI integration** | Integrate agents with chat UIs | [📖](https://docs.restate.dev/ai/patterns/chat-ui-integration) | - | [
](vercel-ai/nextjs-example-app/README.md) | - | - | - |
| **Streaming responses** | Stream agent responses to clients | [📖](https://docs.restate.dev/ai/patterns/streaming-responses) | - | [
](vercel-ai/nextjs-example-app/README.md) | - | - | - |
| **Notify when ready** | Callback when agent completes | [📖](https://docs.restate.dev/ai/patterns/notify-when-ready) | - | - | [
](openai-agents/examples/notify_when_ready/agent.py) | - | - |
## More Examples & Integrations
| Example | Description | Code |
|------------------------|-------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------|
| **NextJS Template** | Minimal example of Restate + AI SDK + NextJS | [
](vercel-ai/nextjs-template/README.md) |
| **NextJS Example App** | Example app of Restate + AI SDK + NextJS with tools, chat, pubsub,... | [
](vercel-ai/nextjs-example-app/README.md) |
| **MCP** | Using Restate for exposing tools and resilient orchestration of tool calls | [
](mcp/README.md) |
| **A2A** | Implement Google's Agent-to-Agent protocol with Restate as resilient, scalable task orchestrator | [
](a2a/README.md) |
### AI Observability
| Integration | Restate | OpenAI Agents | Google ADK | Pydantic AI |
|----------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------|
| **Langfuse** | [
](python-restate-only/examples/langfuse/README.md) | [
](openai-agents/examples/langfuse/README.md) | [
](google-adk/examples/langfuse/README.md) | [
](pydantic-ai/examples/langfuse/README.md) |
| **Arize Phoenix** | - | [
](openai-agents/examples/arize_phoenix/README.md) | - | - |
| **Pydantic LogFire** | - | - | - | [
](pydantic-ai/examples/logfire/README.md) |
## Supported Languages
Restate currently supports 6 languages:
[](https://docs.restate.dev/develop/ts/overview)
[](https://docs.restate.dev/develop/python/overview)
[](https://docs.restate.dev/develop/java/overview)
[](https://docs.restate.dev/develop/java/overview)
[](https://docs.restate.dev/develop/go/overview)
[](https://docs.rs/restate-sdk/latest/restate_sdk/)
The examples can be translated to any of the supported languages.
Join our [Discord](https://discord.restate.dev)/[Slack](https://slack.restate.dev) to get help with translating an examples to your language of choice.
## Using AI coding tools
If you use Claude Code, Codex, or Cursor to build on Restate, we highly recommend installing the [Restate plugin](https://github.com/restatedev/skills). It bundles skills, prompts, and context that help AI coding assistants generate correct, idiomatic Restate code across all supported SDKs. Most templates in this repo install the plugin automatically — see the [skills repo](https://github.com/restatedev/skills) for setup instructions.
## Learn more
- [AI Documentation](https://docs.restate.dev/ai)
- [Examples on workflows, microservice orchestration, async tasks, event processing](https://github.com/restatedev/examples)
- [Restate Cloud](https://restate.dev/cloud/)
- [Discord](https://discord.restate.dev) / [Slack](https://slack.restate.dev)