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

推荐订阅源

月光博客
月光博客
云风的 BLOG
云风的 BLOG
小众软件
小众软件
雷峰网
雷峰网
博客园 - 【当耐特】
V
V2EX
WordPress大学
WordPress大学
IT之家
IT之家
Last Week in AI
Last Week in AI
罗磊的独立博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Apple Machine Learning Research
Apple Machine Learning Research
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
V
Visual Studio Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
有赞技术团队
有赞技术团队
The Cloudflare Blog
Jina AI
Jina AI
博客园 - 司徒正美
阮一峰的网络日志
阮一峰的网络日志
博客园 - 聂微东
大猫的无限游戏
大猫的无限游戏
博客园 - 三生石上(FineUI控件)
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com

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
refactor(agents): remove stale subagent depth policy · op...
vincentkoc · 2026-06-18 · via Recent Commits to openclaw:main

@@ -15,7 +15,6 @@ import {

1515

resolveEffectiveToolPolicy,

1616

resolveGroupToolPolicy,

1717

resolveInheritedToolPolicyForSession,

18-

resolveSubagentToolPolicy,

1918

resolveSubagentToolPolicyForSession,

2019

resolveTrustedGroupId,

2120

} from "./agent-tools.policy.js";

@@ -188,156 +187,11 @@ describe("resolveGroupToolPolicy group context validation", () => {

188187

});

189188

});

190189191-

