
























@@ -7,6 +7,7 @@ vi.mock("../context-engine-capabilities.js", () => ({
77import type { OpenClawConfig } from "../../../config/config.js";
88import { addSession, resetProcessRegistryForTests } from "../../bash-process-registry.js";
99import { createProcessSessionFixture } from "../../bash-process-registry.test-helpers.js";
10+import { wrapPluginSystemContextSection } from "../../hook-system-context-boundary.js";
1011import { SYSTEM_PROMPT_CACHE_BOUNDARY } from "../../system-prompt-cache-boundary.js";
1112import { buildAgentSystemPrompt } from "../../system-prompt.js";
1213import { resolveBootstrapContextTargets } from "./attempt-bootstrap-routing.js";
@@ -88,6 +89,10 @@ function requireContentItem(
8889return requireRecord(content[index], `content item ${index}`);
8990}
909192+function wrappedPluginSystemContext(text: string): string {
93+return wrapPluginSystemContextSection(text) ?? "";
94+}
95+9196function expectSingleTextContent(
9297content: Array<{ type?: string; text?: string }> | unknown[],
9398textFragment: string,
@@ -715,8 +720,12 @@ describe("resolvePromptBuildHookResult", () => {
715720716721expect(result.prependContext).toBe("prompt context\n\nagent start context");
717722expect(result.appendContext).toBe("prompt append context\n\nagent start append context");
718-expect(result.prependSystemContext).toBe("prompt prepend\n\nagent start prepend");
719-expect(result.appendSystemContext).toBe("prompt append\n\nagent start append");
723+expect(result.prependSystemContext).toBe(
724+`${wrappedPluginSystemContext("prompt prepend")}\n\n${wrappedPluginSystemContext("agent start prepend")}`,
725+);
726+expect(result.appendSystemContext).toBe(
727+`${wrappedPluginSystemContext("prompt append")}\n\n${wrappedPluginSystemContext("agent start append")}`,
728+);
720729});
721730722731it("applies heartbeat prompt contributions only during heartbeat turns", async () => {
@@ -766,29 +775,33 @@ describe("composeSystemPromptWithHookContext", () => {
766775expect(
767776composeSystemPromptWithHookContext({
768777baseSystemPrompt: " base system ",
769-prependSystemContext: " prepend ",
770-appendSystemContext: " append ",
778+prependSystemContext: wrappedPluginSystemContext(" prepend "),
779+appendSystemContext: wrappedPluginSystemContext(" append "),
771780}),
772-).toBe("prepend\n\nbase system\n\nappend");
781+).toBe(
782+`${wrappedPluginSystemContext(" prepend")}\n\nbase system\n\n${wrappedPluginSystemContext(" append")}`,
783+);
773784});
774785775-it("normalizes hook system context line endings and trailing whitespace", () => {
786+it("normalizes hook system context block line endings and trailing whitespace", () => {
776787expect(
777788composeSystemPromptWithHookContext({
778789baseSystemPrompt: " base system ",
779-prependSystemContext: " prepend line \r\nsecond line\t\r\n",
780-appendSystemContext: " append \t\r\n",
790+prependSystemContext: wrappedPluginSystemContext(" prepend line \r\nsecond line\t\r\n"),
791+appendSystemContext: wrappedPluginSystemContext(" append \t\r\n"),
781792}),
782-).toBe("prepend line\nsecond line\n\nbase system\n\nappend");
793+).toBe(
794+`${wrappedPluginSystemContext(" prepend line\nsecond line")}\n\nbase system\n\n${wrappedPluginSystemContext(" append")}`,
795+);
783796});
784797785798it("avoids blank separators when base system prompt is empty", () => {
786799expect(
787800composeSystemPromptWithHookContext({
788801baseSystemPrompt: " ",
789-appendSystemContext: " append only ",
802+appendSystemContext: wrappedPluginSystemContext(" append only "),
790803}),
791-).toBe("append only");
804+).toBe(wrappedPluginSystemContext(" append only"));
792805});
793806794807it("keeps bootstrap truncation notices in the system prompt instead of the user prompt", () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。