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

推荐订阅源

A
About on SuperTechFans
G
Google Developers Blog
L
LangChain Blog
aimingoo的专栏
aimingoo的专栏
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
云风的 BLOG
云风的 BLOG
小众软件
小众软件
月光博客
月光博客
Recent Announcements
Recent Announcements
人人都是产品经理
人人都是产品经理
P
Proofpoint News Feed
博客园 - 聂微东
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
雷峰网
雷峰网
The Cloudflare Blog
博客园_首页
美团技术团队
大猫的无限游戏
大猫的无限游戏
B
Blog
IT之家
IT之家
Jina AI
Jina AI
H
Hackread – Cybersecurity News, Data Breaches, AI and More
C
Check Point 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: preserve restart continuations after reboot (#63406)...
VACInc · 2026-04-22 · via Recent Commits to openclaw:main

@@ -0,0 +1,144 @@

1+

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

2+

import type { RestartSentinelPayload } from "../../infra/restart-sentinel.js";

3+4+

const isRestartEnabledMock = vi.fn(() => true);

5+

const extractDeliveryInfoMock = vi.fn(() => ({

6+

deliveryContext: {

7+

channel: "slack",

8+

to: "slack:C123",

9+

accountId: "workspace-1",

10+

},

11+

threadId: "thread-42",

12+

}));

13+

const formatDoctorNonInteractiveHintMock = vi.fn(() => "Run: openclaw doctor --non-interactive");

14+

const writeRestartSentinelMock = vi.fn(async (_payload: RestartSentinelPayload) => "/tmp/restart");

15+

const scheduleGatewaySigusr1RestartMock = vi.fn(() => ({ scheduled: true, delayMs: 250 }));

16+17+

vi.mock("../../config/commands.js", () => ({

18+

isRestartEnabled: isRestartEnabledMock,

19+

}));

20+21+

vi.mock("../../config/sessions.js", () => ({

22+

extractDeliveryInfo: extractDeliveryInfoMock,

23+

}));

24+25+

vi.mock("../../infra/restart-sentinel.js", async () => {

26+

const actual = await vi.importActual<typeof import("../../infra/restart-sentinel.js")>(

27+

"../../infra/restart-sentinel.js",

28+

);

29+

return {

30+

...actual,

31+

formatDoctorNonInteractiveHint: formatDoctorNonInteractiveHintMock,

32+

writeRestartSentinel: writeRestartSentinelMock,

33+

};

34+

});

35+36+

vi.mock("../../infra/restart.js", () => ({

37+

scheduleGatewaySigusr1Restart: scheduleGatewaySigusr1RestartMock,

38+

}));

39+40+

vi.mock("../../logging/subsystem.js", () => ({

41+

createSubsystemLogger: vi.fn(() => ({

42+

info: vi.fn(),

43+

})),

44+

}));

45+46+

vi.mock("./gateway.js", () => ({

47+

callGatewayTool: vi.fn(),

48+

readGatewayCallOptions: vi.fn(() => ({})),

49+

}));

50+51+

describe("gateway tool restart continuation", () => {

52+

beforeEach(() => {

53+

isRestartEnabledMock.mockReset();

54+

isRestartEnabledMock.mockReturnValue(true);

55+

extractDeliveryInfoMock.mockReset();

56+

extractDeliveryInfoMock.mockReturnValue({

57+

deliveryContext: {

58+

channel: "slack",

59+

to: "slack:C123",

60+

accountId: "workspace-1",

61+

},

62+

threadId: "thread-42",

63+

});

64+

formatDoctorNonInteractiveHintMock.mockReset();

65+

formatDoctorNonInteractiveHintMock.mockReturnValue("Run: openclaw doctor --non-interactive");

66+

writeRestartSentinelMock.mockReset();

67+

writeRestartSentinelMock.mockResolvedValue("/tmp/restart");

68+

scheduleGatewaySigusr1RestartMock.mockReset();

69+

scheduleGatewaySigusr1RestartMock.mockReturnValue({ scheduled: true, delayMs: 250 });

70+

});

71+72+

it("uses a flat enum for continuationKind in the tool schema", async () => {

73+

const { createGatewayTool } = await import("./gateway-tool.js");

74+

const tool = createGatewayTool();

75+

const continuationKind = (

76+

tool.parameters as {

77+

properties?: {

78+

continuationKind?: {

79+

type?: string;

80+

enum?: string[];

81+

anyOf?: unknown[];

82+

};

83+

};

84+

}

85+

).properties?.continuationKind;

86+87+

expect(continuationKind).toEqual(

88+

expect.objectContaining({

89+

type: "string",

90+

enum: ["systemEvent", "agentTurn"],

91+

}),

92+

);

93+

expect(continuationKind).not.toHaveProperty("anyOf");

94+

});

95+96+

it("instructs agents to use continuationMessage when a restart still needs a reply", async () => {

97+

const { createGatewayTool } = await import("./gateway-tool.js");

98+

const tool = createGatewayTool();

99+100+

expect(tool.description).toContain("still owe the user a reply");

101+

expect(tool.description).toContain("continuationMessage");

102+

expect(tool.description).toContain("do not write restart sentinel files directly");

103+

});

104+105+

it("writes an agentTurn continuation into the restart sentinel", async () => {

106+

const { createGatewayTool } = await import("./gateway-tool.js");

107+

const tool = createGatewayTool({

108+

agentSessionKey: "agent:main:main",

109+

config: {},

110+

});

111+112+

const result = await tool.execute?.("tool-call-1", {

113+

action: "restart",

114+

delayMs: 250,

115+

reason: "continue after reboot",

116+

note: "Gateway restarting now",

117+

continuationMessage: "Reply with exactly: Yay! I did it!",

118+

});

119+120+

expect(writeRestartSentinelMock).toHaveBeenCalledWith(

121+

expect.objectContaining({

122+

kind: "restart",

123+

status: "ok",

124+

sessionKey: "agent:main:main",

125+

deliveryContext: {

126+

channel: "slack",

127+

to: "slack:C123",

128+

accountId: "workspace-1",

129+

},

130+

threadId: "thread-42",

131+

message: "Gateway restarting now",

132+

continuation: {

133+

kind: "agentTurn",

134+

message: "Reply with exactly: Yay! I did it!",

135+

},

136+

}),

137+

);

138+

expect(scheduleGatewaySigusr1RestartMock).toHaveBeenCalledWith({

139+

delayMs: 250,

140+

reason: "continue after reboot",

141+

});

142+

expect(result?.details).toEqual({ scheduled: true, delayMs: 250 });

143+

});

144+

});