From 94aeb7b7fe86b2969c5ff99d88ede7071025d770 Mon Sep 17 00:00:00 2001 From: Fuad Date: Sat, 26 Apr 2025 23:00:50 +0300 Subject: [PATCH] Fix nil pointer dereference in GetPersistentShell Added nil check in GetPersistentShell before accessing shellInstance.isAlive to prevent panic when newPersistentShell returns nil due to shell startup errors. This resolves the "invalid memory address or nil pointer dereference" error that was occurring in the shell tool. --- internal/llm/tools/shell/shell.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/llm/tools/shell/shell.go b/internal/llm/tools/shell/shell.go index e25bdf3ea..08d8a986b 100644 --- a/internal/llm/tools/shell/shell.go +++ b/internal/llm/tools/shell/shell.go @@ -47,7 +47,7 @@ func GetPersistentShell(workingDir string) *PersistentShell { shellInstance = newPersistentShell(workingDir) }) - if !shellInstance.isAlive { + if shellInstance == nil || !shellInstance.isAlive { shellInstance = newPersistentShell(shellInstance.cwd) }