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

推荐订阅源

奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Blog — PlanetScale
Blog — PlanetScale
小众软件
小众软件
F
Fortinet All Blogs
博客园 - 叶小钗
博客园_首页
D
DataBreaches.Net
Apple Machine Learning Research
Apple Machine Learning Research
U
Unit 42
爱范儿
爱范儿
aimingoo的专栏
aimingoo的专栏
博客园 - Franky
Martin Fowler
Martin Fowler
酷 壳 – CoolShell
酷 壳 – CoolShell
The Cloudflare Blog
A
About on SuperTechFans
Google DeepMind News
Google DeepMind News
Microsoft Security Blog
Microsoft Security Blog
IT之家
IT之家
M
MIT News - Artificial intelligence
有赞技术团队
有赞技术团队
博客园 - 【当耐特】
S
SegmentFault 最新的问题
Hugging Face - Blog
Hugging Face - 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: retire idle bundled MCP runtimes · openclaw/openclaw...
steipete · 2026-04-25 · via Recent Commits to openclaw:main

@@ -26,13 +26,19 @@ function makeRuntime(

2626

tools: Array<{ toolName: string; description: string }>,

2727

serverName = "bundleProbe",

2828

): SessionMcpRuntime {

29+

const createdAt = Date.now();

30+

let lastUsedAt = createdAt;

2931

return {

3032

sessionId: "session-colliding-tools",

3133

workspaceDir: "/tmp",

3234

configFingerprint: "fingerprint",

33-

createdAt: 0,

34-

lastUsedAt: 0,

35-

markUsed: () => {},

35+

createdAt,

36+

get lastUsedAt() {

37+

return lastUsedAt;

38+

},

39+

markUsed: () => {

40+

lastUsedAt = Date.now();

41+

},

3642

getCatalog: async () => ({

3743

version: 1,

3844

generatedAt: 0,

@@ -135,6 +141,27 @@ describe("session MCP runtime", () => {

135141

]);

136142

});

137143144+

it("holds a runtime lease until the materialized tool runtime is disposed", async () => {

145+

let activeLeases = 0;

146+

const runtime = {

147+

...makeRuntime([{ toolName: "bundle_probe", description: "Bundle MCP probe" }]),

148+

acquireLease: () => {

149+

activeLeases += 1;

150+

return () => {

151+

activeLeases -= 1;

152+

};

153+

},

154+

};

155+156+

const materialized = await materializeBundleMcpToolsForRun({ runtime });

157+

expect(activeLeases).toBe(1);

158+159+

await materialized.dispose();

160+

await materialized.dispose();

161+162+

expect(activeLeases).toBe(0);

163+

});

164+138165

it("reuses repeated materialization and recreates after explicit disposal", async () => {

139166

const created: SessionMcpRuntime[] = [];

140167

const disposed: string[] = [];

@@ -361,4 +388,94 @@ describe("session MCP runtime", () => {

361388

retireSessionMcpRuntimeForSessionKey({ sessionKey: "agent:test:missing", reason: "test" }),

362389

).resolves.toBe(false);

363390

});

391+392+

it("evicts idle runtimes after the configured TTL but skips active leases", async () => {

393+

let now = 1_000;

394+

const disposed: string[] = [];

395+

const createRuntime: RuntimeFactory = (params) => {

396+

let lastUsedAt = now;

397+

let activeLeases = 0;

398+

return {

399+

...makeRuntime([{ toolName: "bundle_probe", description: "Bundle MCP probe" }]),

400+

sessionId: params.sessionId,

401+

sessionKey: params.sessionKey,

402+

workspaceDir: params.workspaceDir,

403+

configFingerprint: params.configFingerprint ?? "fingerprint",

404+

get lastUsedAt() {

405+

return lastUsedAt;

406+

},

407+

get activeLeases() {

408+

return activeLeases;

409+

},

410+

markUsed: () => {

411+

lastUsedAt = now;

412+

},

413+

acquireLease: () => {

414+

activeLeases += 1;

415+

return () => {

416+

activeLeases -= 1;

417+

lastUsedAt = now;

418+

};

419+

},

420+

dispose: async () => {

421+

disposed.push(params.sessionId);

422+

},

423+

};

424+

};

425+

const manager = __testing.createSessionMcpRuntimeManager({

426+

createRuntime,

427+

now: () => now,

428+

enableIdleSweepTimer: false,

429+

});

430+431+

const runtime = await manager.getOrCreate({

432+

sessionId: "session-idle",

433+

sessionKey: "agent:test:session-idle",

434+

workspaceDir: "/workspace",

435+

cfg: { mcp: { servers: {}, sessionIdleTtlMs: 50 } },

436+

});

437+

const releaseLease = runtime.acquireLease?.();

438+439+

now += 60;

440+

await expect(manager.sweepIdleRuntimes()).resolves.toBe(0);

441+

expect(manager.listSessionIds()).toEqual(["session-idle"]);

442+443+

releaseLease?.();

444+

now += 60;

445+

await expect(manager.sweepIdleRuntimes()).resolves.toBe(1);

446+447+

expect(disposed).toEqual(["session-idle"]);

448+

expect(manager.listSessionIds()).toEqual([]);

449+

expect(manager.resolveSessionId("agent:test:session-idle")).toBeUndefined();

450+

});

451+452+

it("keeps idle runtime eviction disabled when the TTL is zero", async () => {

453+

let now = 1_000;

454+

const disposed: string[] = [];

455+

const manager = __testing.createSessionMcpRuntimeManager({

456+

createRuntime: (params) => ({

457+

...makeRuntime([{ toolName: "bundle_probe", description: "Bundle MCP probe" }]),

458+

sessionId: params.sessionId,

459+

sessionKey: params.sessionKey,

460+

workspaceDir: params.workspaceDir,

461+

configFingerprint: params.configFingerprint ?? "fingerprint",

462+

dispose: async () => {

463+

disposed.push(params.sessionId);

464+

},

465+

}),

466+

now: () => now,

467+

enableIdleSweepTimer: false,

468+

});

469+470+

await manager.getOrCreate({

471+

sessionId: "session-no-ttl",

472+

workspaceDir: "/workspace",

473+

cfg: { mcp: { servers: {}, sessionIdleTtlMs: 0 } },

474+

});

475+476+

now += 60_000_000;

477+

await expect(manager.sweepIdleRuntimes()).resolves.toBe(0);

478+

expect(manager.listSessionIds()).toEqual(["session-no-ttl"]);

479+

expect(disposed).toEqual([]);

480+

});

364481

});