docs: document subagent spawn tests · openclaw/openclaw@a09594b
steipete
·
2026-06-05
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Subagent spawn depth-limit tests cover max depth, per-parent child limits, |
| 2 | +// inherited tool policy, and preflight failures before gateway dispatch. |
1 | 3 | import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; |
2 | 4 | import { |
3 | 5 | createSubagentSpawnTestConfig, |
@@ -120,6 +122,8 @@ describe("subagent spawn depth + child limits", () => {
|
120 | 122 | const accepted = expectAccepted(result, "run-1"); |
121 | 123 | expect(accepted.childSessionKey).toMatch(/^agent:main:subagent:/); |
122 | 124 | |
| 125 | +// Child capability flags are stored on the session entry so later control |
| 126 | +// tools can enforce leaf behavior without recalculating spawn depth. |
123 | 127 | const childSession = persistedStore?.[accepted.childSessionKey]; |
124 | 128 | if (!childSession) { |
125 | 129 | throw new Error("Expected persisted child session"); |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Subagent spawn session-mode diagnostic tests cover actionable errors when a |
| 2 | +// persistent child session cannot bind to a channel thread. |
1 | 3 | import os from "node:os"; |
2 | 4 | import { beforeEach, describe, expect, it, vi } from "vitest"; |
3 | 5 | import { |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Subagent spawn thread-binding tests cover child-session placement, target |
| 2 | +// account selection, and completion routing for channel thread spawns. |
1 | 3 | import os from "node:os"; |
2 | 4 | import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; |
3 | 5 | import { |
@@ -84,6 +86,8 @@ describe("spawnSubagentDirect thread binding delivery", () => {
|
84 | 86 | }); |
85 | 87 | |
86 | 88 | function installChannelRouteProjectionPluginsForTest() { |
| 89 | +// Matrix fixture projects a parent room plus child thread id into the |
| 90 | +// gateway delivery target shape used by thread-bound sessions. |
87 | 91 | const matrixBase = createChannelTestPluginBaseForTest({ id: "matrix", label: "Matrix" }); |
88 | 92 | setActivePluginRegistryForTest( |
89 | 93 | createTestRegistryForTest([ |
@@ -160,6 +164,8 @@ describe("spawnSubagentDirect thread binding delivery", () => {
|
160 | 164 | }); |
161 | 165 | |
162 | 166 | it("passes the target agent's bound account to core thread binding", async () => { |
| 167 | +// Cross-agent spawns bind the target agent account, while requester origin |
| 168 | +// remains the caller account for completion reporting. |
163 | 169 | const boundRoom = "!room:example.org"; |
164 | 170 | const bindCalls: Array<Record<string, unknown>> = []; |
165 | 171 | currentSessionBindingService = { |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Subagent spawn workspace tests cover same-agent inheritance, cross-agent |
| 2 | +// workspace selection, sandboxed cwd rejection, and cleanup deletion calls. |
1 | 3 | import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; |
2 | 4 | import { |
3 | 5 | createSubagentSpawnTestConfig, |
@@ -111,6 +113,8 @@ function findLastSessionDeleteCall() {
|
111 | 113 | } |
112 | 114 | |
113 | 115 | async function expectAcceptedWorkspace(params: { agentId: string; expectedWorkspaceDir: string }) { |
| 116 | +// Registered run workspace is the canonical child workspace; gateway params |
| 117 | +// should not receive ad hoc workspace overrides for native subagent calls. |
114 | 118 | const result = await spawnSubagentDirect( |
115 | 119 | { |
116 | 120 | task: "inspect workspace", |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Tool filesystem policy tests cover how global and agent-specific tool |
| 2 | +// profiles decide workspace-only access and root expansion. |
1 | 3 | import { describe, expect, it } from "vitest"; |
2 | 4 | import type { OpenClawConfig } from "../config/config.js"; |
3 | 5 | import { |
@@ -65,6 +67,8 @@ describe("resolveEffectiveToolFsRootExpansionAllowed", () => {
|
65 | 67 | }); |
66 | 68 | |
67 | 69 | it("does not re-enable root expansion from tools.fs alone under messaging profile (#47487)", () => { |
| 70 | +// A messaging profile needs an explicit read opt-in; merely configuring |
| 71 | +// tools.fs should not widen filesystem reach. |
68 | 72 | const cfg: OpenClawConfig = { |
69 | 73 | tools: { |
70 | 74 | profile: "messaging", |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Tool image tests cover image payload sanitization before tool outputs are |
| 2 | +// returned to model-visible content blocks. |
1 | 3 | import { describe, expect, it } from "vitest"; |
2 | 4 | import { |
3 | 5 | createNoisyPngBuffer, |
@@ -116,6 +118,8 @@ describe("tool image sanitizing", () => {
|
116 | 118 | }); |
117 | 119 | |
118 | 120 | it("drops malformed image base64 payloads", async () => { |
| 121 | +// Invalid base64 is replaced with text so malformed payloads cannot smuggle |
| 122 | +// attributes or script-like text through image blocks. |
119 | 123 | const blocks = [ |
120 | 124 | { |
121 | 125 | type: "image" as const, |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。