fix: warmup ACP subprocess eagerly to avoid 30s cold-start on status
The pool refactor made ACP client creation lazy, causing the first /llm/health call to spawn + initialize + prompt Gemini in one request (30s+). Now warmup() eagerly starts the subprocess on mcplocal boot. Also fetch models in parallel with LLM health check. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -28,7 +28,9 @@ export async function createProviderFromConfig(
|
||||
const cfg: GeminiAcpConfig = {};
|
||||
if (config.binaryPath) cfg.binaryPath = config.binaryPath;
|
||||
if (config.model) cfg.defaultModel = config.model;
|
||||
registry.register(new GeminiAcpProvider(cfg));
|
||||
const provider = new GeminiAcpProvider(cfg);
|
||||
provider.warmup();
|
||||
registry.register(provider);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -83,6 +83,18 @@ export class GeminiAcpProvider implements LlmProvider {
|
||||
this.pool.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Eagerly spawn the default model's ACP subprocess so it's ready
|
||||
* for the first request (avoids 30s cold-start on health checks).
|
||||
*/
|
||||
warmup(): void {
|
||||
const entry = this.getOrCreateEntry(this.defaultModel);
|
||||
// Fire-and-forget: start the subprocess initialization in the background
|
||||
entry.client.ensureReady().catch(() => {
|
||||
// Ignore errors — next request will retry
|
||||
});
|
||||
}
|
||||
|
||||
/** Number of active pool entries (for testing). */
|
||||
get poolSize(): number {
|
||||
return this.pool.size;
|
||||
|
||||
Reference in New Issue
Block a user