fix(coding-agent): reuse initial resource loader on startup closes #2766

This commit is contained in:
Mario Zechner
2026-04-02 11:05:41 +02:00
parent 8ccd3c55c1
commit 617f1870f8
3 changed files with 10 additions and 3 deletions

View File

@@ -53,6 +53,8 @@ export interface CreateAgentSessionRuntimeOptions {
cwd: string;
/** Optional preselected session manager. If omitted, normal session resolution applies. */
sessionManager?: SessionManager;
/** Optional preloaded resource loader to reuse instead of creating and reloading one. */
resourceLoader?: ResourceLoader;
/** Optional session_start metadata to emit when the runtime binds extensions. */
sessionStartEvent?: SessionStartEvent;
}
@@ -86,15 +88,18 @@ export async function createAgentSessionRuntime(
const settingsManager = SettingsManager.create(cwd, agentDir);
const modelRegistry = ModelRegistry.create(authStorage, join(agentDir, "models.json"));
const resourceLoader =
typeof bootstrap.resourceLoader === "function"
options.resourceLoader ??
(typeof bootstrap.resourceLoader === "function"
? await bootstrap.resourceLoader(cwd, agentDir)
: new DefaultResourceLoader({
...(bootstrap.resourceLoader ?? {}),
cwd,
agentDir,
settingsManager,
});
await resourceLoader.reload();
}));
if (!options.resourceLoader) {
await resourceLoader.reload();
}
const extensionsResult = resourceLoader.getExtensions();
for (const { name, config } of extensionsResult.runtime.pendingProviderRegistrations) {