DeepTutor: Lifelong Personalized Tutoring. https://deeptutor.info/.
Python ai-agentsai-tutorclawbotcli-tooldeepresearchinteractive-learninglearningmulti-agent-systemsrag
fix: request UTF-8 mode for model-authored exec code
wumajiehechuan-laba4c85477b548
diff --git a/deeptutor/services/workspace/execution.py b/deeptutor/services/workspace/execution.pyindex 982484b51..163e60402 100644--- a/deeptutor/services/workspace/execution.py+++ b/deeptutor/services/workspace/execution.py@@ -96,6 +96,13 @@ def prepare_workspace_execution_env("LANG": os.environ.get("LANG", "C.UTF-8"),"PYTHONUNBUFFERED": "1","PYTHONDONTWRITEBYTECODE": "1",+ # Model-authored Python must not fall back to the host's ANSI code page+ # (cp936, cp1252, …): a bare ``open()`` / ``Path.read_text()`` would then+ # mis-decode the UTF-8 files this workspace and every skill writes, and+ # printing a non-ASCII path or message would reach the caller mojibaked.+ # The exec environment inherits only a fixed subset of host variables,+ # so UTF-8 mode has to be requested explicitly rather than assumed.+ "PYTHONUTF8": "1",}if workspace_root:# A stable symbolic handle for model-authored code that needs to opendiff --git a/tests/services/workspace/test_content_workspace.py b/tests/services/workspace/test_content_workspace.pyindex ac98e17ae..ea0712291 100644--- a/tests/services/workspace/test_content_workspace.py+++ b/tests/services/workspace/test_content_workspace.py@@ -583,6 +583,22 @@ def test_execution_environment_keeps_mutable_tool_state_in_the_turn(assert exec_env["DEEPTUTOR_WORKSPACE_ROOT"] == str(workspace_root.resolve())+def test_execution_environment_requests_utf8_mode(+ tmp_path: Path,+) -> None:+ """Model-authored Python must not inherit the host's ANSI code page.++ Without UTF-8 mode a bare ``Path.read_text()`` / ``open()`` decodes UTF-8+ files with the locale encoding — ``cp936`` on a Chinese Windows host — so+ any script that reads a template or writes non-ASCII output fails or+ corrupts it. The exec environment inherits only a fixed subset of host+ variables, so this has to be set here rather than left to the host.+ """+ exec_env = prepare_workspace_execution_env(tmp_path / "outputs" / "chat" / "s" / "turn")++ assert exec_env["PYTHONUTF8"] == "1"++def test_execution_environment_rejects_hidden_state_symlink(tmp_path: Path,) -> None: