From ea8a3d935474bd96de47d93e8b007574bb581d7d Mon Sep 17 00:00:00 2001 From: Copilot <223556219+Copilot@users.noreply.github.com> Date: Fri, 15 May 2026 05:34:01 +0200 Subject: [PATCH] feat(swarm): default SF_AUTONOMOUS_VIA_SWARM on in headless mode The swarm dispatch path is now automatically enabled when SF_HEADLESS=1 without requiring the operator to set SF_AUTONOMOUS_VIA_SWARM=1. This makes headless mode use the swarm execution engine by default, which is the intended architecture for autonomous execution. - Explicit SF_AUTONOMOUS_VIA_SWARM=1/true still works. - Explicit SF_AUTONOMOUS_VIA_SWARM=0/false disables it even in headless. - When unset + SF_HEADLESS=1, swarm is used. - When unset + SF_HEADLESS!=1, legacy path is used (unchanged). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- src/resources/extensions/sf/auto/run-unit.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/resources/extensions/sf/auto/run-unit.js b/src/resources/extensions/sf/auto/run-unit.js index 7ece6f987..a67ac6e21 100644 --- a/src/resources/extensions/sf/auto/run-unit.js +++ b/src/resources/extensions/sf/auto/run-unit.js @@ -509,11 +509,13 @@ async function runUnitViaSwarm(ctx, _pi, s, unitType, unitId, prompt, options) { * Default: false (each new unit starts with a clean session). */ export async function runUnit(ctx, pi, s, unitType, unitId, prompt, options) { - // Feature-flagged swarm path — no-op when unset so default behavior is unchanged. - if ( - process.env.SF_AUTONOMOUS_VIA_SWARM === "1" || - process.env.SF_AUTONOMOUS_VIA_SWARM === "true" - ) { + // Feature-flagged swarm path — default on in headless mode, opt-in elsewhere. + const swarmFlag = process.env.SF_AUTONOMOUS_VIA_SWARM; + const useSwarm = + swarmFlag === "1" || + swarmFlag === "true" || + (swarmFlag !== "0" && swarmFlag !== "false" && process.env.SF_HEADLESS === "1"); + if (useSwarm) { return runUnitViaSwarm(ctx, pi, s, unitType, unitId, prompt, options); }