From 9bc41aa117e535d6430c8e2fe0d8f4e04685760e Mon Sep 17 00:00:00 2001 From: season <690088088@qq.com> Date: Tue, 14 Jul 2026 19:40:51 +0800 Subject: [PATCH] fix(shell_hooks): use explicit UTF-8 encoding with errors='replace' Replace text=True (which uses locale encoding on Windows, e.g. GBK) with explicit encoding='utf-8', errors='replace' to prevent UnicodeDecodeError when shell hooks output non-ASCII characters. text=True on Windows defaults to the system's ANSI codepage (e.g. GBK/CP936 on Chinese Windows), causing silent failures when hook output contains characters outside that codepage. --- agent/shell_hooks.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/agent/shell_hooks.py b/agent/shell_hooks.py index c1cec81df333..e2f1fc426553 100644 --- a/agent/shell_hooks.py +++ b/agent/shell_hooks.py @@ -464,7 +464,8 @@ def _spawn(spec: ShellHookSpec, stdin_json: str) -> Dict[str, Any]: input=stdin_json, capture_output=True, timeout=spec.timeout, - text=True, + encoding='utf-8', + errors='replace', shell=False, **_popen_kwargs, )