




























@@ -5,6 +5,7 @@ import { CURRENT_SESSION_VERSION } from "@mariozechner/pi-coding-agent";
55import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
66import type { OpenClawConfig } from "../../config/types.openclaw.js";
77import { getGlobalHookRunner } from "../../plugins/hook-runner-global.js";
8+import { __testing as cliBackendsTesting } from "../cli-backends.js";
89import { buildActiveMusicGenerationTaskPromptContextForSession } from "../music-generation-task-status.js";
910import { buildActiveVideoGenerationTaskPromptContextForSession } from "../video-generation-task-status.js";
1011import {
@@ -51,10 +52,11 @@ const mockBuildActiveMusicGenerationTaskPromptContextForSession = vi.mocked(
5152buildActiveMusicGenerationTaskPromptContextForSession,
5253);
535454-function createCliBackendConfig(): OpenClawConfig {
55+function createCliBackendConfig(params: { systemPromptOverride?: string } = {}): OpenClawConfig {
5556return {
5657agents: {
5758defaults: {
59+systemPromptOverride: params.systemPromptOverride ?? "test system prompt",
5860cliBackends: {
5961"test-cli": {
6062command: "test-cli",
@@ -114,6 +116,10 @@ function appendTranscriptEntry(
114116115117describe("shouldSkipLocalCliCredentialEpoch", () => {
116118beforeEach(() => {
119+cliBackendsTesting.setDepsForTest({
120+resolvePluginSetupCliBackend: () => undefined,
121+resolveRuntimeCliBackends: () => [],
122+});
117123setCliRunnerPrepareTestDeps({
118124makeBootstrapWarn: vi.fn(() => () => undefined),
119125resolveBootstrapContextForRun: vi.fn(async () => ({
@@ -128,6 +134,7 @@ describe("shouldSkipLocalCliCredentialEpoch", () => {
128134});
129135130136afterEach(() => {
137+cliBackendsTesting.resetDepsForTest();
131138mockGetGlobalHookRunner.mockReset();
132139mockBuildActiveVideoGenerationTaskPromptContextForSession.mockReset();
133140mockBuildActiveMusicGenerationTaskPromptContextForSession.mockReset();
@@ -336,12 +343,11 @@ describe("shouldSkipLocalCliCredentialEpoch", () => {
336343model: "test-model",
337344timeoutMs: 1_000,
338345runId: "run-test-hook-failure",
339-extraSystemPrompt: "base extra system",
340-config: createCliBackendConfig(),
346+config: createCliBackendConfig({ systemPromptOverride: "base extra system" }),
341347});
342348343349expect(context.params.prompt).toBe("latest ask");
344-expect(context.systemPrompt).toContain("base extra system");
350+expect(context.systemPrompt).toBe("base extra system");
345351expect(context.systemPrompt).not.toContain("hook exploded");
346352expect(hookRunner.runBeforePromptBuild).toHaveBeenCalledOnce();
347353} finally {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。