Skip to main content
In this quickstart, you run a weather agent on a local Restate Server, call it over HTTP, and inspect the model calls and tool calls that Restate recorded. The agent uses Restate Harness, Restate’s TypeScript library for agents. You need Node.js 22.21.1 or later, Restate Server 1.8 or later, and an OpenAI API key. curl sends a request for the key session-1 to the Restate Server on localhost:8080, which stores the conversation and invokes agent/session-1/run in your service on localhost:9080. The handler runs weatherAgent, which calls OpenAI and the getWeather tool. The Restate UI runs on localhost:9070.

Start from a prompt

Paste this prompt into your coding agent, such as Claude Code or Codex. The coding agent downloads the template, installs the Restate skills, starts a local Restate Server, and runs the weather agent.

Set up and run the Restate Harness template on a local Restate Server.

Start manually

1

Install Restate Server and CLI

Restate is a single self-contained binary. No external dependencies needed.
Start the server:
You can find the Restate UI running on port 9070 (http://localhost:9070) after starting the Restate Server.
2

Get the template

Download the template and install its dependencies:
The template enables the Restate plugin for Claude Code and Codex. To add the Restate skills to another coding agent, run npx skills add restatedev/skills.
3

Look at the agent

src/agent.ts defines a weather agent with one tool, and a Virtual Object that runs it:
src/agent.ts
  • agent() defines the agent at module scope, with an OpenAI model, instructions, and a limit of five steps. Compaction is on by default, so the run summarizes the older messages of a long conversation.
  • getWeather is an asyncTool. Restate journals its result, so a replay returns the journaled result instead of running execute again.
  • The run handler of the agent Virtual Object runs the agent with a Conversation and returns its answer. The object key identifies the conversation, so requests to the same key continue it. See Sessions.
  • state.preload sends the conversation’s metadata and summary with each request. The run reads the stored messages when it needs them. See Lazy state.
src/app.ts serves the service on port 9080.
4

Run the service

Export your OpenAI API key and start the service:
5

Register the service

Tell Restate where the service is running:
If you run Restate with Docker, register http://host.docker.internal:9080 instead.
When using Restate Cloud, your service must be reachable from your Restate environment. You can use a public endpoint or connect a private service through a supported secure tunnel.
6

Invoke the agent

Send a request to the run handler of the object with the key session-1:
Send a follow-up to the same key, such as {"prompt": "And in Paris?"}. The run loads the earlier messages of the conversation before it calls the model. Use another key to start a new conversation. To send requests from your application, see Clients.Open the Restate UI at http://localhost:9070 and select the invocation to see the journal entries of the model calls and the tool call. Stop and restart the service during a request: Restate replays the journal, and the agent continues without repeating the completed calls.
The template also contains an integration test that runs the agent with a fixture model and forced replay. With Docker running, run npm test. See Testing.

Generator SDK

Restate Harness runs on Restate’s generator SDK, @restatedev/restate-sdk-gen, which differs from the promise-based TypeScript SDK in a few ways:
  • Handlers are generator functions, such as function* ({prompt}). Use yield* to wait for each durable operation, such as an agent run, a call to another service, or a timer.
  • Durable operations are functions of the restate module, such as restate.run(), restate.state(), and restate.client(). Handlers don’t receive a ctx parameter.
  • Use restate.all, restate.any, and restate.spawn for concurrent work instead of Promise.all. Use await only inside a restate.run callback or an asyncTool.
Durable Coroutines explains the generator model in more detail.

Next steps

Agents

Configure instructions, typed output, and limits.

Tools

Let the agent call APIs and Restate services.

Sessions

Keep conversation history between requests.

Tutorial

Follow the numbered lessons, from tools to multi-agent workflows.