From 639f700c151432672539e97d175e2b0673e54fb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=8B=E6=99=BA=E8=B6=850668000959?= Date: Sun, 7 Jun 2026 21:28:45 +0800 Subject: [PATCH] fix(agent): add ok checks for startup info type assertions GetStartupInfo returns map[string]any, and type-asserting tools/skills entries without checking ok is fragile. While the current implementation always stores the correct types, a future refactor could cause silent nil dereference. Add ok checks with explicit nil fallback. --- cmd/picoclaw/internal/agent/helpers.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cmd/picoclaw/internal/agent/helpers.go b/cmd/picoclaw/internal/agent/helpers.go index 405a1c696..e22e19484 100644 --- a/cmd/picoclaw/internal/agent/helpers.go +++ b/cmd/picoclaw/internal/agent/helpers.go @@ -56,8 +56,14 @@ func agentCmd(message, sessionKey, model string, debug bool) error { // Print agent startup info (only for interactive mode) startupInfo := agentLoop.GetStartupInfo() - toolsInfo, _ := startupInfo["tools"].(map[string]any) - skillsInfo, _ := startupInfo["skills"].(map[string]any) + toolsInfo, ok := startupInfo["tools"].(map[string]any) + if !ok { + toolsInfo = nil + } + skillsInfo, ok := startupInfo["skills"].(map[string]any) + if !ok { + skillsInfo = nil + } logFields := map[string]any{} if toolsInfo != nil { logFields["tools_count"] = toolsInfo["count"]