telegram: a restart mid-turn strands a permanent message ending in the ▌ cursor #1212

Closed
opened 2026-10-27 13:39:28 +00:00 by sam · 0 comments
Owner

The live reply is a real, permanent Telegram message (SendRichMessage) whose messageID lives only in the in-memory liveReply struct. No shutdown path — supervisor restart in Start, daemon stop, launch() rebuilding Turns — edits or deletes it. A restart mid-turn strands a permanent message ending in ▌ that nothing will ever finish. The old draft path self-deleted (ephemeral 30-second previews); this is a new class of leftover introduced by the live-edit design.

Failure: the operator restarts the daemon or deploys a new build while a turn is streaming; the partial reply with the cursor persists in the chat indefinitely, implying the bot is still writing.

Design

On gateway Stop/restart, track in-flight liveReply instances (a registry keyed by chat/thread) and edit them to drop the cursor and/or append a cancelled/restarted marker — or delete them. Decide the desired end state for an interrupted turn.

Acceptance criteria

A daemon restart during a streamed turn leaves no ▌-terminated message; the partial reply is either completed, marked, or removed.

Close reason

Fixed: Gateway tracks in-flight liveReply instances in a registry Stop drains, marking each interrupted. Adversarial review found a critical race (concurrent finalize/abandon on the same reply could corrupt the message) plus two lesser issues (unbounded blocking Stop, a narrow post-snapshot registration gap) -- all three fixed: sync.Once serializes finalize/abandon, the drain is time-bounded (default 5s, entries left running in background past that), and registerLive checks a stopped flag to immediately abandon a straggler. Re-reviewed via targeted regression tests including a 20-iteration concurrent race test. task check clean, -race clean across repeated runs. Committed 09ea210.


Imported from beads archie-core-9zoa · GitHub #491 · type bug · priority P2 · created 2026-08-14 · closed 2026-08-14

The live reply is a real, permanent Telegram message (SendRichMessage) whose messageID lives only in the in-memory liveReply struct. No shutdown path — supervisor restart in Start, daemon stop, launch() rebuilding Turns — edits or deletes it. A restart mid-turn strands a permanent message ending in ▌ that nothing will ever finish. The old draft path self-deleted (ephemeral 30-second previews); this is a new class of leftover introduced by the live-edit design. Failure: the operator restarts the daemon or deploys a new build while a turn is streaming; the partial reply with the cursor persists in the chat indefinitely, implying the bot is still writing. ### Design On gateway Stop/restart, track in-flight liveReply instances (a registry keyed by chat/thread) and edit them to drop the cursor and/or append a cancelled/restarted marker — or delete them. Decide the desired end state for an interrupted turn. ### Acceptance criteria A daemon restart during a streamed turn leaves no ▌-terminated message; the partial reply is either completed, marked, or removed. ### Close reason Fixed: Gateway tracks in-flight liveReply instances in a registry Stop drains, marking each interrupted. Adversarial review found a critical race (concurrent finalize/abandon on the same reply could corrupt the message) plus two lesser issues (unbounded blocking Stop, a narrow post-snapshot registration gap) -- all three fixed: sync.Once serializes finalize/abandon, the drain is time-bounded (default 5s, entries left running in background past that), and registerLive checks a stopped flag to immediately abandon a straggler. Re-reviewed via targeted regression tests including a 20-iteration concurrent race test. task check clean, -race clean across repeated runs. Committed 09ea210. --- _Imported from beads `archie-core-9zoa` · GitHub #491 · type bug · priority P2 · created 2026-08-14 · closed 2026-08-14_
sam added the mediumbug labels 2026-10-27 13:39:28 +00:00
sam self-assigned this 2026-10-27 13:39:28 +00:00
sam closed this issue 2026-10-27 13:39:28 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sam/archie#1212