buzz-acp: multi-thread event batch collapses all replies to the newest event's thread (misroute)
- Dominant language
- Rust
- Stars
- 32.7k
- Forks
- 4.3k
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 253
Description
**Component:** `crates/buzz-acp` (queue.rs / format_prompt)
**Summary:** When a channel has pending events spanning more than one thread, buzz-acp drains them into a single batch and derives the *entire turn's* scope and `--reply-to` anchor from only the newest event in that batch. An agent answering content from thread A can have its reply anchored to thread B, because B's event happened to be newest in the batch.
**Evidence (code):**
- `flush_next()` "drains ALL events for that channel into a single batch" (queue.rs ~L258).
- `format_prompt()` uses only the last event for scope + anchor:
- `let last_event = batch.events.last()` (L1416)
- `let thread_tags = parse_thread_tags(&last_event.event)` (L1423)
- passed to `resolve_reply_anchor(...)` (L1479)
- `resolve_reply_anchor` (L1214) is correct in isolation; the defect is that one batch spanning N threads yields one anchor.
**Reproduction (observed on relay):** In channel `655a83db-…`, a human sent a new top-level message (`ad587ca1…`, no `e`-tag) at 17:43:34 asking "how useful is all of this work". The agent's answer (`8ce1dd5c…`, 35s later) was tagged `e … 2165572e… reply` — an *unrelated older thread* — because other messages in that older thread were newer in the same batch. Trigger root and reply root differ = misroute. Later turns routed correctly once each batch contained a single thread.
**Impact:** Human-facing replies land in the wrong thread when a user is active in two threads at once — confusing, and it re-triggers the wrong conversation's participants.
**Suggested fix direction:** Don't anchor a mixed-thread batch to `batch.events.last()`. Either (a) split a batch per-thread so each turn answers+anchors within one thread, or (b) resolve the reply anchor against the specific event a reply addresses. A new top-level trigger should never inherit an older thread's root.
**Repro data:** `buzz messages get --channel 655a83db-fc70-4556-a901-90c4f1a73cc8 --since 1786124580 --before 1786124940`
Contributor guide
Assessment
This issue has not been assessed yet.