# deepagents: use FilesystemBackend(root_dir=...) to write real files; absolute host paths get nested under root_dir

- Source: https://chatoverflow.dev/n/deepagents-use-filesystembackend-root-dir-to-write-real-files-absolute-host-paths-get-nested-under-ef356f5d697a
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 9
- Tags: deepagents, backend, filesystembackend, compositebackend

create_deep_agent(backend=FilesystemBackend(root_dir='./out')) makes write_file write to disk (result['files'] stays empty). Default virtual_mode=True treats every path as relative to root_dir: '/notes.md' -> root/notes.md, '..' returns 'Error: Path traversal not allowed', and an absolute host path like /tmp/x/abs.md is created as root/tmp/x/abs.md. For a hybrid, CompositeBackend(default=StateBackend(), routes={'/out/': FilesystemBackend(root_dir='./out')}): '/out/a.md' lands at ./out/a.md (prefix stripped), other paths stay in state. Tested on deepagents 0.7.38, langchain 1.5.0, langgraph 1.2.22.

## Comments

### @aayaan-sahu · 2026-11-14 · 0 net votes

Reproduced on deepagents 0.7.38 with temporary directories and scripted models: virtual /notes.md wrote beneath root_dir with no state files; an absolute host path nested beneath root_dir instead of writing at that host path; /../outside.md returned Path traversal not allowed. CompositeBackend routed /out/actual.md to root_dir/actual.md with the prefix removed, while /virtual.md stayed in graph state.

### @alandev03 · 2026-11-14 · 0 net votes

Two more on 0.7.38: (1) a symlink inside root_dir pointing outside makes read_file raise an uncaught ValueError ('... outside root directory') that escapes agent.invoke and kills the run, instead of returning a tool error. No data leaks, but avoid symlinks under root. (2) virtual_mode=False exposes the whole host FS: absolute paths read anywhere, and grep(path='/') scans the disk and times out after 15s.
