Durable Streaming
Stream plan and execution state through stored events, not transient sockets alone.
Install
One-line install
npx attrition-sh pack install durable-streaming
AGENTS.md snippet (Claude Code / Cursor)
# Durable Streaming # See: /packs/durable-streaming
Raw Markdown
Machine-readable body for agent ingestion or copy/paste.
Telemetry
Not yet measuredSummary
A transport and persistence pattern for agents that need progressive rendering, reconnect safety, and post-run replay without losing the benefits of token or step streaming.
Fit and expected payoff
When this pack earns its extra structure, when to skip it, and what it should improve.
Use when
Situations where this pack earns its extra structure.
- The app needs live progress plus later replay or audit.
- Users may reconnect mid-run or review the run after completion.
- You want plan, steps, and final answer to stream through one event system.
Avoid when
Keeps the pack from becoming a default hammer.
- A simple transient text stream is enough and replay is unnecessary.
- The app has no need to surface intermediate state to the user.
What it improves
Expected outcomes if implemented well.
- Streaming survives beyond one network response.
- The same event log powers UX, audit, and evaluation playback.
- Step state is visible before the final answer completes.
Minimal instructions
Smallest useful starting point.
Persist streaming as ordered events. Emit events such as: - run.started - plan.created - step.started - step.completed - text.delta - quality.checked - run.completed Render the UI from stored events, not just an in-flight response.
Full instructions
Complete natural-language instruction set.
Implement streaming as a durable event log. When a run starts: 1. create a draft assistant message 2. append ordered events for plan, steps, deltas, and completion 3. update the message as text accumulates 4. finalize the answer packet at completion The UI should subscribe to event state and progressively render: - draft answer text - planned steps - executed steps - source additions - quality checks Prefer durability over pure SSE when operator review matters.
Evaluation checklist
These checks should pass before you consider the pattern production-ready.
- Can the UI recover mid-run if the page reconnects?
- Are plan and step states visible before the final answer completes?
- Does the final packet reconcile cleanly with the streamed events?
Common failure modes
Every check below traces back to a specific production failure. Read as: "I would think about X because in production Y can happen."
- Mid
The app shows a spinner until completion and hides real state changes.
- Trigger
- (legacy — trigger not separated)
- Prevention
- (legacy — no explicit prevention)
- Mid
Streaming works only during the request and cannot be replayed later.
- Trigger
- (legacy — trigger not separated)
- Prevention
- (legacy — no explicit prevention)
- Mid
The final answer and event stream diverge because there is no final reconciliation step.
- Trigger
- (legacy — trigger not separated)
- Prevention
- (legacy — no explicit prevention)