From e2ef5cce7b1894ba8bde85795ef8dbdb766d8948 Mon Sep 17 00:00:00 2001 From: Keith Patrick Date: Fri, 20 Mar 2026 13:24:03 +0000 Subject: [PATCH] log final env keys at exec time MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Debug log shows the merged env keys (cached + exec time + LLM extra) that will be passed to the executed command. Address PR #1261 feedback. 💘 Generated with Crush Assisted-by: MiniMax-M2.5 via Crush --- pkg/tools/shell.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/tools/shell.go b/pkg/tools/shell.go index bfef92ac2..5f3314cd3 100644 --- a/pkg/tools/shell.go +++ b/pkg/tools/shell.go @@ -5,6 +5,7 @@ import ( "context" "errors" "fmt" + "maps" "os" "os/exec" "path/filepath" @@ -15,6 +16,7 @@ import ( "github.com/sipeed/picoclaw/pkg/config" "github.com/sipeed/picoclaw/pkg/constants" + "github.com/sipeed/picoclaw/pkg/logger" "github.com/sipeed/picoclaw/pkg/tools/shell" ) @@ -315,7 +317,11 @@ func (t *ExecTool) Execute(ctx context.Context, args map[string]any) *ToolResult // Use sanitized environment - merge cached env with exec time vars and LLM extra env // Note: cachedEnv is NOT re-filtered - PICOCLAW_* vars are preserved - cmd.Env = shell.MapToEnvSlice(shell.MergeEnvVars(t.cachedEnv, execTimeEnv, extraEnv)) + finalEnv := shell.MergeEnvVars(t.cachedEnv, execTimeEnv, extraEnv) + cmd.Env = shell.MapToEnvSlice(finalEnv) + + // Debug: log final env keys being passed to command + logger.DebugCF("exec", "final env keys", map[string]any{"env_keys": maps.Keys(finalEnv)}) if cwd != "" { cmd.Dir = cwd