react-ag-ui: message queue drains while isSendDisabled is true (expose hold/release or honour isSendDisabled)

Author: notsaltylolCreated Sep 26, 2026Updated Sep 26, 2026
Labelsbug

Package: @assistant-ui/react-ag-ui (seen on 0.0.58, still present in 0.0.62), @assistant-ui/core 0.3.21

What happens

With unstable_enableMessageQueue: true, useAgUiRuntime dispatches the next queued message as soon as the thread goes idle. It decides this with:

javascript
const queueBusy = isRunning || core.getPendingInterrupts() !== null;

isSendDisabled is not considered. So when an app blocks sending after a run ends, the queue still sends every queued message. Examples:

  • the stream dropped and the app is recovering the lost turn;
  • the server refused the request and the app wants the user to resolve it first.

In our case each dispatched message is refused by our transport. It is left in the thread as a failed message. Its failed run then counts as busy→idle, which releases the next queued message, so the whole queue drains into failures.

Why we can't fix it from the app

  • @assistant-ui/core 0.3.21 added hold() / release() to the controller returned by createMessageQueue, which is exactly the pause we need. Only LocalThreadRuntimeCore calls them (for voice).
  • In useAgUiRuntime the controller lives in a private ref. Only its adapter (items, enqueue, steer, move, edit, remove) is passed to the store.
  • Switching unstable_enableMessageQueue off while blocked calls clear(), which drops the user's queued messages.

Suggested fix (either works)

  1. In useAgUiRuntime, call hold() while options.isSendDisabled is true and release() when it clears. The pause is separate from the Stop pause and the busy tracking, so it doesn't reset either.
  2. Or expose the controller's hold/release on the returned runtime (e.g. runtime.unstable_holdQueue()), so apps can pause the queue themselves.

Our workaround: a pnpm patch that adds || options.isSendDisabled === true to queueBusy. It has a side effect: notifyBusy() clears the pause that Stop sets, so a Stop-paused queue can drain after an unrelated isSendDisabled blip. That is why option 1 is the better fix.

Track in Rupic

Source: assistant-ui/assistant-ui