Skip to content

restatedev/ai-examples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

86 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Documentation Discord Slack Twitter

Examples for AI workflows and Durable Agents

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 or the OpenAI Agent SDK. You can also use without and Agent SDK (roll your own loop) or for more traditional workflows.

📄 A gentle intro is in the blog post "Durable Agents - Fault Tolerance across Frameworks and without Handcuffs"

Restate + Vercel AI SDK

Restate + OpenAI Agent SDK

Roll your own Loop? AI-enriched workflows?

Restate is a flexible general-purpose runtime for what we call innately resilient application. It is not limited to agentic workflow use cases and is being used for a variety of other use cases as well, including financial transactions or order processing. These examples show how to build agents directly on Restate's durable execution and state management:

Use Cases

Use Case What it solves
Durable Execution Crash-safe LLM/tool calls & idempotent retries—agents resume at the last successful step.
Journal Observability Auto-captured journal 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 Virtual Objects keep multi-turn conversations and other state isolated and consistent.
Multi-agent orchestration Reliable RPC, queuing, and scheduling between agents running in separate processes.

OpenAI Agent SDK invocation UI
Restate UI showing an ongoing agent execution

Full Example Catalog

  1. Restate + Vercel AI:
    • Template: A minimal example of how to use Restate with the Vercel AI SDK.
    • Examples: A more advanced example of how to use Restate with the Vercel AI SDK that can be deployed as a Next.js app on Vercel.
  2. Restate + OpenAI Agents Python SDK:
    • Template: A minimal example of how to use Restate with the OpenAI Agents SDK.
    • Examples: A more advanced example of how to use Restate with the OpenAI Agents SDK.
  3. Patterns for hardening custom LLM orchestration logic.
  4. MCP : Using Restate for exposing tools and resilient orchestration of tool calls.
  5. A2A : Implement Google's Agent-to-Agent protocol with Restate as resilient, scalable task orchestrator.
  6. Advanced examples:
    • Restate-native agent: A fully customizable agent implemented with Restate without an Agent SDK.
    • Interruptible agents: A customized agent with different operational modes to process new inputs: interrupting, incorporating, queueing.
    • Insurance claims: Filing insurance claims by parsing PDF receipts with LLMs.

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

Acknowledgements

  • The implementations of the Restate-native agent in this repo are heavily inspired by the OpenAI Agents SDK. We therefore want to give credit to the developers of this SDK for the great work they have done. This repo builds further on their work to make it benefit from Restate's programming model and capabilities.

  • The DIY patterns are largely based on Anthropic's agents cookbook.

  • Some of the A2A examples in this repo are based on the examples included in the Google A2A repo.

About

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

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published