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

推荐订阅源

N
Netflix TechBlog - Medium
I
InfoQ
Engineering at Meta
Engineering at Meta
Jina AI
Jina AI
Recent Announcements
Recent Announcements
T
The Blog of Author Tim Ferriss
P
Proofpoint News Feed
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
D
Docker
Microsoft Security Blog
Microsoft Security Blog
宝玉的分享
宝玉的分享
Last Week in AI
Last Week in AI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
GbyAI
GbyAI
博客园 - Franky
博客园 - 聂微东
Microsoft Azure Blog
Microsoft Azure Blog
博客园 - 叶小钗
酷 壳 – CoolShell
酷 壳 – CoolShell
B
Blog RSS Feed
WordPress大学
WordPress大学
MyScale Blog
MyScale 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(gateway): scope session data lookups by agent [AI] (#...
pgondhi987 · 2026-05-17 · via Recent Commits to openclaw:main

@@ -4,14 +4,20 @@ import { afterEach, describe, expect, it, vi } from "vitest";

44

import { filterMemorySearchHitsBySessionVisibility } from "./session-search-visibility.js";

55

import { asOpenClawConfig } from "./tools.test-helpers.js";

667-

const crossAgentStore = {

7+

type TestSessionEntry = {

8+

sessionId: string;

9+

updatedAt: number;

10+

sessionFile: string;

11+

};

12+13+

const crossAgentStore: Record<string, TestSessionEntry> = {

814

"agent:peer:only": {

915

sessionId: "w1",

1016

updatedAt: 1,

1117

sessionFile: "/tmp/sessions/w1.jsonl",

1218

},

1319

};

14-

let combinedSessionStore: typeof crossAgentStore | Record<string, never> = crossAgentStore;

20+

let combinedSessionStore: Record<string, TestSessionEntry> = crossAgentStore;

15211622

vi.mock("openclaw/plugin-sdk/session-transcript-hit", async (importOriginal) => {

1723

const actual =

@@ -100,10 +106,19 @@ describe("filterMemorySearchHitsBySessionVisibility", () => {

100106

hits,

101107

});

102108

expect(sessionTranscriptHit.loadCombinedSessionStoreForGateway).toHaveBeenCalledTimes(1);

103-

expect(sessionTranscriptHit.loadCombinedSessionStoreForGateway).toHaveBeenCalledWith(cfg);

109+

expect(sessionTranscriptHit.loadCombinedSessionStoreForGateway).toHaveBeenCalledWith(cfg, {

110+

agentId: "main",

111+

});

104112

});

105113106-

it("allows cross-agent session hits when visibility=all and agent-to-agent is enabled", async () => {

114+

it("keeps same-agent session hits when visibility=all and agent-to-agent is enabled", async () => {

115+

combinedSessionStore = {

116+

"agent:main:only": {

117+

sessionId: "w1",

118+

updatedAt: 1,

119+

sessionFile: "/tmp/sessions/w1.jsonl",

120+

},

121+

};

107122

const hit: MemorySearchResult = {

108123

path: "sessions/w1.jsonl",

109124

source: "sessions",

@@ -127,6 +142,120 @@ describe("filterMemorySearchHitsBySessionVisibility", () => {

127142

expect(filtered).toEqual([hit]);

128143

});

129144145+

it("keeps global-scope session hits for non-default agents", async () => {

146+

combinedSessionStore = {

147+

global: {

148+

sessionId: "w1",

149+

updatedAt: 1,

150+

sessionFile: "/tmp/sessions/w1.jsonl",

151+

},

152+

};

153+

const hit: MemorySearchResult = {

154+

path: "sessions/w1.jsonl",

155+

source: "sessions",

156+

score: 1,

157+

snippet: "x",

158+

startLine: 1,

159+

endLine: 2,

160+

};

161+

const cfg = asOpenClawConfig({

162+

session: { scope: "global" },

163+

tools: {

164+

sessions: { visibility: "all" },

165+

agentToAgent: { enabled: true, allow: ["*"] },

166+

},

167+

});

168+

const filtered = await filterMemorySearchHitsBySessionVisibility({

169+

cfg,

170+

agentId: "secondary",

171+

requesterSessionKey: "agent:secondary:main",

172+

sandboxed: false,

173+

hits: [hit],

174+

});

175+

expect(filtered).toEqual([hit]);

176+

});

177+178+

it("does not keep cross-agent session hits outside the scoped store", async () => {

179+

combinedSessionStore = {};

180+

const hit: MemorySearchResult = {

181+

path: "sessions/w1.jsonl",

182+

source: "sessions",

183+

score: 1,

184+

snippet: "x",

185+

startLine: 1,

186+

endLine: 2,

187+

};

188+

const cfg = asOpenClawConfig({

189+

tools: {

190+

sessions: { visibility: "all" },

191+

agentToAgent: { enabled: true, allow: ["*"] },

192+

},

193+

});

194+

const filtered = await filterMemorySearchHitsBySessionVisibility({

195+

cfg,

196+

requesterSessionKey: "agent:main:main",

197+

sandboxed: false,

198+

hits: [hit],

199+

});

200+

expect(filtered).toStrictEqual([]);

201+

});

202+203+

it("does not keep cross-agent session hits when a shared store returns out-of-scope keys", async () => {

204+

combinedSessionStore = crossAgentStore;

205+

const hit: MemorySearchResult = {

206+

path: "sessions/w1.jsonl",

207+

source: "sessions",

208+

score: 1,

209+

snippet: "x",

210+

startLine: 1,

211+

endLine: 2,

212+

};

213+

const cfg = asOpenClawConfig({

214+

tools: {

215+

sessions: { visibility: "all" },

216+

agentToAgent: { enabled: true, allow: ["*"] },

217+

},

218+

});

219+

const filtered = await filterMemorySearchHitsBySessionVisibility({

220+

cfg,

221+

requesterSessionKey: "agent:main:main",

222+

sandboxed: false,

223+

hits: [hit],

224+

});

225+

expect(filtered).toStrictEqual([]);

226+

});

227+228+

it("does not keep owner-qualified cross-agent hits that collide with a scoped stem", async () => {

229+

combinedSessionStore = {

230+

"agent:main:main": {

231+

sessionId: "main",

232+

updatedAt: 1,

233+

sessionFile: "/tmp/sessions/main.jsonl",

234+

},

235+

};

236+

const hit: MemorySearchResult = {

237+

path: "sessions/peer/main.jsonl",

238+

source: "sessions",

239+

score: 1,

240+

snippet: "x",

241+

startLine: 1,

242+

endLine: 2,

243+

};

244+

const cfg = asOpenClawConfig({

245+

tools: {

246+

sessions: { visibility: "all" },

247+

agentToAgent: { enabled: true, allow: ["*"] },

248+

},

249+

});

250+

const filtered = await filterMemorySearchHitsBySessionVisibility({

251+

cfg,

252+

requesterSessionKey: "agent:main:main",

253+

sandboxed: false,

254+

hits: [hit],

255+

});

256+

expect(filtered).toStrictEqual([]);

257+

});

258+130259

it("denies cross-agent session hits when agent-to-agent is disabled", async () => {

131260

const hit: MemorySearchResult = {

132261

path: "sessions/w1.jsonl",

@@ -203,4 +332,31 @@ describe("filterMemorySearchHitsBySessionVisibility", () => {

203332204333

expect(filtered).toStrictEqual([]);

205334

});

335+336+

it("does not keep cross-agent deleted archive hits outside the scoped store when a2a is allowed", async () => {

337+

combinedSessionStore = {};

338+

const hit: MemorySearchResult = {

339+

path: "sessions/peer/deleted-stem.jsonl.deleted.2026-02-16T22-27-33.000Z",

340+

source: "sessions",

341+

score: 1,

342+

snippet: "x",

343+

startLine: 1,

344+

endLine: 2,

345+

};

346+

const cfg = asOpenClawConfig({

347+

tools: {

348+

sessions: { visibility: "all" },

349+

agentToAgent: { enabled: true, allow: ["*"] },

350+

},

351+

});

352+353+

const filtered = await filterMemorySearchHitsBySessionVisibility({

354+

cfg,

355+

requesterSessionKey: "agent:main:main",

356+

sandboxed: false,

357+

hits: [hit],

358+

});

359+360+

expect(filtered).toStrictEqual([]);

361+

});

206362

});