Skip to content

Fix/sandbox containerworkdir rw access#4226

Closed
ozgur-polat wants to merge 2 commits intoopenclaw:mainfrom
ozgur-polat:fix/sandbox-containerworkdir-rw-access
Closed

Fix/sandbox containerworkdir rw access#4226
ozgur-polat wants to merge 2 commits intoopenclaw:mainfrom
ozgur-polat:fix/sandbox-containerworkdir-rw-access

Conversation

@ozgur-polat
Copy link
Copy Markdown
Contributor

@ozgur-polat ozgur-polat commented Jan 29, 2026

Summary

Fixes #4171 - Cron isolated agent does not pass sandboxInfo to system prompt

Problem

When running a cron job with sessionTarget: "isolated" and sandbox enabled with workspaceAccess: "rw", the agent receives the host workspace path (e.g., /home/node/loom-novia) in the system prompt instead of the Docker container mount path (/workspace).

Root Cause

The buildEmbeddedSandboxInfo() function was only setting agentWorkspaceMount for read-only (ro) access, but not for read-write (rw) access.

Changes

  • src/agents/pi-embedded-runner/sandbox-info.ts: Added logic to set agentWorkspaceMount to containerWorkdir (typically /workspace) for rw access
  • src/agents/pi-embedded-runner.buildembeddedsandboxinfo.test.ts: Added 2 new test cases for rw and ro workspace access modes

Testing

  • All existing tests pass
  • New test cases added for rw/ro access modes
  • Lint passes
  • Build passes

AI-Assisted

  • This PR was AI-assisted
  • Lightly tested (unit tests only)
  • I understand what the code does

Greptile Overview

Greptile Summary

This PR updates buildEmbeddedSandboxInfo to populate agentWorkspaceMount for workspaceAccess: "rw" using the sandbox’s containerWorkdir, so system prompts reference the container-mounted workspace path (e.g. /workspace) instead of host paths. It also adds unit coverage for rw/ro access modes, and includes small doc/changelog updates.

In the codebase, EmbeddedSandboxInfo is used to shape what the agent sees in the system prompt about its execution sandbox; this change ensures the prompt reflects the actual filesystem mount point when the agent has read/write workspace access inside the container.

Confidence Score: 4/5

  • This PR is likely safe to merge and addresses the reported sandbox path issue with minimal surface area.
  • The change is localized to sandbox prompt info construction and is backed by new unit tests. Remaining risk is mostly around assumptions that containerWorkdir is always set for rw, and that tests don’t fully assert the originally reported host-vs-container path mismatch scenario.
  • src/agents/pi-embedded-runner/sandbox-info.ts; src/agents/pi-embedded-runner.buildembeddedsandboxinfo.test.ts

(5/5) You can turn off certain types of comments like style here!

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation agents Agent runtime and tooling labels Jan 29, 2026
Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 files reviewed, 3 comments

Edit Code Review Agent Settings | Greptile

Comment on lines +14 to +19
const agentWorkspaceMount =
sandbox.workspaceAccess === "rw"
? sandbox.containerWorkdir
: sandbox.workspaceAccess === "ro"
? "/agent"
: undefined;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] agentWorkspaceMount can end up undefined for rw if sandbox.containerWorkdir is missing/empty.

The new branch returns sandbox.containerWorkdir directly for workspaceAccess === "rw". If containerWorkdir is ever unset (e.g., older/partial SandboxContext shapes, misconfig, or a future refactor), this silently produces no mount path even though access is rw, and the original bug can reappear. Consider either defaulting to sandbox.docker.workdir (which is already present on the context) or asserting containerWorkdir is present for rw to fail fast.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/agents/pi-embedded-runner/sandbox-info.ts
Line: 14:19

Comment:
[P1] `agentWorkspaceMount` can end up `undefined` for `rw` if `sandbox.containerWorkdir` is missing/empty.

The new branch returns `sandbox.containerWorkdir` directly for `workspaceAccess === "rw"`. If `containerWorkdir` is ever unset (e.g., older/partial `SandboxContext` shapes, misconfig, or a future refactor), this silently produces no mount path even though access is `rw`, and the original bug can reappear. Consider either defaulting to `sandbox.docker.workdir` (which is already present on the context) or asserting `containerWorkdir` is present for `rw` to fail fast.


How can I resolve this? If you propose a fix, please make it concise.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Feb 3, 2026

Additional Comments (2)

src/agents/pi-embedded-runner.buildembeddedsandboxinfo.test.ts
[P2] New tests don’t cover the real failing case (cron isolated agent showing host path).

Both added cases hardcode containerWorkdir: "/workspace" and only assert it’s copied into agentWorkspaceMount. The regression described in the PR sounds like the system prompt was using the host workspace path; it would be useful to add a test where workspaceDir/agentWorkspaceDir are host paths while containerWorkdir differs, and assert that agentWorkspaceMount uses the container path for rw (and /agent for ro). That would catch a future change that accidentally reverts to host paths.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/agents/pi-embedded-runner.buildembeddedsandboxinfo.test.ts
Line: 146:181

Comment:
[P2] New tests don’t cover the real failing case (cron isolated agent showing host path).

Both added cases hardcode `containerWorkdir: "/workspace"` and only assert it’s copied into `agentWorkspaceMount`. The regression described in the PR sounds like the system prompt was using the *host* workspace path; it would be useful to add a test where `workspaceDir`/`agentWorkspaceDir` are host paths while `containerWorkdir` differs, and assert that `agentWorkspaceMount` uses the container path for `rw` (and `/agent` for `ro`). That would catch a future change that accidentally reverts to host paths.


How can I resolve this? If you propose a fix, please make it concise.

docs/start/onboarding.md
[P3] This doc tweak changes the heading numbering but doesn’t mention the new “security notice” page in the “Page order (current)” list above unless the list was also updated.

Double-check that the numbered “Page order (current)” section matches the later headings after renumbering (it looks aligned in this diff, but this file is easy to get out of sync if one is edited without the other).

Prompt To Fix With AI
This is a comment left during a code review.
Path: docs/start/onboarding.md
Line: 24:26

Comment:
[P3] This doc tweak changes the heading numbering but doesn’t mention the new “security notice” page in the “Page order (current)” list above unless the list was also updated.

Double-check that the numbered “Page order (current)” section matches the later headings after renumbering (it looks aligned in this diff, but this file is easy to get out of sync if one is edited without the other).

How can I resolve this? If you propose a fix, please make it concise.

@mudrii

This comment was marked as spam.

@openclaw-barnacle
Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Mar 7, 2026
@openclaw-barnacle
Copy link
Copy Markdown

Closing due to inactivity.
If you believe this PR should be revived, post in #pr-thunderdome-dangerzone on Discord to talk to a maintainer.
That channel is the escape hatch for high-quality PRs that get auto-closed.

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

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation stale Marked as stale due to inactivity

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cron isolated agent does not pass sandboxInfo to system prompt

2 participants