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

推荐订阅源

GbyAI
GbyAI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 叶小钗
大猫的无限游戏
大猫的无限游戏
H
Help Net Security
G
Google Developers Blog
D
Docker
阮一峰的网络日志
阮一峰的网络日志
A
About on SuperTechFans
aimingoo的专栏
aimingoo的专栏
博客园 - 聂微东
Hugging Face - Blog
Hugging Face - Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
Apple Machine Learning Research
Apple Machine Learning Research
云风的 BLOG
云风的 BLOG
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
腾讯CDC
T
The Blog of Author Tim Ferriss
Microsoft Security Blog
Microsoft Security Blog
WordPress大学
WordPress大学
I
InfoQ
Engineering at Meta
Engineering at Meta
Stack Overflow Blog
Stack Overflow Blog
Google DeepMind News
Google DeepMind News

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 subagent context assertions · openclaw/open...
steipete · 2026-05-10 · via Recent Commits to openclaw:main

@@ -49,6 +49,48 @@ describe("sessions_spawn context modes", () => {

4949

});

5050

}

515152+

function requireAcceptedResult(result: Awaited<ReturnType<typeof spawnSubagentDirect>>) {

53+

expect(result.status).toBe("accepted");

54+

if (result.status !== "accepted") {

55+

throw new Error(`expected accepted result, got ${result.status}`);

56+

}

57+

return result;

58+

}

59+60+

function requireStoreEntry(store: SessionStore, key: string): Record<string, unknown> {

61+

const entry = store[key];

62+

if (!entry) {

63+

throw new Error(`expected session store entry ${key}`);

64+

}

65+

return entry;

66+

}

67+68+

function requireChildSessionKey(result: Awaited<ReturnType<typeof spawnSubagentDirect>>): string {

69+

const key = result.childSessionKey;

70+

if (!key) {

71+

throw new Error("expected child session key");

72+

}

73+

return key;

74+

}

75+76+

function requireFirstMockArg(mock: ReturnType<typeof vi.fn>): Record<string, unknown> {

77+

const arg = mock.mock.calls.at(0)?.[0];

78+

if (!arg || typeof arg !== "object") {

79+

throw new Error("expected first mock argument object");

80+

}

81+

return arg as Record<string, unknown>;

82+

}

83+84+

function requireGatewayRequest(method: string): GatewayRequest {

85+

const request = callGatewayMock.mock.calls

86+

.map(([arg]) => arg as GatewayRequest)

87+

.find((candidate) => candidate.method === method);

88+

if (!request) {

89+

throw new Error(`expected gateway request ${method}`);

90+

}

91+

return request;

92+

}

93+5294

