perf(task): defer subagent launch setup
This commit is contained in:
@@ -2,6 +2,10 @@
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Changed
|
||||
|
||||
- Moved subagent model-registry refresh and session-file opening off the launch critical path. Registry refresh now runs in the background while model resolution uses the registry's static/provider lookup, and `SessionManager.open` starts before prewalk/output-schema/session-option assembly so session creation waits only at its actual input boundary.
|
||||
|
||||
## [17.2.1] - 2026-07-30
|
||||
|
||||
### Added
|
||||
|
||||
@@ -2604,7 +2604,12 @@ export async function runSubprocess(options: ExecutorOptions): Promise<SingleRes
|
||||
}
|
||||
checkAbort();
|
||||
if (!registryFromParent) {
|
||||
await awaitAbortable(modelRegistry.refresh());
|
||||
void modelRegistry.refresh().catch(err => {
|
||||
logger.warn("Subagent model registry refresh failed", {
|
||||
id,
|
||||
error: err instanceof Error ? err.message : String(err),
|
||||
});
|
||||
});
|
||||
} else {
|
||||
logger.debug("runSubagent: reusing parent modelRegistry; skipping refresh");
|
||||
}
|
||||
@@ -2719,19 +2724,12 @@ export async function runSubprocess(options: ExecutorOptions): Promise<SingleRes
|
||||
}
|
||||
|
||||
const effectiveCwd = worktree ?? cwd;
|
||||
const sessionManager = sessionFile
|
||||
? await awaitAbortable(
|
||||
SessionManager.open(sessionFile, undefined, undefined, {
|
||||
initialCwd: effectiveCwd,
|
||||
suppressBreadcrumb: true,
|
||||
}),
|
||||
)
|
||||
: SessionManager.inMemory(effectiveCwd);
|
||||
if (options.parentArtifactManager) {
|
||||
sessionManager.adoptArtifactManager(options.parentArtifactManager);
|
||||
}
|
||||
sessionOpenedAt = performance.now();
|
||||
|
||||
const sessionManagerPromise = sessionFile
|
||||
? SessionManager.open(sessionFile, undefined, undefined, {
|
||||
initialCwd: effectiveCwd,
|
||||
suppressBreadcrumb: true,
|
||||
})
|
||||
: Promise.resolve(SessionManager.inMemory(effectiveCwd));
|
||||
const restrictToolNames = options.restrictToolNames === true;
|
||||
const enableMCP = !restrictToolNames && (options.enableMCP ?? true);
|
||||
const mcpManager = enableMCP ? options.mcpManager : undefined;
|
||||
@@ -2851,6 +2849,12 @@ export async function runSubprocess(options: ExecutorOptions): Promise<SingleRes
|
||||
},
|
||||
});
|
||||
|
||||
const sessionManager = await awaitAbortable(sessionManagerPromise);
|
||||
if (options.parentArtifactManager) {
|
||||
sessionManager.adoptArtifactManager(options.parentArtifactManager);
|
||||
}
|
||||
sessionOpenedAt = performance.now();
|
||||
|
||||
const sessionPromise = createAgentSession(buildSubagentSessionOptions(sessionManager, null));
|
||||
let session: AgentSession;
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user