From f1b9e0fde92d5b303ff2b827bf5d2e16ce02f621 Mon Sep 17 00:00:00 2001 From: master Date: Fri, 20 Mar 2026 13:27:52 -0400 Subject: [PATCH] Plugins: align reset default agent --- src/plugins/registry.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/plugins/registry.ts b/src/plugins/registry.ts index 2a3055d45fb..0f8909c713c 100644 --- a/src/plugins/registry.ts +++ b/src/plugins/registry.ts @@ -319,12 +319,15 @@ const canonicalizePluginMainSessionAlias = (params: { }; const resolveDefaultPluginAgentId = (cfg: OpenClawConfig): string => { - const agents = Array.isArray(cfg.agents?.list) ? cfg.agents.list : []; - const preferred = - agents.find((agent) => agent?.default)?.id ?? - agents.find((agent) => typeof agent?.id === "string")?.id ?? - FALLBACK_AGENT_ID; - return normalizePluginAgentId(preferred); + const agents = Array.isArray(cfg.agents?.list) + ? cfg.agents.list.filter((agent) => Boolean(agent && typeof agent === "object")) + : []; + if (agents.length === 0) { + return FALLBACK_AGENT_ID; + } + const preferredEntry = agents.find((agent) => agent?.default) ?? agents[0]; + const preferredId = typeof preferredEntry?.id === "string" ? preferredEntry.id : undefined; + return normalizePluginAgentId(preferredId); }; const resolvePluginMainSessionKey = (cfg: OpenClawConfig): string => {