buzz icon indicating copy to clipboard operation
buzz copied to clipboard

[Bug] Agent reply in one thread can remain stalled after another thread event is processed

Open atsu6 opened this issue 4 months ago • 2 comments

Description

When the same managed agent receives requests in two separate threads around the same time, the reply to the first thread can remain stalled without any visible error.

In the observed test, the agent successfully replied in Thread B, but did not reply in Thread A until it was mentioned again in Thread A.

Steps to reproduce

  1. Add the same managed agent to a channel.
  2. In Thread A, mention the agent and ask it to calculate the sum of the integers from 1 to 100, then reply only in Thread A using the identifier THREAD-A.
  3. Before the agent replies in Thread A, mention the same agent in Thread B and ask it to calculate the sum of the integers from 1 to 50, then reply only in Thread B using the identifier THREAD-B.
  4. Observe the replies in both threads.
  5. If Thread A remains unanswered, mention the agent again in Thread A.

Actual behavior

  • The agent replied successfully in Thread B.
  • Thread A remained unanswered for several minutes.
  • No failure, cancellation, or retry state was displayed.
  • After another mention in Thread A, the agent returned the expected answer to the original request.

Observed timeline:

  • 01:57 - Request posted in Thread A
  • 01:57 - Request processed and answered in Thread B
  • 02:00 - Thread A was still unanswered, and the agent was mentioned again
  • 02:01 - The agent answered the original Thread A request

Expected behavior

Both requests should eventually receive responses.

If a request is interrupted, cancelled, or fails, Buzz should display an explicit error or retry state rather than silently leaving the thread unanswered.

Additional information

After being mentioned again, the agent claimed that it had moved to another event before completing the pending reply. This statement was generated by the agent and should not be treated as evidence of the internal cause.

The confirmed observations are only:

  1. Thread B received a reply.
  2. Thread A did not receive a reply.
  3. Thread A received the original answer only after another mention.

The problem may relate to event scheduling, cancellation, queueing, or turn-resumption behavior, but the internal cause has not been verified.

atsu6 avatar Jul 25 '26 17:07 atsu6

I think this is the session key rather than a missing error state.

Sessions are keyed by channel only (crates/buzz-acp/src/pool.rs:1468), so every thread in a channel shares one session. When events from two threads land in the same batch, thread history is fetched for the last event only (pool.rs:2495). The earlier thread's mention reaches the model with no context attached and gets dropped. Re-mentioning fixes it because that makes the thread last.

If that's right, the fix is keying sessions by (channel_id, thread_root). The catch: sessions are never evicted today, so per-thread keys would multiply the growth in #2961. That probably needs a bound first.

Happy to write it up as a feature request if maintainers think it's the right direction.

jack-owen avatar Jul 27 '26 12:07 jack-owen

Corroborating real-world incident: approved work silently abandoned after a second thread arrived

I encountered the same failure shape in an owner-only managed-agent workflow on August 12–13, 2026.

Observed timeline (America/Chicago)

  1. At 9:09:56 p.m. CDT, the owner approved creation of two internal architecture artifacts in Thread A.
  2. At 9:10:48 p.m., the agent replied in Thread A that work was in progress and explicitly named the two deliverables and the scope boundary.
  3. At 9:16:36 p.m., the owner sent a separate request in Thread B in the same channel.
  4. The agent handled Thread B and its follow-on work successfully.
  5. Thread A never resumed. It received no completion, failure, cancellation, paused-state, or blocker message, and neither promised artifact existed.
  6. At 6:50:29 a.m. the next morning, the owner had to ask whether the work had finished. Only then was the dropped handoff discovered and the work restarted.

Confirmed observations and boundary

The relay thread history confirms the two requests, the agent's explicit start-of-work message, and the absence of a completion or blocker in Thread A. The workspace and canonical project were also checked the next morning; neither artifact existed.

I am not asserting the internal root cause from these observations alone. The behavior is consistent with this issue and with the per-channel dispatch/steering limitation described in #3563: a second thread can displace in-progress work without preserving a durable continuation. The important product failure is observable regardless of the internal mechanism: accepted work disappeared silently.

Impact

This is more costly than a delayed reply. The owner reasonably relied on the agent's explicit statement that the work was underway and planned to use the deliverables first thing the next morning. The silent drop delayed the next agent build and required the owner to detect and recover the failure manually.

Expected behavior

  • A new request in Thread B must not implicitly cancel or erase accepted work in Thread A.
  • If Buzz interrupts or steers the active turn, the prior commitment should remain durably queued with its source thread, status, and required callback destination.
  • After the newer turn completes, Buzz should resume the prior work automatically, unless the owner explicitly cancels or reprioritizes it.
  • If automatic resumption is impossible, Buzz should publish a visible paused, cancelled, failed, or needs-attention state in Thread A.
  • Completion or blocker reporting should return to Thread A rather than depend on the owner mentioning the agent again.
  • Restart and compaction recovery should not create duplicate execution.

Suggested regression case

  1. Start material work in Thread A and record a durable in-progress commitment.
  2. Before completion, send a separate request in Thread B in the same channel.
  3. Allow Thread B to complete.
  4. Verify that Thread A resumes and posts exactly one completion or blocker to its original root without another mention.

This incident was observed on a hosted Buzz community. The currently installed Desktop version is 0.5.11; the exact client version at the moment Thread A was displaced was not independently captured.

mhyatt18 avatar Aug 13 '26 12:08 mhyatt18