Qwen Code adds epoch tokens to stop stale SSE cursors after daemon restarts
doudouOUC · ghdev · 2026-07-22
Qwen Code adds epoch tokens to fix stale SSE cursors across daemon restarts
This Qwen Code PR hardens the daemon’s event replay and reconnect path in three ways.
1) Stale cursor detection now uses an epoch token
Every session event bus now generates a random epoch token. That token is returned in session load/resume/create responses, in the non-blocking prompt envelope, and in an X-Qwen-Event-Epoch header on both SSE surfaces.
Clients echo the epoch back on reconnect alongside Last-Event-ID. If the token does not match the current bus epoch, the daemon forces a resync instead of trusting event-id arithmetic. A new detail: 'epochmismatch' marker makes the trigger explicit.
2) Replay compaction keeps correct turn attribution
The compaction engine now preserves turn attribution more carefully:
- merged text/thought events re-stamp the latest promptId, originatorClientId, and data.sessionId
- folded tool-call events use latest-wins attribution
3) Replay failures are surfaced instead of hidden
If ingest/seed fails, the bus now latches a degraded flag. Replay snapshots built afterward are marked degraded, session-load responses expose replayDegraded, and the daemon logs an operator breadcrumb plus a warning when /acp serves a degraded initial replay.
The TypeScript SDK also learns the epoch, stores it next to the cursor, and sends it on every reconnect, including the subscribe path used inside prompt().
More from coding & agent
- Treating agents like 50 First Dates: a 3-layer context system so every conversation doesn't start from zero — evielync · 2026-09-11
- SmolVM open-sources persistent computer infrastructure for agents that outlive chat sessions — aniketmaurya · 2026-09-11
- ARRM targets silent economic regressions in AI agents that functional tests miss — Beautiful_Belt_601 · 2026-09-11
- Dev builds browser 3D pizza delivery game with Claude: physics, GPS pathfinding, traffic AI — vinishkapoor · 2026-09-11
- Build X Carousel Posts from One Wide Image: A Splitter Tool Plus YouMind Skill Workflow — sujingshen · 2026-09-11
- "Anyone still coding the old way?" The joke capturing post-AI programming culture — lxfater · 2026-09-11