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
- NVIDIA says Nemotron 3 Ultra hit 97.1% on agentic RTL chip-design tasks — NVIDIAAI · 2026-07-27
- Tokyo Agent Forge hackathon shipped production-ready AI agents in one day — DavidBennett__ · 2026-07-27
- Long-running agents will need immutable event logs, this thread argues — sebpaquet · 2026-07-27
- Agentic Data Science in Practice: Agents Write Code but Answer Wrong Questions — hugobowne · 2026-07-27
- A VS Code extension adds Markdown-style highlighting to Alchemy string templates — samgoodwin89 · 2026-07-27
- Claude’s Stripe MCP connector is being called unusable after repeated disconnects — evielync · 2026-07-27