From 0870815af28e4f4db1623f059b5f9144e1d90062 Mon Sep 17 00:00:00 2001 From: muava12 Date: Tue, 24 Feb 2026 13:37:50 +0800 Subject: [PATCH] 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. --- pkg/tools/shell.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkg/tools/shell.go b/pkg/tools/shell.go index 6883172cd..d6b71d585 100644 --- a/pkg/tools/shell.go +++ b/pkg/tools/shell.go @@ -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