pkg/agent/runtime/restate and passing restate.WithRestateConfig to NewAgent. A running Restate server is required.
Prerequisites
Local development — pick one:
Ingress is at
http://localhost:8080; Admin / UI at http://localhost:9070. Full local and production notes: restate-setup.md in the repository.
Production — use Restate Cloud or a self-hosted cluster. Pass Ingress.AuthKey and optional Endpoint.IdentityPublicKeys as required by your deployment.
Enable
WithRestateConfig
IngressConfig fields
EndpointConfig fields
EventLogConfig fields
Controls post-run cleanup of the per-runAgentEventLog virtual object. After a root Run/Stream finishes, the runtime schedules a delayed Clear so readers can drain first.
NewAgent starts an embedded SDK endpoint in your process. Restate calls into that endpoint to run the agent loop.
Architecture
Restate splits agent execution into an ingress plane and an embedded endpoint:Restate topology is ingress + embedded SDK endpoint: the agent loop runs in your process when Restate invokes the registered deployment. Scale by registering multiple deployments; Restate routes invocations to them. For Temporal’s task-queue + worker model, see Temporal runtime and Distributed Execution.
Durable execution
Because every agent run is a Restate durable invocation:- Process crashes do not lose progress — completed steps are not re-executed; given approvals are not re-requested
- Deploys are safe — restart the process; Restate resumes from recorded journal entries
- Runs outlive the client attach — the invocation continues in Restate even if your subscriber disconnects
Closedoes not terminate invocations — callingAgent.Close()shuts down the local SDK endpoint and owned connections; in-flight invocations keep running and resume when an endpoint is available again
GetAgentRun / GetAgentStream reconnect protocol.
Topology
Production topology is:- Run Restate (Cloud or self-hosted)
- Run one or more agent processes with
restate.WithRestateConfig(each embeds an SDK endpoint) - Register deployments (automatic when
AdminURLis set, or via the Restate admin/CLI)
Streaming and approvals
Events are delivered through a Restate PubSub virtual object (AgentEventLog) — a durable, ordered event log. Every published event is appended with a monotonic offset; subscribers receive the same events in the same order.
Delivery model:
After a disconnect — stream reconnect with
GetAgentStream:
Always persist the runID and offset before processing each event. If your process crashes between reading an event and saving its offset, you will replay only that event on reconnect, never lose progress beyond it.
GetAgentRun:
Agent mode
WithAgentMode tells the runtime how to treat the run. AgentModeInteractive (default) is for user-facing apps with short, bounded sessions. AgentModeAutonomous is for background jobs and long-running pipelines. See Timeouts & Modes.
Sub-agents on Restate
Each specialist is a normal Restate agent: its ownAgentLoop_<name>, AgentEventLog_<name>, and listen port (unique when co-located). The parent invokes the child’s AgentLoop service; when delegated, the child publishes stream events to the parent’s AgentEventLog (same idea as Temporal’s RootWorkflowID). Give each agent a distinct Endpoint.ListenAddress / DeploymentURL. See Sub-agents.
Examples
Durable Agent (Restate)
Single-process crash lab and reconnect
Durable Execution
Crash recovery and GetAgentRun / GetAgentStream
Running Examples
Set AGENT_RUNTIME=restate and start Restate infra