From 7fa49f58ce120d2f4672841f7e1e908c0d76efba Mon Sep 17 00:00:00 2001 From: kumarabhirup Date: Tue, 3 Mar 2026 16:34:03 -0800 Subject: [PATCH] feat(cli): add ensureSubagentDefaults function to set default subagent configurations This commit introduces the ensureSubagentDefaults function, which sets various default configurations for subagents, including max concurrent agents, max spawn depth, and run timeout settings. The function is called during the bootstrap process to ensure these defaults are applied for the specified profile. --- src/cli/bootstrap-external.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/cli/bootstrap-external.ts b/src/cli/bootstrap-external.ts index 44e3baeeef7..08b16d5ac59 100644 --- a/src/cli/bootstrap-external.ts +++ b/src/cli/bootstrap-external.ts @@ -357,6 +357,25 @@ async function ensureDefaultWorkspacePath( }); } +async function ensureSubagentDefaults(openclawCommand: string, profile: string): Promise { + const settings: Array<[string, string]> = [ + ["agents.defaults.subagents.maxConcurrent", "8"], + ["agents.defaults.subagents.maxSpawnDepth", "2"], + ["agents.defaults.subagents.maxChildrenPerAgent", "10"], + ["agents.defaults.subagents.archiveAfterMinutes", "180"], + ["agents.defaults.subagents.runTimeoutSeconds", "0"], + ["tools.subagents.tools.deny", "[]"], + ]; + for (const [key, value] of settings) { + await runOpenClawOrThrow({ + openclawCommand, + args: ["--profile", profile, "config", "set", key, value], + timeoutMs: 10_000, + errorMessage: `Failed to set ${key}=${value}.`, + }); + } +} + async function probeForWebApp(port: number): Promise { const controller = new AbortController(); const timer = setTimeout(() => controller.abort(), 1_500); @@ -1355,6 +1374,8 @@ export async function bootstrapCommand( // the same gateway target on subsequent requests. await ensureGatewayPort(openclawCommand, profile, gatewayPort); + await ensureSubagentDefaults(openclawCommand, profile); + let gatewayProbe = await probeGateway(openclawCommand, profile, gatewayPort); let gatewayAutoFix: GatewayAutoFixResult | undefined; if (!gatewayProbe.ok) {