@@ -162,6 +162,7 @@ export async function loadAndMaybeMigrateDoctorConfig(params: {
162162 pendingChanges : false ,
163163 fixHints : [ ] ,
164164 } ;
165+ const explicitSetPaths : string [ ] [ ] = [ ] ;
165166 let shouldRepairCronCodexModelRefsAfterConfigWrite = false ;
166167 const doctorFixCommand = formatCliCommand ( "openclaw doctor --fix" ) ;
167168 const applyConfigMutation = (
@@ -213,11 +214,14 @@ export async function loadAndMaybeMigrateDoctorConfig(params: {
213214 entries : migratedEntries as NonNullable < OpenClawConfig [ "agents" ] > [ "entries" ] ,
214215 } ,
215216 } ,
216- changes : [ "Persisted agents.entries with exactly one explicit default agent." ] ,
217+ changes : [ "Prepared agents.entries with exactly one explicit default agent for persistence ." ] ,
217218 } ;
218219 applyConfigMutation ( rosterRepair , {
219220 fixHint : `Run "${ doctorFixCommand } " to persist the explicit agent roster.` ,
220221 } ) ;
222+ // Read-time normalization already exposes this roster in the runtime shape.
223+ // Preserve doctor's write intent so the atomic writer does not restore the authored omission.
224+ explicitSetPaths . push ( [ "agents" , "entries" ] ) ;
221225 }
222226 applyConfigMutation ( materializeDefaultAgentRoles ( state . candidate ) , {
223227 fixHint : `Run "${ doctorFixCommand } " to persist explicit ambient agent targets.` ,
@@ -503,6 +507,7 @@ export async function loadAndMaybeMigrateDoctorConfig(params: {
503507 sourceConfigValid : snapshot . valid ,
504508 ...( sourceLastTouchedVersion ? { sourceLastTouchedVersion } : { } ) ,
505509 ...( legacyMigrationPartiallyValid ? { skipPluginValidationOnWrite : true } : { } ) ,
510+ ...( finalized . shouldWriteConfig && explicitSetPaths . length > 0 ? { explicitSetPaths } : { } ) ,
506511 ...( singleTopLevelIncludeWrite ? { skipWizardMetadataForIncludeWrite : true } : { } ) ,
507512 ...( shouldRepairCronCodexModelRefsAfterConfigWrite
508513 ? { shouldRepairCronCodexModelRefsAfterConfigWrite : true }
0 commit comments