Skip to content

Fix: Fallback to workspace when exec cwd is outside allowed directories#828

Merged
FL4TLiN3 merged 2 commits intomainfrom
fix/exec-cwd-fallback
Mar 25, 2026
Merged

Fix: Fallback to workspace when exec cwd is outside allowed directories#828
FL4TLiN3 merged 2 commits intomainfrom
fix/exec-cwd-fallback

Conversation

@FL4TLiN3
Copy link
Contributor

Summary

  • When the LLM passes an invalid cwd to the exec tool (e.g. /home/user), fall back to the workspace path instead of throwing an access denied error
  • This allows installed commands like pab, npm, npx, agent-browser to execute regardless of what cwd the model chooses
  • File read/write/edit path validation remains strict (unchanged)

Changes

  • apps/base/src/tools/exec.ts — Extract resolveCwd() that tries validatePath() and falls back to workspacePath
  • apps/base/src/tools/exec.test.ts — Add test for fallback behavior

Test plan

  • Existing exec tests pass (8/8)
  • New fallback test passes — exec with cwd: "/home/user" succeeds by falling back to workspace

🤖 Generated with Claude Code

FL4TLiN3 and others added 2 commits March 25, 2026 21:43
Instead of throwing an error when the LLM passes an invalid cwd (e.g.
/home/user), fall back to the workspace path. This allows installed
commands like pab, npm, and agent-browser to execute even when the model
picks a bad working directory.

File read/write/edit path validation remains strict.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@FL4TLiN3 FL4TLiN3 force-pushed the fix/exec-cwd-fallback branch from 9525d6d to bc03d64 Compare March 25, 2026 21:43
@FL4TLiN3 FL4TLiN3 merged commit beac1ef into main Mar 25, 2026
11 checks passed
@FL4TLiN3 FL4TLiN3 deleted the fix/exec-cwd-fallback branch March 25, 2026 21:45
@FL4TLiN3 FL4TLiN3 mentioned this pull request Mar 25, 2026
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