Documentation
¶
Overview ¶
agent_with_reconnect demonstrates Agent.GetAgentStream: subscribe to a prior run's durable event log from a saved offset, simulating a mid-run crash and recovery in a single process. Works with Temporal and Restate (not local — no stream offsets).
Temporal embeds a worker; Restate embeds the SDK endpoint. Cancelling the Events context only closes the subscriber-side event channel — the Stream context (and durable run) keep running. Do not share one cancelable ctx for Stream and Events when simulating a subscriber crash.
AGENT_RUNTIME=temporal go run ./agent_with_reconnect [prompt] AGENT_RUNTIME=restate go run ./agent_with_reconnect [prompt]
Caller-side reconnect protocol:
- On Stream start, save runID alongside your correlation key.
- Track Offset() on each received event.
- On restart: GetAgentStream(ctx, savedRunID), then Events(ctx, WithOffset(savedOffset)).
- Events at offset ≤ savedOffset may be redelivered; discard duplicates if needed.
- Clear the saved runID on RUN_FINISHED or RUN_ERROR.
Click to show internal directories.
Click to hide internal directories.