| title | Resume | |
|---|---|---|
| sdk | java | |
| spec_sections |
|
|
| kind | guide | |
| since | 1.0.0 |
Resume lets a client reconnect to the same logical session after a disconnect and replay any missed events, without re-submitting jobs.
session.welcomecarries aresume_token— an opaque string generated by the runtime.- The runtime's
ResumeBufferretains alljob.event,job.result, andjob.errorframes for a configurable window (default 60 s). - On reconnect, the client sends a new
session.hellowithresume_tokenandlast_event_seq(the highest sequence number the client processed). - The runtime replays all buffered frames with
event_seq > last_event_seqbefore allowing new events.
// 1. Save token + seq before the connection drops
String token = client.session().resumeToken();
long lastSeq = client.session().lastReceivedSeq();
// ... transport failure — reconnect the underlying connection ...
Transport newTransport = WebSocketTransport.connect(serverUri);
// 2. Resume
ArcpClient fresh = ArcpClient.builder(newTransport)
.bearer(myBearerToken)
.resumeToken(token)
.lastEventSeq(lastSeq)
.build();
fresh.connect(Duration.ofSeconds(5));
// 3. Re-attach handles to running jobs (events replay automatically)
JobHandle handle = fresh.reattach(myJobId);
JobResult result = handle.result().get();client.reattach(jobId) sends job.subscribe and returns a JobHandle
backed by the replayed event stream.
The runtime discards buffered frames after a configurable TTL:
ArcpRuntime runtime = ArcpRuntime.builder()
.resumeWindowSec(300) // default: 60 s; set to 5 min
.build();If the client reconnects after the window, the runtime returns
RESUME_WINDOW_EXPIRED (non-retryable). In that case:
- Start a fresh session (new
session.hello, noresume_token). - Re-subscribe to any jobs that are still running:
client.subscribe(jobId, SubscribeOptions.live()). - Events emitted before the reconnect are lost — design agents to checkpoint state externally if durability is required.
The ack feature tells the runtime which events have been processed,
allowing earlier eviction from the buffer. With ack negotiated, the
client periodically emits session.ack { last_processed_seq }. Frames
at or below last_processed_seq are eligible for early reclamation.
See guides/sessions.md.
examples/resume/ — demonstrates a simulated
disconnect mid-stream and the reconnect/replay flow.
recipes/stream-resume/ — shows how to
persist the resume token and last-seq to durable storage between process
restarts.