Skip to content

fix(tools): name the sandbox working directory with POSIX separators in EnvironmentToolset instructions - #8154

Open
DZH166 wants to merge 1 commit into
google:mainfrom
DZH166:fix/environment-toolset-posix-path
Open

DZH166 wants to merge 1 commit into
google:mainfrom
DZH166:fix/environment-toolset-posix-path

Conversation

@DZH166

@DZH166 DZH166 commented Nov 14, 2026

Copy link
Copy Markdown

Problem

EnvironmentToolset builds the model-facing instruction lazily with the host path flavour:

working_dir = pathlib.PurePath(self.working_dir)      # _environment_toolset.py
...
f"All file paths used in the functions must be absolute and start with {parent_dir}."

The tool always talks to a Linux sandbox, but PurePath resolves against the running platform:

  • on Windows PurePath("/home/user") renders as \home\user, so the prompt tells the model to start paths with a backslash-prefixed string the sandbox does not have;
  • os.path.dirname() of a bare relative directory is "", so the examples are emitted relative to an empty directory;
  • pathlib also normalises the value (/home//user -> /home/user), disagreeing with the directory that is actually created.

The code already formats POSIX paths by hand a few lines below (f"{working_dir}/{file_name}"), and the sandbox wrappers hard-code /workspace.

before: "Your environment is at \home\user\" (Windows host)
after : first line "Your environment is at /home/user/" on every host

Fix

Strip trailing separators and render the directory with /, computing the parent directory on the POSIX string.

Tests

tests/unittests/tools/test_environment_toolset.py (1 new test; the existing 21 still pass):

pytest tests/unittests/tools/test_environment_toolset.py -q    # before: 1 failed, 21 passed   after: 22 passed

…in EnvironmentToolset instructions

The lazy instruction builder used pathlib.PurePath(working_dir), which takes the host flavour: on Windows a sandbox path like /home/user became backslash-separated in the model prompt, and dirname of a bare relative directory was empty so the examples were relative to nothing. Render the documented POSIX path explicitly.
@google-cla

google-cla Bot commented Nov 14, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants