惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
爱范儿
爱范儿
WordPress大学
WordPress大学
博客园 - 三生石上(FineUI控件)
J
Java Code Geeks
Vercel News
Vercel News
aimingoo的专栏
aimingoo的专栏
T
Tailwind CSS Blog
罗磊的独立博客
B
Blog
博客园_首页
A
About on SuperTechFans
有赞技术团队
有赞技术团队
V
V2EX
U
Unit 42
I
InfoQ
IT之家
IT之家
博客园 - 司徒正美
阮一峰的网络日志
阮一峰的网络日志
博客园 - 叶小钗
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Stack Overflow Blog
Stack Overflow Blog
The Cloudflare Blog
H
Help Net Security

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(agents): run heartbeat_prompt_contribution on harness...
azogheb · 2026-06-24 · via Recent Commits to openclaw:main
1-

import { afterEach, describe, expect, it } from "vitest";

2-

import { resetGlobalHookRunner } from "../../plugins/hook-runner-global.js";

1+

import { afterEach, describe, expect, it, vi } from "vitest";

2+

import {

3+

initializeGlobalHookRunner,

4+

resetGlobalHookRunner,

5+

} from "../../plugins/hook-runner-global.js";

6+

import { createMockPluginRegistry } from "../../plugins/hooks.test-helpers.js";

37

import { resolveAgentHarnessBeforePromptBuildResult } from "./prompt-compaction-hook-helpers.js";

4859

afterEach(() => {

@@ -63,4 +67,84 @@ describe("resolveAgentHarnessBeforePromptBuildResult", () => {

6367

promptInputRange: { start: 17, end: 17 },

6468

});

6569

});

70+71+

it("runs heartbeat_prompt_contribution on a heartbeat turn and prepends its contribution", async () => {

72+

initializeGlobalHookRunner(

73+

createMockPluginRegistry([

74+

{

75+

hookName: "heartbeat_prompt_contribution",

76+

handler: () => ({ prependContext: "Run the base-heartbeat skill." }),

77+

},

78+

]),

79+

);

80+81+

const result = await resolveAgentHarnessBeforePromptBuildResult({

82+

prompt: "Read HEARTBEAT.md.",

83+

developerInstructions: "base instructions",

84+

messages: [],

85+

ctx: { trigger: "heartbeat", agentId: "agent-1", sessionKey: "session-1" },

86+

});

87+88+

expect(result.prompt).toBe("Run the base-heartbeat skill.\n\nRead HEARTBEAT.md.");

89+

// The heartbeat contribution affects only the prompt, not developer instructions.

90+

expect(result.developerInstructions).toBe("base instructions");

91+

});

92+93+

it("runs heartbeat contributions before other prompt-build hooks", async () => {

94+

const calls: string[] = [];

95+

initializeGlobalHookRunner(

96+

createMockPluginRegistry([

97+

{

98+

hookName: "heartbeat_prompt_contribution",

99+

handler: () => {

100+

calls.push("heartbeat");

101+

return { prependContext: "heartbeat context" };

102+

},

103+

},

104+

{

105+

hookName: "before_prompt_build",

106+

handler: () => {

107+

calls.push("before_prompt_build");

108+

return { prependContext: "prompt context" };

109+

},

110+

},

111+

{

112+

hookName: "before_agent_start",

113+

handler: () => {

114+

calls.push("before_agent_start");

115+

return { prependContext: "agent-start context" };

116+

},

117+

},

118+

]),

119+

);

120+121+

const result = await resolveAgentHarnessBeforePromptBuildResult({

122+

prompt: "hello",

123+

developerInstructions: "base instructions",

124+

messages: [],

125+

ctx: { trigger: "heartbeat", agentId: "agent-1", sessionKey: "session-1" },

126+

});

127+128+

expect(calls).toEqual(["heartbeat", "before_prompt_build", "before_agent_start"]);

129+

expect(result.prompt).toBe(

130+

"heartbeat context\n\nprompt context\n\nagent-start context\n\nhello",

131+

);

132+

});

133+134+

it("skips heartbeat_prompt_contribution off a heartbeat turn", async () => {

135+

const handler = vi.fn(() => ({ prependContext: "should not appear" }));

136+

initializeGlobalHookRunner(

137+

createMockPluginRegistry([{ hookName: "heartbeat_prompt_contribution", handler }]),

138+

);

139+140+

const result = await resolveAgentHarnessBeforePromptBuildResult({

141+

prompt: "hello",

142+

developerInstructions: "base instructions",

143+

messages: [],

144+

ctx: { trigger: "user", agentId: "agent-1", sessionKey: "session-1" },

145+

});

146+147+

expect(handler).not.toHaveBeenCalled();

148+

expect(result.prompt).toBe("hello");

149+

});

66150

});