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

推荐订阅源

IT之家
IT之家
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
A
About on SuperTechFans
博客园 - 聂微东
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
B
Blog RSS Feed
U
Unit 42
Stack Overflow Blog
Stack Overflow Blog
Recent Announcements
Recent Announcements
雷峰网
雷峰网
罗磊的独立博客
Microsoft Security Blog
Microsoft Security Blog
Hugging Face - Blog
Hugging Face - Blog
L
LangChain Blog
人人都是产品经理
人人都是产品经理
The GitHub Blog
The GitHub Blog
F
Fortinet All Blogs
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
H
Help Net Security
P
Proofpoint News Feed
The Cloudflare Blog
D
Docker
大猫的无限游戏
大猫的无限游戏

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
test: tighten exec approval followup assertions · opencla...
steipete · 2026-05-10 · via Recent Commits to openclaw:main

@@ -19,6 +19,40 @@ afterEach(() => {

1919

vi.resetAllMocks();

2020

});

212122+

function requireRecord(value: unknown, label: string): Record<string, unknown> {

23+

if (!value || typeof value !== "object" || Array.isArray(value)) {

24+

throw new Error(`expected ${label}`);

25+

}

26+

return value as Record<string, unknown>;

27+

}

28+29+

function requireFirstMockCall(mock: unknown, label: string): unknown[] {

30+

const call = (mock as { mock?: { calls?: unknown[][] } }).mock?.calls?.[0];

31+

if (!call) {

32+

throw new Error(`expected ${label}`);

33+

}

34+

return call;

35+

}

36+37+

function expectGatewayAgentFollowup(expected: Record<string, unknown>) {

38+

const call = requireFirstMockCall(callGatewayTool, "callGatewayTool call");

39+

expect(call[0]).toBe("agent");

40+

requireRecord(call[1], "gateway tool context");

41+

const params = requireRecord(call[2], "gateway tool params");

42+

for (const [key, value] of Object.entries(expected)) {

43+

expect(params[key]).toBe(value);

44+

}

45+

expect(call[3]).toEqual({ expectFinal: true });

46+

}

47+48+

function expectDirectSend(expected: Record<string, unknown>) {

49+

const call = requireFirstMockCall(sendMessage, "sendMessage call");

50+

const params = requireRecord(call[0], "sendMessage params");

51+

for (const [key, value] of Object.entries(expected)) {

52+

expect(params[key]).toBe(value);

53+

}

54+

}

55+2256

describe("exec approval followup", () => {

2357

it("uses an explicit denial prompt when the command did not run", () => {

2458

const prompt = buildExecApprovalFollowupPrompt(

@@ -44,17 +78,12 @@ describe("exec approval followup", () => {

4478

resultText: "Exec completed: echo ok",

4579

});

468047-

expect(callGatewayTool).toHaveBeenCalledWith(

48-

"agent",

49-

expect.any(Object),

50-

expect.objectContaining({

51-

sessionKey: "agent:main:main",

52-

deliver: false,

53-

channel: undefined,

54-

to: undefined,

55-

}),

56-

{ expectFinal: true },

57-

);

81+

expectGatewayAgentFollowup({

82+

sessionKey: "agent:main:main",

83+

deliver: false,

84+

channel: undefined,

85+

to: undefined,

86+

});

5887

expect(sendMessage).not.toHaveBeenCalled();

5988

});

6089

@@ -91,21 +120,16 @@ describe("exec approval followup", () => {

91120

resultText: "slack exec approval smoke",

92121

});

9312294-

expect(callGatewayTool).toHaveBeenCalledWith(

95-

"agent",

96-

expect.any(Object),

97-

expect.objectContaining({

98-

sessionKey: target.sessionKey,

99-

deliver: true,

100-

bestEffortDeliver: true,

101-

channel: target.channel,

102-

to: target.to,

103-

accountId: target.accountId,

104-

threadId: target.threadId,

105-

idempotencyKey: `exec-approval-followup:req-${target.channel}`,

106-

}),

107-

{ expectFinal: true },

108-

);

123+

expectGatewayAgentFollowup({

124+

sessionKey: target.sessionKey,

125+

deliver: true,

126+

bestEffortDeliver: true,

127+

channel: target.channel,

128+

to: target.to,

129+

accountId: target.accountId,

130+

threadId: target.threadId,

131+

idempotencyKey: `exec-approval-followup:req-${target.channel}`,

132+

});

109133

expect(sendMessage).not.toHaveBeenCalled();

110134

});

111135

@@ -119,16 +143,14 @@ describe("exec approval followup", () => {

119143

resultText: "Exec finished (gateway id=req-no-session, session=sess_1, code 0)\nall good",

120144

});

121145122-

expect(sendMessage).toHaveBeenCalledWith(

123-

expect.objectContaining({

124-

channel: "discord",

125-

to: "123",

126-

accountId: "default",

127-

threadId: "456",

128-

content: "all good",

129-

idempotencyKey: "exec-approval-followup:req-no-session",

130-

}),

131-

);

146+

expectDirectSend({

147+

channel: "discord",

148+

to: "123",

149+

accountId: "default",

150+

threadId: "456",

151+

content: "all good",

152+

idempotencyKey: "exec-approval-followup:req-no-session",

153+

});

132154

expect(callGatewayTool).not.toHaveBeenCalled();

133155

});

