log final env keys at exec time

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 <crush@charm.land>
This commit is contained in:
Keith Patrick 2026-03-20 13:24:03 +00:00
parent 7b8d8a8416
commit e2ef5cce7b

View file

@ -5,6 +5,7 @@ import (
"context" "context"
"errors" "errors"
"fmt" "fmt"
"maps"
"os" "os"
"os/exec" "os/exec"
"path/filepath" "path/filepath"
@ -15,6 +16,7 @@ import (
"github.com/sipeed/picoclaw/pkg/config" "github.com/sipeed/picoclaw/pkg/config"
"github.com/sipeed/picoclaw/pkg/constants" "github.com/sipeed/picoclaw/pkg/constants"
"github.com/sipeed/picoclaw/pkg/logger"
"github.com/sipeed/picoclaw/pkg/tools/shell" "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 // Use sanitized environment - merge cached env with exec time vars and LLM extra env
// Note: cachedEnv is NOT re-filtered - PICOCLAW_* vars are preserved // 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 != "" { if cwd != "" {
cmd.Dir = cwd cmd.Dir = cwd