it("forks the requester transcript when context=fork", async () => {

5395

const store: SessionStore = {

5496

main: {

@@ -71,27 +113,26 @@ describe("sessions_spawn context modes", () => {

71113

{ agentSessionKey: "main" },

72114

);

7311574-

expect(result).toMatchObject({ status: "accepted", runId: "run-1" });

116+

const accepted = requireAcceptedResult(result);

117+

expect(accepted.runId).toBe("run-1");

75118

expect(forkSessionFromParentMock).toHaveBeenCalledWith({

76119

parentEntry: store.main,

77120

agentId: "main",

78121

sessionsDir: path.dirname(storePath),

79122

});

80-

expect(store[result.childSessionKey ?? ""]).toMatchObject({

81-

sessionId: "forked-session-id",

82-

sessionFile: "/tmp/forked-session.jsonl",

83-

forkedFromParent: true,

84-

});

85-

expect(prepareSubagentSpawn).toHaveBeenCalledWith(

86-

expect.objectContaining({

87-

parentSessionKey: "main",

88-

childSessionKey: result.childSessionKey,

89-

contextMode: "fork",

90-

parentSessionId: "parent-session-id",

91-

childSessionId: "forked-session-id",

92-

childSessionFile: "/tmp/forked-session.jsonl",

93-

}),

94-

);

123+

const childSessionKey = requireChildSessionKey(accepted);

124+

const childEntry = requireStoreEntry(store, childSessionKey);

125+

expect(childEntry.sessionId).toBe("forked-session-id");

126+

expect(childEntry.sessionFile).toBe("/tmp/forked-session.jsonl");

127+

expect(childEntry.forkedFromParent).toBe(true);

128+129+

const prepareContext = requireFirstMockArg(prepareSubagentSpawn);

130+

expect(prepareContext.parentSessionKey).toBe("main");

131+

expect(prepareContext.childSessionKey).toBe(childSessionKey);

132+

expect(prepareContext.contextMode).toBe("fork");

133+

expect(prepareContext.parentSessionId).toBe("parent-session-id");

134+

expect(prepareContext.childSessionId).toBe("forked-session-id");

135+

expect(prepareContext.childSessionFile).toBe("/tmp/forked-session.jsonl");

95136

});

9613797138

it("keeps the default spawn context isolated", async () => {

@@ -106,13 +147,10 @@ describe("sessions_spawn context modes", () => {

106147107148

expect(result.status).toBe("accepted");

108149

expect(forkSessionFromParentMock).not.toHaveBeenCalled();

109-

expect(prepareSubagentSpawn).toHaveBeenCalledWith(

110-

expect.objectContaining({

111-

parentSessionKey: "main",

112-

childSessionKey: result.childSessionKey,

113-

contextMode: "isolated",

114-

}),

115-

);

150+

const prepareContext = requireFirstMockArg(prepareSubagentSpawn);

151+

expect(prepareContext.parentSessionKey).toBe("main");

152+

expect(prepareContext.childSessionKey).toBe(requireChildSessionKey(result));

153+

expect(prepareContext.contextMode).toBe("isolated");

116154

});

117155118156

it("falls back to isolated context when requested fork is too large", async () => {

@@ -133,17 +171,15 @@ describe("sessions_spawn context modes", () => {

133171

{ agentSessionKey: "main" },

134172

);

135173136-

expect(result).toMatchObject({ status: "accepted", runId: "run-1" });

137-

expect(result.note).toContain("Parent context is too large to fork");

174+

const accepted = requireAcceptedResult(result);

175+

expect(accepted.runId).toBe("run-1");

176+

expect(accepted.note).toContain("Parent context is too large to fork");

138177

expect(forkSessionFromParentMock).not.toHaveBeenCalled();

139-

expect(prepareSubagentSpawn).toHaveBeenCalledWith(

140-

expect.objectContaining({

141-

parentSessionKey: "main",

142-

childSessionKey: result.childSessionKey,

143-

contextMode: "isolated",

144-

parentSessionId: "parent-session-id",

145-

}),

146-

);

178+

const prepareContext = requireFirstMockArg(prepareSubagentSpawn);

179+

expect(prepareContext.parentSessionKey).toBe("main");

180+

expect(prepareContext.childSessionKey).toBe(requireChildSessionKey(accepted));

181+

expect(prepareContext.contextMode).toBe("isolated");

182+

expect(prepareContext.parentSessionId).toBe("parent-session-id");

147183

});

148184149185

it("forks by default for thread-bound subagent sessions", async () => {

@@ -179,16 +215,10 @@ describe("sessions_spawn context modes", () => {

179215

agentId: "main",

180216

sessionsDir: path.dirname(storePath),

181217

});

182-

expect(callGatewayMock).toHaveBeenCalledWith(

183-

expect.objectContaining({

184-

method: "sessions.delete",

185-

params: expect.objectContaining({

186-

key: result.childSessionKey,

187-

deleteTranscript: true,

188-

emitLifecycleHooks: false,

189-

}),

190-

}),

191-

);

218+

const cleanupRequest = requireGatewayRequest("sessions.delete");

219+

expect(cleanupRequest.params?.key).toBe(result.childSessionKey);

220+

expect(cleanupRequest.params?.deleteTranscript).toBe(true);

221+

expect(cleanupRequest.params?.emitLifecycleHooks).toBe(false);

192222

expect(prepareSubagentSpawn).not.toHaveBeenCalled();

193223

});

194224

@@ -234,7 +264,8 @@ describe("sessions_spawn context modes", () => {

234264235265

const result = await spawnSubagentDirect({ task: "clean worker" }, { agentSessionKey: "main" });

236266237-

expect(result).toMatchObject({ status: "error", error: "agent start failed" });

267+

expect(result.status).toBe("error");

268+

expect(result.error).toBe("agent start failed");

238269

expect(rollback).toHaveBeenCalledTimes(1);

239270

expect(callGatewayMock.mock.calls.map((call) => (call[0] as GatewayRequest).method)).toContain(

240271

"sessions.delete",