134156

@@ -144,15 +166,13 @@ describe("exec approval followup", () => {

144166

direct: true,

145167

});

146168147-

expect(sendMessage).toHaveBeenCalledWith(

148-

expect.objectContaining({

149-

channel: "telegram",

150-

to: "123",

151-

accountId: "default",

152-

content: "pasteable diagnostics report",

153-

idempotencyKey: "exec-approval-followup:req-direct",

154-

}),

155-

);

169+

expectDirectSend({

170+

channel: "telegram",

171+

to: "123",

172+

accountId: "default",

173+

content: "pasteable diagnostics report",

174+

idempotencyKey: "exec-approval-followup:req-direct",

175+

});

156176

expect(callGatewayTool).not.toHaveBeenCalled();

157177

});

158178

@@ -170,12 +190,10 @@ describe("exec approval followup", () => {

170190

"Exec finished (gateway id=req-session-resume-failed, session=sess_1, code 0)\nall good",

171191

});

172192173-

expect(sendMessage).toHaveBeenCalledWith(

174-

expect.objectContaining({

175-

content: "all good",

176-

idempotencyKey: "exec-approval-followup:req-session-resume-failed",

177-

}),

178-

);

193+

expectDirectSend({

194+

content: "all good",

195+

idempotencyKey: "exec-approval-followup:req-session-resume-failed",

196+

});

179197

});

180198181199

it("uses a generic summary when a no-session completion has no user-visible output", async () => {

@@ -188,12 +206,10 @@ describe("exec approval followup", () => {

188206

resultText: "Exec finished (gateway id=req-no-session-empty, session=sess_2, code 0)",

189207

});

190208191-

expect(sendMessage).toHaveBeenCalledWith(

192-

expect.objectContaining({

193-

content: "Background command finished.",

194-

idempotencyKey: "exec-approval-followup:req-no-session-empty",

195-

}),

196-

);

209+

expectDirectSend({

210+

content: "Background command finished.",

211+

idempotencyKey: "exec-approval-followup:req-no-session-empty",

212+

});

197213

});

198214199215

it("uses safe denied copy when session resume fails", async () => {

@@ -209,13 +225,11 @@ describe("exec approval followup", () => {

209225

resultText: "Exec denied (gateway id=req-denied-resume-failed, approval-timeout): uname -a",

210226

});

211227212-

expect(sendMessage).toHaveBeenCalledWith(

213-

expect.objectContaining({

214-

content:

215-

"Automatic session resume failed, so sending the status directly.\n\nCommand did not run: approval timed out.",

216-

idempotencyKey: "exec-approval-followup:req-denied-resume-failed",

217-

}),

218-

);

228+

expectDirectSend({

229+

content:

230+

"Automatic session resume failed, so sending the status directly.\n\nCommand did not run: approval timed out.",

231+

idempotencyKey: "exec-approval-followup:req-denied-resume-failed",

232+

});

219233

});

220234221235

it("suppresses denied followups for subagent sessions", async () => {

@@ -261,16 +275,11 @@ describe("exec approval followup", () => {

261275

resultText: "Exec completed: systemctl status gateway",

262276

});

263277264-

expect(callGatewayTool).toHaveBeenCalledWith(

265-

"agent",

266-

expect.any(Object),

267-

expect.objectContaining({

268-

sessionKey: "agent:main:telegram:-100123",

269-

deliver: false,

270-

channel: "telegram",

271-

}),

272-

{ expectFinal: true },

273-

);

278+

expectGatewayAgentFollowup({

279+

sessionKey: "agent:main:telegram:-100123",

280+

deliver: false,

281+

channel: "telegram",

282+

});

274283

expect(sendMessage).not.toHaveBeenCalled();

275284

});

276285