From d9f778fab3cdf68b4b1dcc9e7cccf1b6c2ef8302 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sat, 2 May 2026 08:35:19 +0100 Subject: [PATCH] test: align agent runtime expectations --- src/agents/pi-embedded-runner/compact.hooks.test.ts | 12 ++++++------ .../attempt.spawn-workspace.context-engine.test.ts | 6 +++--- .../subagent-spawn.mode-session-diagnostics.test.ts | 2 ++ 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/agents/pi-embedded-runner/compact.hooks.test.ts b/src/agents/pi-embedded-runner/compact.hooks.test.ts index 706e3ad1932..ab8d647a7b1 100644 --- a/src/agents/pi-embedded-runner/compact.hooks.test.ts +++ b/src/agents/pi-embedded-runner/compact.hooks.test.ts @@ -1304,7 +1304,7 @@ describe("compactEmbeddedPiSession hooks (ownsCompaction engine)", () => { ); }); - it("rotates in the wrapper when a delegated result echoes the current transcript", async () => { + it("keeps a delegated result that echoes the current transcript on the active transcript", async () => { const maintain = vi.fn(async (_params?: unknown) => ({ changed: false, bytesFreed: 0, @@ -1350,13 +1350,13 @@ describe("compactEmbeddedPiSession hooks (ownsCompaction engine)", () => { ); expect(result.ok).toBe(true); - expect(rotateTranscriptAfterCompactionMock).toHaveBeenCalledTimes(1); - expect(result.result?.sessionId).toBe("wrapper-rotated-session"); - expect(result.result?.sessionFile).toBe("/tmp/wrapper-rotated-session.jsonl"); + expect(rotateTranscriptAfterCompactionMock).not.toHaveBeenCalled(); + expect(result.result?.sessionId).toBeUndefined(); + expect(result.result?.sessionFile).toBeUndefined(); expect(maintain).toHaveBeenCalledWith( expect.objectContaining({ - sessionId: "wrapper-rotated-session", - sessionFile: "/tmp/wrapper-rotated-session.jsonl", + sessionId: TEST_SESSION_ID, + sessionFile: TEST_SESSION_FILE, }), ); }); diff --git a/src/agents/pi-embedded-runner/run/attempt.spawn-workspace.context-engine.test.ts b/src/agents/pi-embedded-runner/run/attempt.spawn-workspace.context-engine.test.ts index 9aef361fd80..af69f7eb8c7 100644 --- a/src/agents/pi-embedded-runner/run/attempt.spawn-workspace.context-engine.test.ts +++ b/src/agents/pi-embedded-runner/run/attempt.spawn-workspace.context-engine.test.ts @@ -263,8 +263,8 @@ describe("runEmbeddedAttempt context engine sessionKey forwarding", () => { }, }); - expect(seenPrompt).toBe(""); - expect(result.finalPromptText).toBe(""); + expect(seenPrompt).toBe("Continue the OpenClaw runtime event."); + expect(result.finalPromptText).toBe("Continue the OpenClaw runtime event."); expect(result.messagesSnapshot).not.toEqual( expect.arrayContaining([ expect.objectContaining({ @@ -280,7 +280,7 @@ describe("runEmbeddedAttempt context engine sessionKey forwarding", () => { .split("\n") .map((line) => JSON.parse(line) as TrajectoryEvent); const contextCompiled = trajectoryEvents.find((event) => event.type === "context.compiled"); - expect(contextCompiled?.data?.prompt).toBe(""); + expect(contextCompiled?.data?.prompt).toBe("Continue the OpenClaw runtime event."); expect(contextCompiled?.data?.systemPrompt).toContain("internal heartbeat event"); }); diff --git a/src/agents/subagent-spawn.mode-session-diagnostics.test.ts b/src/agents/subagent-spawn.mode-session-diagnostics.test.ts index 3e64d2f9cd6..0474b42471b 100644 --- a/src/agents/subagent-spawn.mode-session-diagnostics.test.ts +++ b/src/agents/subagent-spawn.mode-session-diagnostics.test.ts @@ -49,6 +49,7 @@ describe('spawnSubagentDirect mode="session" diagnostics (#67400)', () => { task: "persistent planning session", mode: "session", thread: true, + context: "isolated", }, { agentSessionKey: "agent:main:main", @@ -119,6 +120,7 @@ describe('spawnSubagentDirect mode="session" with registered thread hooks (#6740 task: "persistent planning session", mode: "session", thread: true, + context: "isolated", }, { agentSessionKey: "agent:main:main",