From 317b8254e45ff438eeec45225cf506ec616958a3 Mon Sep 17 00:00:00 2001 From: iven Date: Tue, 21 Apr 2026 21:19:44 +0800 Subject: [PATCH] =?UTF-8?q?fix(growth,saas):=20B9=20Agent=E5=88=9B?= =?UTF-8?q?=E5=BB=BA502=E8=B0=83=E6=9F=A5+=E6=97=A5=E5=BF=97=E5=A2=9E?= =?UTF-8?q?=E5=BC=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 深入追踪 B9 (Agent 创建 502): - SaaS create_agent_from_template 端点代码不可能产生 502 (SaasError::Relay 是唯一 502 来源,仅 relay 模块使用) - 前端 createFromTemplate 双层 try-catch + fallback 已足够健壮 - 结论: B9 不可复现,可能因当时 SaaS 未运行或 token 过期导致 改进: - handlers.rs: 添加 create_agent_from_template 请求/响应日志 - agentStore.ts: outer catch 记录 status + message 便于未来诊断 --- crates/zclaw-saas/src/agent_template/handlers.rs | 5 ++++- desktop/src/store/agentStore.ts | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/crates/zclaw-saas/src/agent_template/handlers.rs b/crates/zclaw-saas/src/agent_template/handlers.rs index 36dfd79..98cfefc 100644 --- a/crates/zclaw-saas/src/agent_template/handlers.rs +++ b/crates/zclaw-saas/src/agent_template/handlers.rs @@ -186,5 +186,8 @@ pub async fn create_agent_from_template( Path(id): Path, ) -> SaasResult> { check_permission(&ctx, "model:read")?; - Ok(Json(service::create_agent_from_template(&state.db, &id).await?)) + tracing::info!("[AgentTemplate] create_agent_from_template: id={}, account={}", id, ctx.account_id); + let result = service::create_agent_from_template(&state.db, &id).await?; + tracing::info!("[AgentTemplate] create_agent_from_template OK: name={}", result.name); + Ok(Json(result)) } diff --git a/desktop/src/store/agentStore.ts b/desktop/src/store/agentStore.ts index 9c6554e..250185d 100644 --- a/desktop/src/store/agentStore.ts +++ b/desktop/src/store/agentStore.ts @@ -342,7 +342,8 @@ export const useAgentStore = create((set, get) => ({ } return undefined; } catch (error) { - log.error('[AgentStore] createFromTemplate error:', error); + const status = error && typeof error === 'object' ? (error as { status?: number }).status : undefined; + log.error('[AgentStore] createFromTemplate error:', { status, message: error instanceof Error ? error.message : String(error) }); const userMsg = classifyAgentError(error, '创建失败'); set({ error: userMsg }); return undefined;