Skip to content

[Bug]: One queued agent message makes every later agent auto send to that thread queue until its turn ends #41455

Closed

Description

@cyppe

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/server

Steps to reproduce

  1. Thread B runs one long turn on a provider with active steering (Claude), for example a 10-minute foreground command.
  2. An agent in thread A queues a message to B: t3_thread_send {"threadId": "<B>", "mode": "queue", "message": "first"}. It becomes a queued run created by an agent.
    The same happens when the agent in A sends B a slash command with mode: "auto" (for example /context): since fix(server): slash commands sent during a turn wait instead of steering #40316 it is queued behind the active run.
  3. An agent in a different thread C sends B a plain message: t3_thread_send {"threadId": "<B>", "mode": "auto", "message": "urgent"}.

Expected behavior

C's auto send steers into B's running turn, as it does when nothing is queued. The ordering guard from #39417 only needs to keep one sender's messages in order, so a queued message from A should not hold back a message from C. (A's own later auto sends waiting behind A's queued message would keep #39404 fixed.)

Actual behavior

C's send returns delivery: "queued", and so does every later auto send from any agent, until B's turn ends. With a turn that runs for hours, those messages wait for hours.

The guard in Orchestrator.dispatchMessage turns an agent's auto steer into queue_after_active whenever the thread holds any non-held queued run whose message an agent created, without looking at who sent it:

// An agent's automatic send must not overtake an earlier agent message still queued
// (e.g. behind /compact), or the agent receives them out of send order.
if (
command.deliveryIntent === "auto" &&
command.createdBy === "agent" &&
(dispatchMode.type === "steer_active" || dispatchMode.type === "restart_active")
) {
const queuedRuns = projection.runs.filter(
(run) => run.status === "queued" && run.queueHeld !== true,
);
if (queuedRuns.length > 0) {
const queuedMessages = yield* projectionStore
.getMessagesById(
command.threadId,
queuedRuns.map((run) => run.userMessageId),
)
.pipe(mapDispatchError(command));
if ([...queuedMessages.values()].some((message) => message.createdBy === "agent")) {
dispatchMode = { type: "queue_after_active" };
}
}

A slash command an agent sends is always queued here, so it is one way to start the chain:

// A provider runs a steered command in place of the turn's task, so commands wait.
return mode.type === "steer_active" && isSlashCommand(message)
? { type: "queue_after_active" }
: mode;

Messages already carry senderThreadId, so the check could compare the queued messages' senderThreadId with the incoming command's.

Impact

Major degradation or frequent failure

Version or commit

Seen on 0.1.12 nightly builds since 2026-11-22 (last on 0.1.12-nightly.20261123.5138). The same code is on main 5e12857.

Environment

Linux, desktop app with its local server, provider claudeAgent (claude-opus-5-5).

Logs or stack traces

One thread ran a single turn for about 5.5 hours.
- Before any queued message: auto sends from other threads came back "steered".
- One agent then sent that thread one message with mode "queue" (queued run 2).
- From then on, about 40 auto sends from five other agent threads all came back "queued".
  Nothing reached the running turn for about 1.5 hours.
- When the turn ended, the queued runs started one after another.
- Explicit mode "steer" sends in the same window came back "steered" and were delivered.

Workaround

Senders pass mode: "steer" to a thread that has a running turn, and fall back to auto when steer is refused because no turn is running.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions