fix(seed): always run seedDefaultProvider regardless of agents count

This commit is contained in:
bboxwtf
2026-03-21 03:41:05 +00:00
parent 1ad62cf215
commit 981ab696b7

View File

@@ -332,40 +332,39 @@ export async function seedDefaults(): Promise<void> {
.where(eq(agents.isSystem, true));
if (Number(systemCount) > 0) {
console.log(`[Seed] Skipping — ${systemCount} system agent(s) already exist`);
return;
console.log(`[Seed] Skipping agents ${systemCount} system agent(s) already exist`);
} else {
console.log("[Seed] No agents found — seeding default agents...");
for (const agentDef of DEFAULT_AGENTS) {
await db.insert(agents).values({
userId: SYSTEM_USER_ID,
name: agentDef.name,
description: agentDef.description,
role: agentDef.role,
model: agentDef.model,
provider: agentDef.provider,
temperature: agentDef.temperature,
maxTokens: agentDef.maxTokens,
topP: agentDef.topP,
frequencyPenalty: agentDef.frequencyPenalty,
presencePenalty: agentDef.presencePenalty,
systemPrompt: agentDef.systemPrompt,
allowedTools: agentDef.allowedTools,
allowedDomains: agentDef.allowedDomains,
maxRequestsPerHour: agentDef.maxRequestsPerHour,
isActive: agentDef.isActive,
isPublic: agentDef.isPublic,
isSystem: agentDef.isSystem,
isOrchestrator: agentDef.isOrchestrator,
tags: agentDef.tags,
metadata: agentDef.metadata,
});
console.log(`[Seed] ✓ Created agent: ${agentDef.name}`);
}
console.log(`[Seed] Done — ${DEFAULT_AGENTS.length} default agents created`);
}
console.log("[Seed] No agents found — seeding default agents...");
for (const agentDef of DEFAULT_AGENTS) {
await db.insert(agents).values({
userId: SYSTEM_USER_ID,
name: agentDef.name,
description: agentDef.description,
role: agentDef.role,
model: agentDef.model,
provider: agentDef.provider,
temperature: agentDef.temperature,
maxTokens: agentDef.maxTokens,
topP: agentDef.topP,
frequencyPenalty: agentDef.frequencyPenalty,
presencePenalty: agentDef.presencePenalty,
systemPrompt: agentDef.systemPrompt,
allowedTools: agentDef.allowedTools,
allowedDomains: agentDef.allowedDomains,
maxRequestsPerHour: agentDef.maxRequestsPerHour,
isActive: agentDef.isActive,
isPublic: agentDef.isPublic,
isSystem: agentDef.isSystem,
isOrchestrator: agentDef.isOrchestrator,
tags: agentDef.tags,
metadata: agentDef.metadata,
});
console.log(`[Seed] ✓ Created agent: ${agentDef.name}`);
}
console.log(`[Seed] Done — ${DEFAULT_AGENTS.length} default agents created`);
} catch (error) {
console.error("[Seed] Failed to seed default agents:", error);
// Non-fatal: server continues even if seed fails