From 2b190b21228cd438432b0e45f7d9fd4893a7fbbf Mon Sep 17 00:00:00 2001 From: Goutam Adwant <8672451+goutamadwant@users.noreply.github.com> Date: Thu, 20 Aug 2026 21:44:05 -0700 Subject: [PATCH] fix(doctor): migrate markerless multi-agent rosters (#126595) --- src/commands/doctor-config-flow.test.ts | 27 +++++++++++++++++++++++++ src/commands/doctor-config-flow.ts | 3 +-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/commands/doctor-config-flow.test.ts b/src/commands/doctor-config-flow.test.ts index 5075bf22434e..2b1e14215152 100644 --- a/src/commands/doctor-config-flow.test.ts +++ b/src/commands/doctor-config-flow.test.ts @@ -1858,6 +1858,33 @@ describe("doctor config flow", () => { expect(result.cfg.agents).not.toHaveProperty("list"); }); + it("stamps explicit ownership when Doctor migrates a markerless multi-agent list", async () => { + const rawConfig = { + agents: { + list: [{ id: "ops" }, { id: "research", model: "openai/research" }], + }, + }; + const result = await runDoctorConfigWithInput({ + config: migratePersistedImplicitMainRoster(rawConfig).config as OpenClawConfig, + parsedConfig: rawConfig, + repair: true, + run: loadAndMaybeMigrateDoctorConfig, + }); + + expect(result.shouldWriteConfig).toBe(true); + expect(result.explicitSetPaths).toEqual([ + ["agents", "entries"], + ["agents", "ownership"], + ]); + expect(result.cfg.agents).toEqual({ + ownership: "explicit", + entries: { + ops: {}, + research: { model: "openai/research" }, + }, + }); + }); + it("materializes ambient roles for a multi-agent configured default", async () => { const rawConfig = { agents: { diff --git a/src/commands/doctor-config-flow.ts b/src/commands/doctor-config-flow.ts index 48544f98b845..89ab2e8e55f8 100644 --- a/src/commands/doctor-config-flow.ts +++ b/src/commands/doctor-config-flow.ts @@ -266,8 +266,7 @@ export async function loadAndMaybeMigrateDoctorConfig(params: { const migratedRoster = readAgentRosterProperty(migrated); const migratedEntries = migratedRoster?.kind === "entries" ? migratedRoster.value : undefined; const { list: _legacyList, ...candidateAgents } = migrated.agents ?? {}; - const stampsExplicitOwnership = - legacyDefaultAgentId !== undefined && Object.keys(migratedEntries ?? {}).length > 1; + const stampsExplicitOwnership = Object.keys(migratedEntries ?? {}).length > 1; const rosterRepair = { config: { ...migrated,