From 5ff65dbf68a4f6b0a25cbb3ee618210f7700d322 Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Fri, 17 Apr 2026 21:30:34 -0700 Subject: [PATCH] docs(execute_code): clarify that scripts run in their own temp dir, not session CWD (#11956) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Weaker models (Gemma-class) repeatedly rediscover and forget that execute_code's working directory differs from terminal()/read_file()'s, leading to os.path.exists('.env') returning False even though the file exists in the session's CWD. They then bounce between 'the file exists' and 'the file is missing' across tool calls. Adds a 'Working directory' note to the execute_code schema description pointing agents at absolute paths (os.path.expanduser) or terminal()/read_file() for inspecting user files. Carefully avoids the 'sandbox'/'isolated'/'cloud' language that commit 39b83f34 removed (it caused agents on local backends to refuse networking tasks and save false sandbox beliefs to persistent memory). Purely factual CWD guidance — no restriction implications. --- tools/code_execution_tool.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/code_execution_tool.py b/tools/code_execution_tool.py index 3e7e3f925b..8268024fc7 100644 --- a/tools/code_execution_tool.py +++ b/tools/code_execution_tool.py @@ -1367,6 +1367,8 @@ def build_execute_code_schema(enabled_sandbox_tools: set = None) -> dict: f"{tool_lines}\n\n" "Limits: 5-minute timeout, 50KB stdout cap, max 50 tool calls per script. " "terminal() is foreground-only (no background or pty).\n\n" + "Scripts run in their own temp dir, not the session's CWD — use absolute paths " + "(os.path.expanduser('~/.hermes/.env')) or terminal()/read_file() for user files.\n\n" "Print your final result to stdout. Use Python stdlib (json, re, math, csv, " "datetime, collections, etc.) for processing between tool calls.\n\n" "Also available (no import needed — built into hermes_tools):\n"