From 981ab696b740ce0cf6bb8508d0a67b029780c285 Mon Sep 17 00:00:00 2001 From: bboxwtf Date: Sat, 21 Mar 2026 03:41:05 +0000 Subject: [PATCH] fix(seed): always run seedDefaultProvider regardless of agents count --- server/seed.ts | 65 +++++++++++++++++++++++++------------------------- 1 file changed, 32 insertions(+), 33 deletions(-) diff --git a/server/seed.ts b/server/seed.ts index 23798b1..f655948 100644 --- a/server/seed.ts +++ b/server/seed.ts @@ -332,40 +332,39 @@ export async function seedDefaults(): Promise { .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