Deep Agents use pluggable backends for file operations and memory:
Short-term (StateBackend): Persists within a single thread, lost when thread ends
Long-term (StoreBackend): Persists across threads and sessions
Hybrid (CompositeBackend): Route different paths to different backends
FilesystemMiddleware provides tools: ls, read_file, write_file, edit_file, glob, grep
| Use Case | Backend | Why |
|---|
| Temporary working files | StateBackend | Default, no setup |
| Local development CLI | FilesystemBackend | Direct disk access |
| Cross-session memory | StoreBackend | Persists across threads |
| Hybrid storage | CompositeBackend | Mix ephemeral + persistent |
Default StateBackend stores files ephemerally within a thread.
Default StateBackend stores files ephemerally within a thread.
Configure CompositeBackend to route paths to different storage backends.
Configure CompositeBackend to route paths to different storage backends.
Files in /memories/ persist across threads via StoreBackend routing.
Files in /memories/ persist across threads via StoreBackend routing.
Use FilesystemBackend for local development with real disk access and human-in-the-loop.
Use FilesystemBackend for local development with real disk access and human-in-the-loop.
Security: Never use FilesystemBackend in web servers - use StateBackend or sandbox instead.
Access the store directly in custom tools for long-term memory operations.
### What Agents CAN Configure
- Backend type and configuration
- Routing rules for CompositeBackend
- Root directory for FilesystemBackend
- Human-in-the-loop for file operations
- Tool names (ls, read_file, write_file, edit_file, glob, grep)
- Access files outside virtual_mode restrictions
- Cross-thread file access without proper backend setup
StoreBackend requires a store instance.
StoreBackend requires a store instance.
StateBackend files are thread-scoped - use same thread_id or StoreBackend for cross-thread access.
StateBackend files are thread-scoped - use same thread_id or StoreBackend for cross-thread access.
Path must match CompositeBackend route prefix for persistence.
Path must match CompositeBackend route prefix for persistence.
Use PostgresStore for production (InMemoryStore lost on restart).
Use PostgresStore for production (InMemoryStore lost on restart).
Enable virtual_mode=True to restrict path access (prevents ../ and ~/ escapes).
CompositeBackend matches longest prefix first.