























11import type { AgentMessage } from "openclaw/plugin-sdk/agent-core";
2-import { beforeEach, describe, expect, it, vi } from "vitest";
2+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
33import type { ContextEngine } from "../context-engine/types.js";
44import type { PreparedCliRunContext } from "./cli-runner/types.js";
55@@ -122,7 +122,7 @@ function expectMessageText(message: AgentMessage | undefined, expected: string):
122122}
123123124124describe("runPreparedCliAgent context engine lifecycle", () => {
125-beforeEach(() => {
125+beforeEach(async () => {
126126executePreparedCliRunMock.mockReset();
127127executePreparedCliRunMock.mockResolvedValue({
128128text: " final answer ",
@@ -140,6 +140,16 @@ describe("runPreparedCliAgent context engine lifecycle", () => {
140140loadCliSessionHistoryMessagesMock.mockResolvedValue([]);
141141getGlobalHookRunnerMock.mockReset();
142142getGlobalHookRunnerMock.mockReturnValue(null);
143+const { restoreCliRunnerTestDeps, setCliRunnerTestDeps } = await import("./cli-runner.js");
144+restoreCliRunnerTestDeps();
145+setCliRunnerTestDeps({
146+claudeCliSessionTranscriptHasContent: vi.fn(async () => true),
147+});
148+});
149+150+afterEach(async () => {
151+const { restoreCliRunnerTestDeps } = await import("./cli-runner.js");
152+restoreCliRunnerTestDeps();
143153});
144154145155it("finalizes successful CLI turns with the active context engine", async () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。