diff --git a/agents/s02_tool_use.py b/agents/s02_tool_use.py index 8e434c04a..deff34143 100644 --- a/agents/s02_tool_use.py +++ b/agents/s02_tool_use.py @@ -51,7 +51,8 @@ def run_bash(command: str) -> str: return "Error: Dangerous command blocked" try: r = subprocess.run(command, shell=True, cwd=WORKDIR, - capture_output=True, text=True, timeout=120) + capture_output=True, text=True, + encoding="utf-8", errors="replace", timeout=120) out = (r.stdout + r.stderr).strip() return out[:50000] if out else "(no output)" except subprocess.TimeoutExpired: diff --git a/s02_tool_use/code.py b/s02_tool_use/code.py index 4630521ee..e6575119a 100644 --- a/s02_tool_use/code.py +++ b/s02_tool_use/code.py @@ -49,7 +49,8 @@ def run_bash(command: str) -> str: return "Error: Dangerous command blocked" try: r = subprocess.run(command, shell=True, cwd=WORKDIR, - capture_output=True, text=True, timeout=120) + capture_output=True, text=True, + encoding="utf-8", errors="replace", timeout=120) out = (r.stdout + r.stderr).strip() return out[:50000] if out else "(no output)" except subprocess.TimeoutExpired: