PRAISONAI_WORKSPACE and the glob_files, grep_search, and multiedit tools reject any directory= outside that real path.
Quick Start
1
Set the workspace root
Export
PRAISONAI_WORKSPACE, then hand the file tools to an agent — searches stay inside the project:2
No workspace set
Without
PRAISONAI_WORKSPACE, no sandbox is enforced — the tools search wherever directory= points:How It Works
Confinement is opt-in. WithoutPRAISONAI_WORKSPACE set, no sandbox is enforced — the previous cwd() “boundary” was never real, and enforcing it broke callers passing an explicit directory (see PraisonAI 86dd01a). When set, all three tools reject a directory= whose real path is not under the workspace root:
os.path.realpath + os.path.commonpath, so symlinks pointing out of the workspace are rejected too.
Protected-path filtering
Inside the workspace, protected files are still hidden, skipped, or refused:
See Protected Paths for the full list of protected targets.
Grep ReDoS bound
grep_search caps each line at _MAX_LINE = 100_000 characters and silently skips anything longer. The stdlib re module has no timeout, so a pathological line like aaaa…! can pin a CPU under a crafted regex — skipping over-long lines bounds that risk.
Configuration Options
PRAISONAI_WORKSPACE is the single switch that turns confinement on.
Common Patterns
Confine a code-exploration agent
Explain a refused search to the user
Best Practices
Set PRAISONAI_WORKSPACE for untrusted prompts
Set PRAISONAI_WORKSPACE for untrusted prompts
When an agent acts on user-supplied instructions, set
PRAISONAI_WORKSPACE to the project root so a crafted directory= can’t reach /etc or a home directory.Leave it unset for trusted CLI runs
Leave it unset for trusted CLI runs
Local scripts that intentionally search arbitrary directories should leave
PRAISONAI_WORKSPACE unset — enforcing a sandbox would reject their explicit directory= inputs.Combine with protected paths
Combine with protected paths
Workspace confinement bounds where tools look; protected paths bound what they touch inside. Use both — protected-path filtering still applies within the workspace.
Trust the ReDoS cap
Trust the ReDoS cap
grep_search skips lines over 100,000 characters. If a legitimate file has very long lines, split it or search a narrower pattern rather than removing the cap.Related
Protected Paths
Block agents from reading or writing sensitive files.
Workspace Boundary
Approval-gate on external paths — a different mechanism from env-var confinement.
Workspace Isolation
Per-agent workspace isolation.

