Skip to content
agentsessions

Durable agent sessions Run it once. Replay it exactly.

Your agent does not call the model. The host does, and records the answer. That one inversion is why a run here can be replayed byte-for-byte, forked for nothing, and checked by someone who does not trust you.
local · no server, no API keyprovider calls 0
$agentctl exec --input "hello world"session sess-6ff29e8d93d3a4c65f6f38bcseq=1   EVENT_INPUT  user: hello worldcalling providerseq=2   EVENT_MODEL_CALLseq=3   EVENT_OUTPUT  assistant: echo:hello worldseq=4   EVENT_ENDone turn, journaled and hash-chained
$agentctl replay --session sess-6ff29e8dseq=1   EVENT_INPUT  user: hello worldseq=2   EVENT_MODEL_CALLseq=3   EVENT_OUTPUT  assistant: echo:hello worldseq=4   EVENT_ENDbyte-identical, and the provider was never called

Nearly every agent framework lets the agent call the provider. The completion then exists only in the agent’s memory, so the log can describe what happened but never rebuild it. Re-running is the best on offer, and a re-run drifts.

Here the host performs the call on the harness’s behalf. The completion passes through the host on its way back and lands in the journal as a record. Look for the arrow to the provider: it leaves the host, and the sandbox has none.

1 / 7one turn, across process boundaries
A turn flowing from your application into the agentsessions host, which provisions a sandbox through the Runtime SPI and drives a harness inside it, while the host itself makes the model call and appends the result to the journal. YOUR APPLICATIONAGENTSESSIONS HOSTSANDBOXhost makes the callappendcreate / restoreharness stream, bidirectionalclient / SDKSessions APIPlacerControllerModel providerJournalRuntimeHarness A turn flowing from your application into the agentsessions host, which provisions a sandbox through the Runtime SPI and drives a harness inside it, while the host itself makes the model call and appends the result to the journal. YOUR APPLICATIONAGENTSESSIONS HOSTSANDBOXhost makes the callappendcreate / restoreharness stream,bidirectionalclient / SDKSessions APIPlacerControllerModel providerJournalRuntimeHarness
Your application calls Exec, and records stream back as they commit.

Replay costs nothing

Recorded completions are served from the log, so reconstruction is the same bytes rather than a similar answer. Zero provider calls, enforced in the controller and covered in CI.

Fork is not a re-run

Children inherit the parent’s prefix and diverge independently, so a fan-out starts from identical state at no model cost.

Placement is checked first

A harness declares what it needs to survive a resume and a runtime declares what it offers. Impossible pairings are refused before compute is provisioned, so the system degrades honestly instead of resuming wrong.

execcompute LIVE
A session log growing by four records, being replayed, forked into a child, then suspended and resumed. 1INPUT2MODEL_CALL3OUTPUT4END5resumed5LIFECYCLE6child turnsessionfork A session log growing by four records, being replayed, forked into a child, then suspended and resumed. 1INPUT2MODEL_CALL3OUTPUT4END5resumed5LIFECYCLE6child turnsessionfork
Each turn appends typed, hash-chained records to one append-only log.

A plain Deployment and a PersistentVolume: no substrate, no memory snapshot. A turn, a second turn, a free replay, a two-way fork, suspend and resume, then the pod is deleted and a different pod picks the session up mid-conversation.

kind cluster — the full lifecycle, then pod deathrecorded
Recorded by hack/demos/kubernetes-tour.sh against deploy/kubernetes/agentsessionsd.yaml. Nothing is staged: the replay after the pod dies is served from the journal, so the model is called zero times.

The same lifecycle with each session’s actor in a micro-VM. Resume brings back the same actor with its memory, replay calls the model zero times, and a snapshot that cannot restore that memory is refused.

micro-VM actors — the lifecycle pagerecorded

A two-minute recording of the lifecycle page from examples/session-lifecycle-ui, driven against a kind cluster whose actors run in micro-VMs, with a caption for each of six steps. One: a memory-tier session is created and runs a turn, which places its actor on a micro-VM worker with one model call. Two: suspend checkpoints the actor, which shows SUSPENDED with a MEMORY snapshot. Three: resume restores it, RUNNING with the same actor UID, and a second turn's reply still lists the first turn's issue. Four: a fork at the head starts a child session whose own turn carries the parent's two issues plus a third. Five: a stateless-tier session runs a turn and is replayed; the controller counts zero model calls and the fake model's counter does not move. Six: on a template that takes VOLUMES snapshots, suspend is refused with FailedPrecondition, required MEMORY, observed VOLUMES. The end card repeats the claim: the same actor after resume, and zero model calls on replay. The model is a fake model.

Recorded from the page in examples/session-lifecycle-ui, whose README brings it up with the example's up.sh and ui.sh; the micro-VMs need /dev/kvm in the Docker host. The model is a fake model that counts its calls, and the count did not move during the replay.

Three contracts. One neutral wire form with a Go SPI, and Event is shared by the log and the harness stream, so what is journaled is exactly what the harness emitted.

Sessions

CreateSession Exec Fork
GetSession Replay Suspend
ListSessions Resume

Harness

Describe the static contract
Run drive one turn,
emitting typed events

Runtime

Create Restore Stop
Snapshot Fork Status
Capabilities

Three runtimes ship. runtime/local is filesystem-only and refuses a memory-snapshot harness rather than resuming it wrongly. runtime/remote attaches to a harness you are already running, so your agent is registered by address rather than compiled into the server. runtime/substrate runs both capability tiers against a real cluster on every pull request with substrate-relevant changes, both on a micro-VM. Kata, Cloud Hypervisor, and plain pods fit the same SPI. No provider SDK appears anywhere, and CI asserts the core links no backend vendor.

Terminal window
go install github.com/agent-primitives/sessions/cmd/agentctl@v0.4.0

Signed archives and container images are on the latest release.