


























@@ -7,7 +7,6 @@ import {
77embeddedAgentLog,
88nativeHookRelayTesting,
99onAgentEvent,
10-queueAgentHarnessMessage,
1110resetAgentEventsForTest,
1211type AgentEventPayload,
1312type EmbeddedRunAttemptParams,
@@ -18,6 +17,13 @@ import {
1817} from "openclaw/plugin-sdk/hook-runtime";
1918import { createMockPluginRegistry } from "openclaw/plugin-sdk/plugin-test-runtime";
2019import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
20+import { queueEmbeddedPiMessageWithOutcome } from "../../../../src/agents/pi-embedded-runner/runs.js";
21+22+function queueActiveRunMessageForTest(
23+ ...args: Parameters<typeof queueEmbeddedPiMessageWithOutcome>
24+): boolean {
25+return queueEmbeddedPiMessageWithOutcome(...args).queued;
26+}
2127import { CODEX_GPT5_BEHAVIOR_CONTRACT } from "../../prompt-overlay.js";
2228import {
2329buildCodexAppInventoryCacheKey,
@@ -1177,7 +1183,7 @@ describe("runCodexAppServerAttempt", () => {
11771183}),
11781184{ interval: 1 },
11791185);
1180-expect(queueAgentHarnessMessage("session-1", "after timeout")).toBe(false);
1186+expect(queueActiveRunMessageForTest("session-1", "after timeout")).toBe(false);
11811187});
1182118811831189it("does not count account rate-limit updates as turn completion activity", async () => {
@@ -1486,7 +1492,7 @@ describe("runCodexAppServerAttempt", () => {
14861492}),
14871493{ interval: 1 },
14881494);
1489-expect(queueAgentHarnessMessage("session-1", "after silent turn")).toBe(false);
1495+expect(queueActiveRunMessageForTest("session-1", "after silent turn")).toBe(false);
14901496});
1491149714921498it("applies before_prompt_build to Codex developer instructions and turn input", async () => {
@@ -2332,7 +2338,7 @@ describe("runCodexAppServerAttempt", () => {
23322338);
23332339await waitForMethod("turn/start");
233423402335-expect(queueAgentHarnessMessage("session-1", "more context", { debounceMs: 1 })).toBe(true);
2341+expect(queueActiveRunMessageForTest("session-1", "more context", { debounceMs: 1 })).toBe(true);
23362342await vi.waitFor(() => expect(requests.map((entry) => entry.method)).toContain("turn/steer"), {
23372343interval: 1,
23382344});
@@ -2377,8 +2383,8 @@ describe("runCodexAppServerAttempt", () => {
23772383);
23782384await waitForMethod("turn/start");
237923852380-expect(queueAgentHarnessMessage("session-1", "first", { debounceMs: 5 })).toBe(true);
2381-expect(queueAgentHarnessMessage("session-1", "second", { debounceMs: 5 })).toBe(true);
2386+expect(queueActiveRunMessageForTest("session-1", "first", { debounceMs: 5 })).toBe(true);
2387+expect(queueActiveRunMessageForTest("session-1", "second", { debounceMs: 5 })).toBe(true);
2382238823832389await vi.waitFor(
23842390() =>
@@ -2410,7 +2416,9 @@ describe("runCodexAppServerAttempt", () => {
24102416);
24112417await waitForMethod("turn/start");
241224182413-expect(queueAgentHarnessMessage("session-1", "late steer", { debounceMs: 30_000 })).toBe(true);
2419+expect(queueActiveRunMessageForTest("session-1", "late steer", { debounceMs: 30_000 })).toBe(
2420+true,
2421+);
2414242224152423await completeTurn({ threadId: "thread-1", turnId: "turn-1" });
24162424await run;
@@ -2435,12 +2443,12 @@ describe("runCodexAppServerAttempt", () => {
24352443);
24362444await waitForMethod("turn/start");
243724452438-expect(queueAgentHarnessMessage("session-1", "first", { steeringMode: "one-at-a-time" })).toBe(
2439-true,
2440-);
2441-expect(queueAgentHarnessMessage("session-1", "second", { steeringMode: "one-at-a-time" })).toBe(
2442-true,
2443-);
2446+expect(
2447+queueActiveRunMessageForTest("session-1", "first", { steeringMode: "one-at-a-time" }),
2448+).toBe(true);
2449+expect(
2450+queueActiveRunMessageForTest("session-1", "second", { steeringMode: "one-at-a-time" }),
2451+).toBe(true);
2444245224452453await vi.waitFor(
24462454() =>
@@ -2540,7 +2548,7 @@ describe("runCodexAppServerAttempt", () => {
25402548});
2541254925422550await vi.waitFor(() => expect(params.onBlockReply).toHaveBeenCalledTimes(1), { interval: 1 });
2543-expect(queueAgentHarnessMessage("session-1", "2")).toBe(true);
2551+expect(queueActiveRunMessageForTest("session-1", "2")).toBe(true);
25442552await expect(response).resolves.toEqual({
25452553answers: { mode: { answers: ["Deep"] } },
25462554});
@@ -3388,7 +3396,7 @@ describe("runCodexAppServerAttempt", () => {
33883396await expect(runCodexAppServerAttempt(params, { startupTimeoutFloorMs: 1 })).rejects.toThrow(
33893397"codex app-server startup timed out",
33903398);
3391-expect(queueAgentHarnessMessage("session-1", "after timeout")).toBe(false);
3399+expect(queueActiveRunMessageForTest("session-1", "after timeout")).toBe(false);
33923400});
3393340133943402it("passes the selected auth profile into app-server startup", async () => {
@@ -3450,7 +3458,7 @@ describe("runCodexAppServerAttempt", () => {
34503458params.timeoutMs = 1;
3451345934523460await expect(runCodexAppServerAttempt(params)).rejects.toThrow("turn/start timed out");
3453-expect(queueAgentHarnessMessage("session-1", "after timeout")).toBe(false);
3461+expect(queueActiveRunMessageForTest("session-1", "after timeout")).toBe(false);
34543462});
3455346334563464it("keeps extended history enabled when resuming a bound Codex thread", async () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。