Skip to content

fix(gateway): preview sandbox skill files mounted from outside the session root - #7

Merged
tomorrowflow merged 2 commits into
mainfrom
fix/sandbox-mounted-file-preview
Sep 26, 2026
Merged

tomorrowflow merged 2 commits into
mainfrom
fix/sandbox-mounted-file-preview

Conversation

@tomorrowflow

Copy link
Copy Markdown
Owner

Problem

Chat from a sandboxed agent links skill files by their container path, for example /workspace/.openclaw/sandbox-skills/skills/kleinanzeigen-publish-onedrive/SKILL.md. The Control UI shows the link, but clicking it gives "session file not found".

The fix from e0e95c9 translates container paths through the sandbox mount table. It only helped when the mount source sits inside the session root. Materialized skills live in ~/.openclaw/sandbox/skills-workspaces/workspace-<hash>/. The workspace only has an empty folder where they are mounted, so the root check rejected the translated path.

A second gap showed up after the first deploy. When no sandbox container is registered, the Gateway derives the mount table from config, and that happens after every deploy recreates the sandboxes. The derived table was built without skillsWorkspaceDir, so the skills mount pointed at the empty folder in the workspace.

Solution

  • getSessionWorkspaceFile gets a fallback for when the session-root lookup misses. It resolves the container path to its mount (resolveSandboxContainerPathMount), opens that mount's host root with the same fs-safe reader, and returns a read-only entry (no hash, no workspacePath).
  • The fallback applies only to mounts whose source is under SANDBOX_STATE_DIR. Custom docker.binds are excluded because their sources are daemon-host paths, so a Gateway-local path with the same name could be a different file. Secret mounts are not in the mount table.
  • resolveSessionSandboxPaths resolves the sandbox layout once. It passes the layout's scope key to the registry lookup and its skillsWorkspaceDir to deriveSandboxContainerMounts.
  • sessions.files.set is unchanged, so writes still stay inside the session root.
  • The fork-features checklist has entries for both call sites.

Evidence

  • Live repro before the fix: openclaw gateway call sessions.files.get returned "session file not found" for the SKILL.md path, while /workspace/AGENTS.md opened.
  • Live after deploying 3aba99b: SKILL.md returns 11,562 bytes of text with no hash. /workspace/AGENTS.md still opens. /run/secrets/GH_TOKEN and /media are still refused.
  • Tests: in sessions-files.sandbox-paths.test.ts, the new skills test runs with no registered container. It fails on the previous source and passes now. The new custom-bind guard fails when the state-dir gate is removed. All 93 tests in the 5 session-files suites pass.
  • Test cost: the whole file takes about 25 s wall with --maxWorkers=1, mostly startup; each new case runs in under 15 ms.
  • Typecheck: pnpm tsgo:core is clean. check-fork-features: 71 present.
  • Known unrelated failure: check-changed fails on the config-docs baseline drift.

🤖 Generated with Claude Code

tomorrowflow and others added 2 commits September 25, 2026 23:45
…ssion root

A sandboxed agent links materialized skills by container path, e.g.
/workspace/.openclaw/sandbox-skills/skills/<skill>/SKILL.md. The mount
table translates that to ~/.openclaw/sandbox/skills-workspaces/<scope>/...,
but that source is outside the session root; the workspace only holds the
empty mountpoint. Root containment rejected the file and the Control UI
answered "session file not found" for a link it had just rendered.

When the root lookup misses, sessions.files.get now opens the backing
mount's own host root through the same fs-safe reader, for mounts sourced
from the Gateway-owned sandbox state dir only. Custom binds are excluded:
their sources are daemon-host paths and a same-named Gateway-local path
could be a different file. The entry has no hash or workspacePath, so the
UI shows it read-only; sessions.files.set is unchanged.

The positive case fails on the previous source; the custom-bind guard
fails when the state-dir gate is removed.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…reviews

With no registered container, as after every deploy recreates sandboxes,
sessions.files derived the mount table without the materialized skills
workspace. The skills mount then fell back to the empty scaffold inside
the workspace, so skill links still answered "session file not found"
on the live Gateway after the previous fix.

Resolve the sandbox layout once and pass its scope key to the registry
lookup and its skillsWorkspaceDir to the derived mapping, matching what
the runtime mounts. The regression test now runs without a registered
container and fails on the previous source.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
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.

1 participant