From 799049f586dc59792f56ae688a44237929652aad Mon Sep 17 00:00:00 2001 From: Vignesh Natarajan Date: Sun, 15 Feb 2026 19:15:57 -0800 Subject: [PATCH] fix (agents/sandbox): clarify container-vs-host workspace paths in prompt --- src/agents/system-prompt.e2e.test.ts | 6 ++++-- src/agents/system-prompt.ts | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/agents/system-prompt.e2e.test.ts b/src/agents/system-prompt.e2e.test.ts index e2180a49561..0b552fd62d3 100644 --- a/src/agents/system-prompt.e2e.test.ts +++ b/src/agents/system-prompt.e2e.test.ts @@ -454,10 +454,12 @@ describe("buildAgentSystemPrompt", () => { expect(prompt).toContain("Your working directory is: /workspace"); expect(prompt).toContain( - "For read/write/edit/apply_patch, file paths resolve against host workspace: /tmp/openclaw.", + "For read/write/edit/apply_patch, file paths resolve against host workspace: /tmp/openclaw. For bash/exec commands, use sandbox container paths under /workspace (or relative paths from that workdir), not host paths.", ); expect(prompt).toContain("Sandbox container workdir: /workspace"); - expect(prompt).toContain("Sandbox host workspace: /tmp/sandbox"); + expect(prompt).toContain( + "Sandbox host mount source (file tools bridge only; not valid inside sandbox exec): /tmp/sandbox", + ); expect(prompt).toContain("You are running in a sandboxed runtime"); expect(prompt).toContain("Sub-agents stay sandboxed"); expect(prompt).toContain("User can toggle with /elevated on|off|ask|full."); diff --git a/src/agents/system-prompt.ts b/src/agents/system-prompt.ts index 0c9fe921a33..5c7d312d459 100644 --- a/src/agents/system-prompt.ts +++ b/src/agents/system-prompt.ts @@ -366,7 +366,7 @@ export function buildAgentSystemPrompt(params: { : sanitizedWorkspaceDir; const workspaceGuidance = params.sandboxInfo?.enabled && sanitizedSandboxContainerWorkspace - ? `For read/write/edit/apply_patch, file paths resolve against host workspace: ${sanitizedWorkspaceDir}. Prefer relative paths so both sandboxed exec and file tools work consistently.` + ? `For read/write/edit/apply_patch, file paths resolve against host workspace: ${sanitizedWorkspaceDir}. For bash/exec commands, use sandbox container paths under ${sanitizedSandboxContainerWorkspace} (or relative paths from that workdir), not host paths. Prefer relative paths so both sandboxed exec and file tools work consistently.` : "Treat this directory as the single global workspace for file operations unless explicitly instructed otherwise."; const safetySection = [ "## Safety", @@ -488,7 +488,7 @@ export function buildAgentSystemPrompt(params: { ? `Sandbox container workdir: ${sanitizeForPromptLiteral(params.sandboxInfo.containerWorkspaceDir)}` : "", params.sandboxInfo.workspaceDir - ? `Sandbox host workspace: ${sanitizeForPromptLiteral(params.sandboxInfo.workspaceDir)}` + ? `Sandbox host mount source (file tools bridge only; not valid inside sandbox exec): ${sanitizeForPromptLiteral(params.sandboxInfo.workspaceDir)}` : "", params.sandboxInfo.workspaceAccess ? `Agent workspace access: ${params.sandboxInfo.workspaceAccess}${