Skip to content

restatedev/ai-examples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

143 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

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, and Google ADK. 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 πŸ“–
OpenAI Agents SDK πŸ“–
Google ADK πŸ“–
Restate - Python - no agent SDK πŸ“–
Restate - TS - no agent SDK πŸ“–

Getting Started - Basic Examples

Pattern Description Docs Restate Vercel AI OpenAI ADK
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 Description Docs Restate Vercel AI OpenAI ADK
Parallel tool calls Run multiple tools in parallel with recovery and coordination πŸ“–
Workflows: Sequential pipeline Chain agents in multi-step pipelines πŸ“–
Workflows: Parallel agents Executing multiple agents in parallel πŸ“–
Workflows: Orchestrator-worker Break tasks into specialized subtasks πŸ“–
Workflows: 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 πŸ“– - - -

Reliability Guides

Pattern Description Docs Restate Vercel AI OpenAI ADK
Error handling Retries and error handling for agents πŸ“– -
Rollback Saga pattern for compensating failed operations πŸ“– - -

Frontend Integration

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

More Examples

Example Description Code
NextJS Template Minimal example of Restate + AI SDK + NextJS
NextJS Example App Example app of Restate + AI SDK + NextJS with tools, chat, pubsub,...
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

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