mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-21 18:08:05 -06:00
dba9fb8509
* fix(queue): deliver queued steers in arrival order across turn boundaries * test(queue): align steer fallback with pre-dispatch injection
34 lines
1.1 KiB
TypeScript
34 lines
1.1 KiB
TypeScript
// Resolves queue mode and admission policy for a reply turn.
|
|
import type { QueueSettings } from "./queue.js";
|
|
|
|
/** Queue decisions for messages that arrive while an agent run is active. */
|
|
export type ActiveRunQueueAction = "run-now" | "enqueue-followup" | "drop";
|
|
|
|
/** Resolves whether an active session should run, queue, or drop a new inbound turn. */
|
|
export function resolveActiveRunQueueAction(params: {
|
|
queueAdmissionState?: "empty" | "steering" | "ready";
|
|
isActive: boolean;
|
|
isHeartbeat: boolean;
|
|
shouldFollowup: boolean;
|
|
queueMode: QueueSettings["mode"];
|
|
resetTriggered?: boolean;
|
|
}): ActiveRunQueueAction {
|
|
if (!params.isActive && (!params.queueAdmissionState || params.queueAdmissionState === "empty")) {
|
|
return "run-now";
|
|
}
|
|
if (params.isHeartbeat) {
|
|
return "drop";
|
|
}
|
|
if (params.resetTriggered) {
|
|
return "run-now";
|
|
}
|
|
if (params.queueAdmissionState && params.queueAdmissionState !== "empty") {
|
|
return "enqueue-followup";
|
|
}
|
|
// Follow-up queueing is only meaningful for non-heartbeat user turns.
|
|
if (params.shouldFollowup) {
|
|
return "enqueue-followup";
|
|
}
|
|
return "run-now";
|
|
}
|