Skip to content

Commit b28290c

Browse files
zeroaltitudeclaude
andcommitted
fix(models-config): wire plugin-catalog writes into ensureOpenClawModelsJson (restore main parity)
The cache-fingerprint rewrite of ensureOpenClawModelsJson dropped main's plugin-catalog writing: mergeGeneratedPluginCatalogProvidersIntoExistingParsed (merge generated plugin provider catalogs into existingParsed before planning) and writePluginCatalogsForModelsJson (write the catalogs in the skip/noop/write paths). Both functions were defined but never called, so generated plugin provider catalogs were no longer written alongside models.json. Restore the calls, mirroring main's skip/noop/write structure. main's mtime-based cache helpers (readFileMtimeMs/readPluginCatalogMtimes) stay intentionally removed — superseded by this branch's content fingerprint. models-config + plugin-catalog suite: 40/40. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
1 parent 450151b commit b28290c

1 file changed

Lines changed: 20 additions & 3 deletions

File tree

‎src/agents/models-config.ts‎

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -729,14 +729,19 @@ export async function ensureOpenClawModelsJson(
729729
// are available to provider discovery without mutating process.env.
730730
const env = createConfigRuntimeEnv(cfg);
731731
const existingModelsFile = await readExistingModelsFile(targetPath);
732+
const existingParsedForMerge = await mergeGeneratedPluginCatalogProvidersIntoExistingParsed({
733+
agentDir,
734+
existingParsed: existingModelsFile.parsed,
735+
...(pluginMetadataSnapshot ? { pluginMetadataSnapshot } : {}),
736+
});
732737
const plan = await planOpenClawModelsJson({
733738
cfg,
734739
sourceConfigForSecrets: resolved.sourceConfigForSecrets,
735740
agentDir,
736741
env,
737742
...(workspaceDir ? { workspaceDir } : {}),
738743
existingRaw: existingModelsFile.raw,
739-
existingParsed: existingModelsFile.parsed,
744+
existingParsed: existingParsedForMerge,
740745
...(pluginMetadataSnapshot ? { pluginMetadataSnapshot } : {}),
741746
...(options.providerDiscoveryProviderIds
742747
? { providerDiscoveryProviderIds: options.providerDiscoveryProviderIds }
@@ -752,27 +757,39 @@ export async function ensureOpenClawModelsJson(
752757
if (plan.action === "skip") {
753758
// No write performed; capture whatever's currently on disk so the
754759
// cache can detect external edits between now and the next call.
760+
const wrotePluginCatalog = await writePluginCatalogsForModelsJson({
761+
agentDir,
762+
pluginCatalogWrites: plan.pluginCatalogWrites,
763+
});
755764
const modelsJsonOutcome = await readModelsJsonContentOutcome(targetPath);
756765
return {
757766
fingerprint: fingerprintForEntry,
758767
modelsJsonOutcome,
759-
result: { agentDir, wrote: false },
768+
result: { agentDir, wrote: wrotePluginCatalog },
760769
};
761770
}
762771

763772
if (plan.action === "noop") {
773+
const wrotePluginCatalog = await writePluginCatalogsForModelsJson({
774+
agentDir,
775+
pluginCatalogWrites: plan.pluginCatalogWrites,
776+
});
764777
await ensureModelsFileModeForModelsJson(targetPath);
765778
const modelsJsonOutcome = await readModelsJsonContentOutcome(targetPath);
766779
return {
767780
fingerprint: fingerprintForEntry,
768781
modelsJsonOutcome,
769-
result: { agentDir, wrote: false },
782+
result: { agentDir, wrote: wrotePluginCatalog },
770783
};
771784
}
772785

773786
await fs.mkdir(agentDir, { recursive: true, mode: 0o700 });
774787
await writeModelsFileAtomicForModelsJson(targetPath, plan.contents);
775788
await ensureModelsFileModeForModelsJson(targetPath);
789+
await writePluginCatalogsForModelsJson({
790+
agentDir,
791+
pluginCatalogWrites: plan.pluginCatalogWrites,
792+
});
776793
// Capture the post-write outcome so subsequent cache checks can
777794
// detect any external edit / corruption that happens after this
778795
// point.

0 commit comments

Comments
 (0)