feat(swarm): default SF_AUTONOMOUS_VIA_SWARM on in headless mode
Some checks are pending
CI / detect-changes (push) Waiting to run
CI / docs-check (push) Blocked by required conditions
CI / lint (push) Blocked by required conditions
CI / build (push) Blocked by required conditions
CI / integration-tests (push) Blocked by required conditions
CI / windows-portability (push) Blocked by required conditions
CI / rtk-portability (linux, blacksmith-4vcpu-ubuntu-2404) (push) Blocked by required conditions
CI / rtk-portability (macos, macos-15) (push) Blocked by required conditions
CI / rtk-portability (windows, blacksmith-4vcpu-windows-2025) (push) Blocked by required conditions

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>
This commit is contained in:
Copilot 2026-05-15 05:34:01 +02:00
parent 46d9d45279
commit ea8a3d9354

View file

@ -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);
}