mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 12:41:37 +00:00
refactor(runtime): consolidate followup, gateway, and provider dedupe paths
This commit is contained in:
@@ -148,6 +148,27 @@ describe("createFollowupRunner compaction", () => {
|
||||
});
|
||||
|
||||
describe("createFollowupRunner messaging tool dedupe", () => {
|
||||
function createMessagingDedupeRunner(
|
||||
onBlockReply: (payload: unknown) => Promise<void>,
|
||||
overrides: Partial<{
|
||||
sessionEntry: SessionEntry;
|
||||
sessionStore: Record<string, SessionEntry>;
|
||||
sessionKey: string;
|
||||
storePath: string;
|
||||
}> = {},
|
||||
) {
|
||||
return createFollowupRunner({
|
||||
opts: { onBlockReply },
|
||||
typing: createMockTypingController(),
|
||||
typingMode: "instant",
|
||||
defaultModel: "anthropic/claude-opus-4-5",
|
||||
sessionEntry: overrides.sessionEntry,
|
||||
sessionStore: overrides.sessionStore,
|
||||
sessionKey: overrides.sessionKey,
|
||||
storePath: overrides.storePath,
|
||||
});
|
||||
}
|
||||
|
||||
it("drops payloads already sent via messaging tool", async () => {
|
||||
const onBlockReply = vi.fn(async () => {});
|
||||
runEmbeddedPiAgentMock.mockResolvedValueOnce({
|
||||
@@ -156,12 +177,7 @@ describe("createFollowupRunner messaging tool dedupe", () => {
|
||||
meta: {},
|
||||
});
|
||||
|
||||
const runner = createFollowupRunner({
|
||||
opts: { onBlockReply },
|
||||
typing: createMockTypingController(),
|
||||
typingMode: "instant",
|
||||
defaultModel: "anthropic/claude-opus-4-5",
|
||||
});
|
||||
const runner = createMessagingDedupeRunner(onBlockReply);
|
||||
|
||||
await runner(baseQueuedRun());
|
||||
|
||||
@@ -176,12 +192,7 @@ describe("createFollowupRunner messaging tool dedupe", () => {
|
||||
meta: {},
|
||||
});
|
||||
|
||||
const runner = createFollowupRunner({
|
||||
opts: { onBlockReply },
|
||||
typing: createMockTypingController(),
|
||||
typingMode: "instant",
|
||||
defaultModel: "anthropic/claude-opus-4-5",
|
||||
});
|
||||
const runner = createMessagingDedupeRunner(onBlockReply);
|
||||
|
||||
await runner(baseQueuedRun());
|
||||
|
||||
@@ -197,12 +208,7 @@ describe("createFollowupRunner messaging tool dedupe", () => {
|
||||
meta: {},
|
||||
});
|
||||
|
||||
const runner = createFollowupRunner({
|
||||
opts: { onBlockReply },
|
||||
typing: createMockTypingController(),
|
||||
typingMode: "instant",
|
||||
defaultModel: "anthropic/claude-opus-4-5",
|
||||
});
|
||||
const runner = createMessagingDedupeRunner(onBlockReply);
|
||||
|
||||
await runner(baseQueuedRun("slack"));
|
||||
|
||||
@@ -217,12 +223,7 @@ describe("createFollowupRunner messaging tool dedupe", () => {
|
||||
meta: {},
|
||||
});
|
||||
|
||||
const runner = createFollowupRunner({
|
||||
opts: { onBlockReply },
|
||||
typing: createMockTypingController(),
|
||||
typingMode: "instant",
|
||||
defaultModel: "anthropic/claude-opus-4-5",
|
||||
});
|
||||
const runner = createMessagingDedupeRunner(onBlockReply);
|
||||
|
||||
await runner(baseQueuedRun());
|
||||
|
||||
@@ -238,12 +239,7 @@ describe("createFollowupRunner messaging tool dedupe", () => {
|
||||
meta: {},
|
||||
});
|
||||
|
||||
const runner = createFollowupRunner({
|
||||
opts: { onBlockReply },
|
||||
typing: createMockTypingController(),
|
||||
typingMode: "instant",
|
||||
defaultModel: "anthropic/claude-opus-4-5",
|
||||
});
|
||||
const runner = createMessagingDedupeRunner(onBlockReply);
|
||||
|
||||
await runner(baseQueuedRun());
|
||||
|
||||
@@ -275,15 +271,11 @@ describe("createFollowupRunner messaging tool dedupe", () => {
|
||||
},
|
||||
});
|
||||
|
||||
const runner = createFollowupRunner({
|
||||
opts: { onBlockReply },
|
||||
typing: createMockTypingController(),
|
||||
typingMode: "instant",
|
||||
const runner = createMessagingDedupeRunner(onBlockReply, {
|
||||
sessionEntry,
|
||||
sessionStore,
|
||||
sessionKey,
|
||||
storePath,
|
||||
defaultModel: "anthropic/claude-opus-4-5",
|
||||
});
|
||||
|
||||
await runner(baseQueuedRun("slack"));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { applyQueueDropPolicy, shouldSkipQueueItem } from "../../../utils/queue-helpers.js";
|
||||
import { FOLLOWUP_QUEUES, getFollowupQueue } from "./state.js";
|
||||
import { getExistingFollowupQueue, getFollowupQueue } from "./state.js";
|
||||
import type { FollowupRun, QueueDedupeMode, QueueSettings } from "./types.js";
|
||||
|
||||
function isRunAlreadyQueued(
|
||||
@@ -57,11 +57,7 @@ export function enqueueFollowupRun(
|
||||
}
|
||||
|
||||
export function getFollowupQueueDepth(key: string): number {
|
||||
const cleaned = key.trim();
|
||||
if (!cleaned) {
|
||||
return 0;
|
||||
}
|
||||
const queue = FOLLOWUP_QUEUES.get(cleaned);
|
||||
const queue = getExistingFollowupQueue(key);
|
||||
if (!queue) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -20,6 +20,14 @@ export const DEFAULT_QUEUE_DROP: QueueDropPolicy = "summarize";
|
||||
|
||||
export const FOLLOWUP_QUEUES = new Map<string, FollowupQueueState>();
|
||||
|
||||
export function getExistingFollowupQueue(key: string): FollowupQueueState | undefined {
|
||||
const cleaned = key.trim();
|
||||
if (!cleaned) {
|
||||
return undefined;
|
||||
}
|
||||
return FOLLOWUP_QUEUES.get(cleaned);
|
||||
}
|
||||
|
||||
export function getFollowupQueue(key: string, settings: QueueSettings): FollowupQueueState {
|
||||
const existing = FOLLOWUP_QUEUES.get(key);
|
||||
if (existing) {
|
||||
@@ -57,10 +65,7 @@ export function getFollowupQueue(key: string, settings: QueueSettings): Followup
|
||||
|
||||
export function clearFollowupQueue(key: string): number {
|
||||
const cleaned = key.trim();
|
||||
if (!cleaned) {
|
||||
return 0;
|
||||
}
|
||||
const queue = FOLLOWUP_QUEUES.get(cleaned);
|
||||
const queue = getExistingFollowupQueue(cleaned);
|
||||
if (!queue) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user