<overview>
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
</overview>
<backend-selection>
</backend-selection>
<ex-default-state-backend>
<python>
Default StateBackend stores files ephemerally within a thread.
</python>
<typescript>
Default StateBackend stores files ephemerally within a thread.
</typescript>
</ex-default-state-backend>
<ex-composite-backend-for-hybrid>
<python>
Configure CompositeBackend to route paths to different storage backends.
</python>
<typescript>
Configure CompositeBackend to route paths to different storage backends.
</typescript>
</ex-composite-backend-for-hybrid>
<ex-cross-session-memory>
<python>
Files in /memories/ persist across threads via StoreBackend routing.
</python>
<typescript>
Files in /memories/ persist across threads via StoreBackend routing.
</typescript>
</ex-cross-session-memory>
<ex-filesystem-backend-local-dev>
<python>
Use FilesystemBackend for local development with real disk access and human-in-the-loop.
</python>
<typescript>
Use FilesystemBackend for local development with real disk access and human-in-the-loop.
</typescript>
Security: Never use FilesystemBackend in web servers - use StateBackend or sandbox instead.
</ex-filesystem-backend-local-dev>
<ex-store-in-custom-tools>
<python>
Access the store directly in custom tools for long-term memory operations.
</python>
</ex-store-in-custom-tools>
<boundaries>
What Agents CAN Configure
- Backend type and configuration
- Routing rules for CompositeBackend
- Root directory for FilesystemBackend
- Human-in-the-loop for file operations
What Agents CANNOT Configure
- 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
</boundaries>
<fix-storebackend-requires-store>
<python>
StoreBackend requires a store instance.
</python>
<typescript>
StoreBackend requires a store instance.
</typescript>
</fix-storebackend-requires-store>
<fix-statebackend-files-dont-persist>
<python>
StateBackend files are thread-scoped - use same thread_id or StoreBackend for cross-thread access.
</python>
<typescript>
StateBackend files are thread-scoped - use same thread_id or StoreBackend for cross-thread access.
</typescript>
</fix-statebackend-files-dont-persist>
<fix-path-prefix-for-persistence>
<python>
Path must match CompositeBackend route prefix for persistence.
</python>
<typescript>
Path must match CompositeBackend route prefix for persistence.
</typescript>
</fix-path-prefix-for-persistence>
<fix-production-store>
<python>
Use PostgresStore for production (InMemoryStore lost on restart).
</python>
<typescript>
Use PostgresStore for production (InMemoryStore lost on restart).
</typescript>
</fix-production-store>
<fix-filesystem-backend-needs-virtual-mode>
<python>
Enable virtual_mode=True to restrict path access (prevents ../ and ~/ escapes).
</python>
</fix-filesystem-backend-needs-virtual-mode>
<fix-longest-prefix-match>
<python>
CompositeBackend matches longest prefix first.
</python>
</fix-longest-prefix-match>


