fix: per-provider health checks in /llm/providers and status display
The /llm/providers endpoint now runs isAvailable() on each provider in parallel and returns health status per provider. The status command shows ✓/✗ per provider based on actual availability, not just the fast tier. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -140,19 +140,40 @@ export async function createHttpServer(
|
||||
}
|
||||
});
|
||||
|
||||
// LLM providers — list all registered providers with tier assignments
|
||||
// LLM providers — list all registered providers with tier assignments and health
|
||||
app.get('/llm/providers', async (_request, reply) => {
|
||||
const registry = deps.providerRegistry;
|
||||
if (!registry) {
|
||||
reply.code(200).send({ providers: [], tiers: { fast: [], heavy: [] } });
|
||||
reply.code(200).send({ providers: [], tiers: { fast: [], heavy: [] }, health: {} });
|
||||
return;
|
||||
}
|
||||
|
||||
// Run isAvailable() on all providers in parallel (lightweight, no tokens burned)
|
||||
const names = registry.list();
|
||||
const healthChecks = await Promise.all(
|
||||
names.map(async (name) => {
|
||||
const provider = registry.get(name);
|
||||
if (!provider) return { name, available: false };
|
||||
try {
|
||||
const available = await provider.isAvailable();
|
||||
return { name, available };
|
||||
} catch {
|
||||
return { name, available: false };
|
||||
}
|
||||
}),
|
||||
);
|
||||
const health: Record<string, boolean> = {};
|
||||
for (const check of healthChecks) {
|
||||
health[check.name] = check.available;
|
||||
}
|
||||
|
||||
reply.code(200).send({
|
||||
providers: registry.list(),
|
||||
providers: names,
|
||||
tiers: {
|
||||
fast: registry.getTierProviders('fast'),
|
||||
heavy: registry.getTierProviders('heavy'),
|
||||
},
|
||||
health,
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user