Skip to content

restatedev/ai-examples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

82 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Documentation Discord Slack Twitter

Restate: SDK-agnostic resilient agentic workflows

Restate turns brittle agents into resilient agents.

Restate is Agent-SDK-agnostic and turns your agentic workflows into reliable applications that work consistently in production.

Restate has got your back: whether you start by adding resiliency to an existing agent SDK, or decide the agent SDK not flexible enough and implement everything from scratch while keeping your resiliency guarantees.

Restate + Vercel AI SDK

Use Restate in combination with the Vercel AI SDK to turn your Vercel AI SDK-based agents into resilient agents:

Restate + OpenAI Agent SDK

Use Restate in combination with the OpenAI Agent SDK to turn your OpenAI Agent SDK-based agents into resilient agents:

Why Restate?

Restate lets you easily build reliable applications that work consistently in production. Restate's capabilities and programming model work very well for implementing agentic workflows. Move beyond fragile demos by giving your agents innate resilience—persistent memory, fault-tolerant tool/LLM calls, and robust handling of long-running tasks. Focus on your agent's intelligence, not the infrastructure complexity tax.

Restate provides the following capabilities:

  • 🚀 Move fast and far - Innate resiliency and control from your first LLM-SDK-based app to low-level, customized multi-agent applications.
  • 🛠️ SDK-agnostic - Use Restate with any agent SDK, such as OpenAI Agent SDK, Vercel AI SDK, or your own custom agent implementation.
  • Resilience where it matters most – Automatically recover from failures in your agentic workflows and tools.
  • 🎮 Task control - Cancel tasks, query status, re-subscribe to ongoing tasks, and track progress across failures, time, and processes.
  • 🤖 Reliable multi-agent - Flexible and reliable communication patterns including RPC, scheduled tasks, events, human-in-the-loop and parallel execution.
  • 🙂 Human-in-the-loop – Resiliently integrate human feedback into your agentic workflows.
  • 👀 Full observability – Line-by-line execution tracking with a built-in audit trail and UI. Seamless integration with OpenTelemetry.
  • 🔁 Orchestrate long-running processes – Coordinate durable and stateful agentic processes for millis or months.
  • 🔧 Rich primitives – Leverage workflows, durable promises, communication, and persistent state.
  • 🧠 Exactly-once execution - Automatic deduplication of hand-offs and tool executions via idempotency keys.
  • 💾 Persistent memory - Maintain consistent agent memory across infrastructure events.
  • 🌍 Deploy anywhere – Whether it's AWS Lambda, CloudRun, Fly.io, Cloudflare, Kubernetes, Deno Deploy,...
  • ☁️ Easy to self-host – Single-binary self-hosted deployments or connect to Restate Cloud.

OpenAI Agent SDK invocation UI

Restate can also be used for other use cases, such as: workflows, microservice orchestration, async tasks, and event processing. Or check out the Restate examples repository.

This repository contains examples of how to use Restate for AI / Agent use cases.

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 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.

Running the examples

Clone the repository and consult the README of the example you want to run for further instructions.

git clone [email protected]:restatedev/ai-examples.git

How Restate Compares (vs. Alternatives for Agents):

  • vs. DIY (Basic Loops + DB/Queue): Eliminates vast amounts of boilerplate code for retries, state management, consistency checks, and failure recovery that developers would otherwise need to build manually.
  • vs. Basic Agent Frameworks (focused on prompts/reasoning): Provides the crucial missing layer of execution reliability, state persistence, and robust async operation management needed for production. Restate complements these frameworks by providing a reliable runtime beneath the agent's reasoning logic.
  • vs. Heavy Workflow Engines: Offers similar strong execution guarantees but with a lighter footprint, lower latency, simpler programming model, native serverless integration, and easier self-hosting/operational story—often a better fit for the potentially high-volume, interactive nature of agent applications.

Learn more

Disclaimers and acknowledgements

Disclaimer 1: 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.

Disclaimer 2: Many of the DIY patterns have been based on Anthropic's agents cookbook.

Disclaimer 3: 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