mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-25 11:59:34 +00:00
fix(context-engine): forward abortSignal through delegation bridge to runtime compaction
delegateCompactionToRuntime built the CompactEmbeddedAgentSessionDirect params object without forwarding params.abortSignal. The ContextEngine compact() public API and CompactEmbeddedAgentSessionParams both carry an optional abortSignal, but the delegate bridge silently dropped it. When the user pressed stop during auto-compaction, the host aborted the wait via the signal, but the in-flight compaction LLM call continued to completion and wrote its summary to the session file. The next turn then saw a compacted session (e.g. 239→4 messages) the user had not consented to, causing model confusion about ongoing work and instructions. Fixes #89868
This commit is contained in:
@@ -603,6 +603,32 @@ describe("Engine contract tests", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("delegateCompactionToRuntime forwards the caller abortSignal to the runtime (#89868)", async () => {
|
||||
installCompactRuntimeSpy();
|
||||
const controller = new AbortController();
|
||||
await delegateCompactionToRuntime({
|
||||
sessionId: "s-abort",
|
||||
sessionFile: "/tmp/session-abort.json",
|
||||
tokenBudget: 4096,
|
||||
abortSignal: controller.signal,
|
||||
});
|
||||
|
||||
const compactRuntimeParams = requireCompactRuntimeParams(0);
|
||||
expect(compactRuntimeParams.abortSignal).toBe(controller.signal);
|
||||
});
|
||||
|
||||
it("delegateCompactionToRuntime passes undefined abortSignal when none supplied", async () => {
|
||||
installCompactRuntimeSpy();
|
||||
await delegateCompactionToRuntime({
|
||||
sessionId: "s-no-abort",
|
||||
sessionFile: "/tmp/session-no-abort.json",
|
||||
tokenBudget: 4096,
|
||||
});
|
||||
|
||||
const compactRuntimeParams = requireCompactRuntimeParams(0);
|
||||
expect(compactRuntimeParams.abortSignal).toBeUndefined();
|
||||
});
|
||||
|
||||
it("builds a normalized memory system prompt addition from the active memory prompt path", () => {
|
||||
registerMemoryPromptSection(({ citationsMode }) => [
|
||||
"## Memory Recall",
|
||||
|
||||
@@ -60,6 +60,7 @@ export async function delegateCompactionToRuntime(
|
||||
...(currentTokenCount !== undefined ? { currentTokenCount } : {}),
|
||||
force: params.force,
|
||||
customInstructions: params.customInstructions,
|
||||
abortSignal: params.abortSignal,
|
||||
workspaceDir:
|
||||
typeof runtimeContext.workspaceDir === "string" ? runtimeContext.workspaceDir : process.cwd(),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user