describe("resolveSubagentToolPolicy depth awareness", () => {

190+

describe("resolveSubagentToolPolicyForSession", () => {

192191

const baseCfg = {

193192

agents: { defaults: { subagents: { maxSpawnDepth: 2 } } },

194193

} as unknown as OpenClawConfig;

195194196-

const deepCfg = {

197-

agents: { defaults: { subagents: { maxSpawnDepth: 3 } } },

198-

} as unknown as OpenClawConfig;

199-200-

const leafCfg = {

201-

agents: { defaults: { subagents: { maxSpawnDepth: 1 } } },

202-

} as unknown as OpenClawConfig;

203-204-

it("applies subagent tools.alsoAllow to re-enable default-denied tools", () => {

205-

const cfg = {

206-

agents: { defaults: { subagents: { maxSpawnDepth: 2 } } },

207-

tools: { subagents: { tools: { alsoAllow: ["sessions_send"] } } },

208-

} as unknown as OpenClawConfig;

209-

const policy = resolveSubagentToolPolicy(cfg, 1);

210-

expect(isToolAllowedByPolicyName("sessions_send", policy)).toBe(true);

211-

expect(isToolAllowedByPolicyName("cron", policy)).toBe(false);

212-

});

213-214-

it("applies subagent tools.allow to re-enable default-denied tools", () => {

215-

const cfg = {

216-

agents: { defaults: { subagents: { maxSpawnDepth: 2 } } },

217-

tools: { subagents: { tools: { allow: ["sessions_send"] } } },

218-

} as unknown as OpenClawConfig;

219-

const policy = resolveSubagentToolPolicy(cfg, 1);

220-

expect(isToolAllowedByPolicyName("sessions_send", policy)).toBe(true);

221-

});

222-223-

it("merges subagent tools.alsoAllow into tools.allow when both are set", () => {

224-

const cfg = {

225-

agents: { defaults: { subagents: { maxSpawnDepth: 2 } } },

226-

tools: {

227-

subagents: { tools: { allow: ["sessions_spawn"], alsoAllow: ["sessions_send"] } },

228-

},

229-

} as unknown as OpenClawConfig;

230-

const policy = resolveSubagentToolPolicy(cfg, 1);

231-

expect(policy.allow).toEqual(["sessions_spawn", "sessions_send"]);

232-

});

233-234-

it("keeps configured deny precedence over allow and alsoAllow", () => {

235-

const cfg = {

236-

agents: { defaults: { subagents: { maxSpawnDepth: 2 } } },

237-

tools: {

238-

subagents: {

239-

tools: {

240-

allow: ["sessions_send"],

241-

alsoAllow: ["sessions_send"],

242-

deny: ["sessions_send"],

243-

},

244-

},

245-

},

246-

} as unknown as OpenClawConfig;

247-

const policy = resolveSubagentToolPolicy(cfg, 1);

248-

expect(isToolAllowedByPolicyName("sessions_send", policy)).toBe(false);

249-

});

250-251-

it("applies configured deny to memory tools even though they are allowed by default", () => {

252-

const cfg = {

253-

agents: { defaults: { subagents: { maxSpawnDepth: 2 } } },

254-

tools: {

255-

subagents: {

256-

tools: {

257-

deny: ["memory_search", "memory_get"],

258-

},

259-

},

260-

},

261-

} as unknown as OpenClawConfig;

262-

const policy = resolveSubagentToolPolicy(cfg, 1);

263-

expect(isToolAllowedByPolicyName("memory_search", policy)).toBe(false);

264-

expect(isToolAllowedByPolicyName("memory_get", policy)).toBe(false);

265-

});

266-267-

it("does not create a restrictive allowlist when only alsoAllow is configured", () => {

268-

const cfg = {

269-

agents: { defaults: { subagents: { maxSpawnDepth: 2 } } },

270-

tools: { subagents: { tools: { alsoAllow: ["sessions_send"] } } },

271-

} as unknown as OpenClawConfig;

272-

const policy = resolveSubagentToolPolicy(cfg, 1);

273-

expect(policy.allow).toBeUndefined();

274-

expect(isToolAllowedByPolicyName("subagents", policy)).toBe(true);

275-

});

276-277-

it("depth-1 orchestrator (maxSpawnDepth=2) allows sessions_spawn", () => {

278-

const policy = resolveSubagentToolPolicy(baseCfg, 1);

279-

expect(isToolAllowedByPolicyName("sessions_spawn", policy)).toBe(true);

280-

});

281-282-

it("depth-1 orchestrator (maxSpawnDepth=2) allows subagents", () => {

283-

const policy = resolveSubagentToolPolicy(baseCfg, 1);

284-

expect(isToolAllowedByPolicyName("subagents", policy)).toBe(true);

285-

});

286-287-

it("depth-1 orchestrator (maxSpawnDepth=2) allows sessions_list", () => {

288-

const policy = resolveSubagentToolPolicy(baseCfg, 1);

289-

expect(isToolAllowedByPolicyName("sessions_list", policy)).toBe(true);

290-

});

291-292-

it("depth-1 orchestrator (maxSpawnDepth=2) allows sessions_history", () => {

293-

const policy = resolveSubagentToolPolicy(baseCfg, 1);

294-

expect(isToolAllowedByPolicyName("sessions_history", policy)).toBe(true);

295-

});

296-297-

it("depth-1 orchestrator still denies gateway and cron but allows memory tools", () => {

298-

const policy = resolveSubagentToolPolicy(baseCfg, 1);

299-

expect(isToolAllowedByPolicyName("gateway", policy)).toBe(false);

300-

expect(isToolAllowedByPolicyName("cron", policy)).toBe(false);

301-

expect(isToolAllowedByPolicyName("memory_search", policy)).toBe(true);

302-

expect(isToolAllowedByPolicyName("memory_get", policy)).toBe(true);

303-

});

304-305-

it("depth-2 leaf denies sessions_spawn", () => {

306-

const policy = resolveSubagentToolPolicy(baseCfg, 2);

307-

expect(isToolAllowedByPolicyName("sessions_spawn", policy)).toBe(false);

308-

});

309-310-

it("depth-2 orchestrator (maxSpawnDepth=3) allows sessions_spawn", () => {

311-

const policy = resolveSubagentToolPolicy(deepCfg, 2);

312-

expect(isToolAllowedByPolicyName("sessions_spawn", policy)).toBe(true);

313-

});

314-315-

it("depth-3 leaf (maxSpawnDepth=3) denies sessions_spawn", () => {

316-

const policy = resolveSubagentToolPolicy(deepCfg, 3);

317-

expect(isToolAllowedByPolicyName("sessions_spawn", policy)).toBe(false);

318-

});

319-320-

it("depth-2 leaf denies subagents", () => {

321-

const policy = resolveSubagentToolPolicy(baseCfg, 2);

322-

expect(isToolAllowedByPolicyName("subagents", policy)).toBe(false);

323-

});

324-325-

it("depth-2 leaf denies sessions_list and sessions_history", () => {

326-

const policy = resolveSubagentToolPolicy(baseCfg, 2);

327-

expect(isToolAllowedByPolicyName("sessions_list", policy)).toBe(false);

328-

expect(isToolAllowedByPolicyName("sessions_history", policy)).toBe(false);

329-

});

330-331-

it("depth-1 leaf (maxSpawnDepth=1) denies sessions_spawn", () => {

332-

const policy = resolveSubagentToolPolicy(leafCfg, 1);

333-

expect(isToolAllowedByPolicyName("sessions_spawn", policy)).toBe(false);

334-

});

335-336-

it("depth-1 leaf (maxSpawnDepth=1) denies sessions_list", () => {

337-

const policy = resolveSubagentToolPolicy(leafCfg, 1);

338-

expect(isToolAllowedByPolicyName("sessions_list", policy)).toBe(false);

339-

});

340-341195

it("uses stored leaf role for flat depth-1 session keys", () => {

342196

const storePath = path.join(

343197

os.tmpdir(),

@@ -533,18 +387,6 @@ describe("resolveSubagentToolPolicy depth awareness", () => {

533387

expect(isToolAllowedByPolicyName("custom_denied_tool", policy)).toBe(false);

534388

expect(isToolAllowedByPolicyName("read", policy)).toBe(false);

535389

});

536-537-

it("defaults to leaf behavior when no depth is provided", () => {

538-

const policy = resolveSubagentToolPolicy(baseCfg);

539-

// Default depth=1, maxSpawnDepth=2 → orchestrator

540-

expect(isToolAllowedByPolicyName("sessions_spawn", policy)).toBe(true);

541-

});

542-543-

it("defaults to leaf behavior when depth is undefined and maxSpawnDepth is 1", () => {

544-

const policy = resolveSubagentToolPolicy(leafCfg);

545-

// Default depth=1, maxSpawnDepth=1 → leaf

546-

expect(isToolAllowedByPolicyName("sessions_spawn", policy)).toBe(false);

547-

});

548390

});

549391550392

describe("resolveEffectiveToolPolicy", () => {