fix: an answer to a blocked agent goes ahead of the queue

Co-Authored-By: Ovis Fast (Claude) <[email protected]>
This commit is contained in:
FactorandOvis Fast committed 2026-11-19 12:19:54 +01:00
1 parent f3250e594e
commit e6afb3ebf9
3 files changed
+50 -5

No files matched your search

+22 -1
View File
@@ -8,7 +8,7 @@
// belongs to an agent (the draft, the queue, the attachments) is keyed by the
// agent's address, so two Claude Code agents never share a draft.
import { drain, gateAfter } from "./delivery.js";
import { drain, gateAfter, queueBlocksDirectSend } from "./delivery.js";
import { LIMITS } from "./attachments.js";
/**
@@ -495,3 +495,24 @@ export function canAutoSend(ready, key) {
export function stillSameAgent({ before, after, target }) {
return before !== "" && before === after && before === target;
}
/**
* Must a message that could go out now wait behind what is already in flight
* or in the queue?
*
* - a message on the wire always goes first (`draining`);
* - Ctrl+Enter (`mode "now"`) is the person's own order and does not wait;
* - an answer to an agent that is `blocked` does not wait either: the queue
* does not start while the agent waits for the person, so queueing the
* answer would leave the agent waiting for ever - it goes ahead (with
* `--force`) and the queue stays as it is;
* - otherwise it waits when a message is queued or counting down.
*
* @param {{draining:boolean, mode:string, status:string, queue:object[]|undefined}} input
* @returns {boolean}
*/
export function directSendBlocked({ draining, mode, status, queue }) {
if (draining) return true;
if (mode === "now" || status === "blocked") return false;
return queueBlocksDirectSend(queue);
}