fix(tools): inject TZ env into shell commands from config timezone

Ensure shell scripts executed via the exec tool use the same timezone
as the Go process (configured via agents.defaults.timezone). Without
this, shell date commands use the OS timezone, causing mismatch when
the config timezone differs from the system timezone.
This commit is contained in:
muava12 2026-02-24 13:37:50 +08:00
parent ff6c412882
commit 0870815af2

View file

@ -185,6 +185,13 @@ func (t *ExecTool) Execute(ctx context.Context, args map[string]any) *ToolResult
cmd.Dir = cwd
}
// Inherit parent env and inject TZ from config timezone (time.Local).
// This ensures shell scripts use the same timezone as the Go process.
cmd.Env = os.Environ()
if tz := time.Local.String(); tz != "Local" && tz != "" {
cmd.Env = append(cmd.Env, "TZ="+tz)
}
prepareCommandForTermination(cmd)
var stdout, stderr bytes.Buffer