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 (
- Homebrew
- Download binaries
- npm
- Docker
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.getWeatheris anasyncTool. Restate journals its result, so a replay returns the journaled result instead of runningexecuteagain.- The
runhandler of theagentVirtual Object runs the agent with aConversationand returns its answer. The object key identifies the conversation, so requests to the same key continue it. See Sessions. state.preloadsends 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.Restate Cloud
Restate Cloud
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 Send a follow-up to the same key, such as
run handler of the object with the key session-1:{"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.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}). Useyield*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
restatemodule, such asrestate.run(),restate.state(), andrestate.client(). Handlers don’t receive actxparameter. - Use
restate.all,restate.any, andrestate.spawnfor concurrent work instead ofPromise.all. Useawaitonly inside arestate.runcallback or anasyncTool.
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.