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.
This commit is contained in:
parent
67eaa984c7
commit
639f700c15
1 changed files with 8 additions and 2 deletions
|
|
@ -56,8 +56,14 @@ func agentCmd(message, sessionKey, model string, debug bool) error {
|
||||||
|
|
||||||
// Print agent startup info (only for interactive mode)
|
// Print agent startup info (only for interactive mode)
|
||||||
startupInfo := agentLoop.GetStartupInfo()
|
startupInfo := agentLoop.GetStartupInfo()
|
||||||
toolsInfo, _ := startupInfo["tools"].(map[string]any)
|
toolsInfo, ok := startupInfo["tools"].(map[string]any)
|
||||||
skillsInfo, _ := startupInfo["skills"].(map[string]any)
|
if !ok {
|
||||||
|
toolsInfo = nil
|
||||||
|
}
|
||||||
|
skillsInfo, ok := startupInfo["skills"].(map[string]any)
|
||||||
|
if !ok {
|
||||||
|
skillsInfo = nil
|
||||||
|
}
|
||||||
logFields := map[string]any{}
|
logFields := map[string]any{}
|
||||||
if toolsInfo != nil {
|
if toolsInfo != nil {
|
||||||
logFields["tools_count"] = toolsInfo["count"]
|
logFields["tools_count"] = toolsInfo["count"]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue