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

推荐订阅源

有赞技术团队
有赞技术团队
美团技术团队
博客园 - 司徒正美
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
阮一峰的网络日志
阮一峰的网络日志
S
SegmentFault 最新的问题
博客园_首页
雷峰网
雷峰网
V
V2EX
The Cloudflare Blog
博客园 - 三生石上(FineUI控件)
量子位
Last Week in AI
Last Week in AI
人人都是产品经理
人人都是产品经理
爱范儿
爱范儿
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 聂微东
V
Visual Studio Blog
Hugging Face - Blog
Hugging Face - Blog
博客园 - 【当耐特】
Jina AI
Jina AI
月光博客
月光博客
L
LangChain Blog

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(heartbeat): multi-agent cadence — parallel broadcast,...
zeroaltitude · 2026-05-13 · via Recent Commits to openclaw:main

@@ -0,0 +1,147 @@

1+

import fs from "node:fs";

2+

import os from "node:os";

3+

import path from "node:path";

4+

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

5+

import { resolveStorePath } from "../config/sessions/paths.js";

6+

import type { OpenClawConfig } from "../config/types.openclaw.js";

7+

import { describeHeartbeatSessionTargetIssues } from "./doctor-heartbeat-session-target.js";

8+9+

describe("describeHeartbeatSessionTargetIssues", () => {

10+

let tmpDir: string;

11+12+

beforeEach(() => {

13+

tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-heartbeat-doctor-"));

14+

});

15+16+

afterEach(() => {

17+

fs.rmSync(tmpDir, { recursive: true, force: true });

18+

});

19+20+

function cfgWithSession(session: string, target: string | null = "slack"): OpenClawConfig {

21+

const heartbeat = target === null ? { session } : { session, target };

22+

return {

23+

session: {

24+

mainKey: "work",

25+

store: path.join(tmpDir, "agents", "{agentId}", "sessions", "sessions.json"),

26+

},

27+

agents: {

28+

list: [

29+

{

30+

id: "ops",

31+

heartbeat,

32+

},

33+

],

34+

},

35+

} as OpenClawConfig;

36+

}

37+38+

function cfgWithDefaultHeartbeat(

39+

session: string,

40+

target: string | null = "slack",

41+

): OpenClawConfig {

42+

const heartbeat = target === null ? { session } : { session, target };

43+

return {

44+

session: {

45+

mainKey: "work",

46+

store: path.join(tmpDir, "agents", "{agentId}", "sessions", "sessions.json"),

47+

},

48+

agents: {

49+

defaults: {

50+

heartbeat,

51+

},

52+

list: [

53+

{

54+

id: "ops",

55+

},

56+

],

57+

},

58+

} as OpenClawConfig;

59+

}

60+61+

function writeStore(cfg: OpenClawConfig, entries: Record<string, unknown>) {

62+

const storePath = resolveStorePath(cfg.session?.store, { agentId: "ops" });

63+

fs.mkdirSync(path.dirname(storePath), { recursive: true });

64+

fs.writeFileSync(storePath, JSON.stringify(entries, null, 2));

65+

}

66+67+

it("uses runtime session canonicalization before warning", () => {

68+

const cfg = cfgWithSession("agent:ops:main");

69+

writeStore(cfg, {

70+

"agent:ops:work": {

71+

sessionId: "agent:ops:work",

72+

updatedAt: Date.now(),

73+

},

74+

});

75+76+

expect(describeHeartbeatSessionTargetIssues(cfg)).toEqual([]);

77+

});

78+79+

it("warns when the resolved heartbeat session is missing", () => {

80+

const cfg = cfgWithSession("slack:channel:c123");

81+

writeStore(cfg, {});

82+83+

const warnings = describeHeartbeatSessionTargetIssues(cfg);

84+85+

expect(warnings).toHaveLength(1);

86+

expect(warnings[0]).toContain("resolved to agent:ops:slack:channel:c123");

87+

expect(warnings[0]).toContain('reason="no-target"');

88+

});

89+90+

it("does not warn when an explicit heartbeat recipient does not need session history", () => {

91+

const cfg = cfgWithSession("slack:channel:c123");

92+

const agent = cfg.agents?.list?.[0];

93+

if (!agent?.heartbeat) {

94+

throw new Error("expected test config to include heartbeat config");

95+

}

96+

agent.heartbeat.target = "telegram";

97+

agent.heartbeat.to = "-100123";

98+

writeStore(cfg, {});

99+100+

expect(describeHeartbeatSessionTargetIssues(cfg)).toEqual([]);

101+

});

102+103+

it("does not warn when the heartbeat cadence is disabled", () => {

104+

const cfg = cfgWithSession("slack:channel:c123");

105+

const agent = cfg.agents?.list?.[0];

106+

if (!agent?.heartbeat) {

107+

throw new Error("expected test config to include heartbeat config");

108+

}

109+

agent.heartbeat.every = "0m";

110+

writeStore(cfg, {});

111+112+

expect(describeHeartbeatSessionTargetIssues(cfg)).toEqual([]);

113+

});

114+115+

it("warns when a default-only heartbeat session is missing", () => {

116+

const cfg = cfgWithDefaultHeartbeat("slack:channel:c123");

117+

writeStore(cfg, {});

118+119+

const warnings = describeHeartbeatSessionTargetIssues(cfg);

120+121+

expect(warnings).toHaveLength(1);

122+

expect(warnings[0]).toContain("Agent ops heartbeat.session pins slack:channel:c123");

123+

expect(warnings[0]).toContain("resolved to agent:ops:slack:channel:c123");

124+

});

125+126+

it("warns when an explicit heartbeat inherits a default session", () => {

127+

const cfg = cfgWithDefaultHeartbeat("slack:channel:c123");

128+

const agent = cfg.agents?.list?.[0];

129+

if (!agent) {

130+

throw new Error("expected test config to include an agent");

131+

}

132+

agent.heartbeat = {};

133+

writeStore(cfg, {});

134+135+

const warnings = describeHeartbeatSessionTargetIssues(cfg);

136+137+

expect(warnings).toHaveLength(1);

138+

expect(warnings[0]).toContain("resolved to agent:ops:slack:channel:c123");

139+

});

140+141+

it("does not warn when target is omitted because runtime defaults to none", () => {

142+

const cfg = cfgWithSession("slack:channel:c123", null);

143+

writeStore(cfg, {});

144+145+

expect(describeHeartbeatSessionTargetIssues(cfg)).toEqual([]);

146+

});

147+

});