StoreBackend¶
StoreBackend
¶
Bases: BackendProtocol
Backend that stores files in LangGraph's BaseStore (persistent).
Uses LangGraph's Store for persistent, cross-conversation storage. Files are organized via namespaces and persist across all threads.
The namespace can include an optional assistant_id for multi-agent isolation.
| METHOD | DESCRIPTION |
|---|---|
__init__ |
Initialize StoreBackend with runtime. |
ls_info |
List files and directories in the specified directory (non-recursive). |
read |
Read file content with line numbers. |
aread |
Async version of read using native store async methods. |
write |
Create a new file with content. |
awrite |
Async version of write using native store async methods. |
edit |
Edit a file by replacing string occurrences. |
aedit |
Async version of edit using native store async methods. |
grep_raw |
Search for a literal text pattern in files. |
glob_info |
Find files matching a glob pattern. |
upload_files |
Upload multiple files to the store. |
download_files |
Download multiple files from the store. |
als_info |
Async version of ls_info. |
agrep_raw |
Async version of grep_raw. |
aglob_info |
Async version of glob_info. |
aupload_files |
Async version of upload_files. |
adownload_files |
Async version of download_files. |
__init__
¶
Initialize StoreBackend with runtime.
| PARAMETER | DESCRIPTION |
|---|---|
runtime
|
The ToolRuntime instance providing store access and configuration.
TYPE:
|
ls_info
¶
List files and directories in the specified directory (non-recursive).
| PARAMETER | DESCRIPTION |
|---|---|
path
|
Absolute path to directory.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[FileInfo]
|
List of FileInfo-like dicts for files and directories directly in the directory. |
list[FileInfo]
|
Directories have a trailing / in their path and is_dir=True. |
read
¶
Read file content with line numbers.
| PARAMETER | DESCRIPTION |
|---|---|
file_path
|
Absolute file path.
TYPE:
|
offset
|
Line offset to start reading from (0-indexed).
TYPE:
|
limit
|
Maximum number of lines to read.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
Formatted file content with line numbers, or error message. |
aread
async
¶
Async version of read using native store async methods.
This avoids sync calls in async context by using store.aget directly.
write
¶
Create a new file with content. Returns WriteResult. External storage sets files_update=None.
awrite
async
¶
Async version of write using native store async methods.
This avoids sync calls in async context by using store.aget/aput directly.
edit
¶
Edit a file by replacing string occurrences. Returns EditResult. External storage sets files_update=None.
aedit
async
¶
Async version of edit using native store async methods.
This avoids sync calls in async context by using store.aget/aput directly.
grep_raw
¶
Search for a literal text pattern in files.
| PARAMETER | DESCRIPTION |
|---|---|
pattern
|
Literal string to search for (NOT regex). Performs exact substring matching within file content. Example: "TODO" matches any line containing "TODO"
TYPE:
|
path
|
Optional directory path to search in. If None, searches in current working directory. Example: "/workspace/src"
TYPE:
|
glob
|
Optional glob pattern to filter which FILES to search.
Filters by filename/path, not content.
Supports standard glob wildcards:
-
TYPE:
|
Examples:
- "*.py" - only search Python files
- "**/*.txt" - search all .txt files recursively
- "src/**/*.js" - search JS files under src/
- "test[0-9].txt" - search test0.txt, test1.txt, etc.
| RETURNS | DESCRIPTION |
|---|---|
list[GrepMatch] | str
|
On success: list[GrepMatch] with structured results containing: - path: Absolute file path - line: Line number (1-indexed) - text: Full line content containing the match |
list[GrepMatch] | str
|
On error: str with error message (e.g., invalid path, permission denied) |
glob_info
¶
Find files matching a glob pattern.
| PARAMETER | DESCRIPTION |
|---|---|
pattern
|
Glob pattern with wildcards to match file paths.
Supports standard glob syntax:
-
TYPE:
|
path
|
Base directory to search from. Default: "/" (root). The pattern is applied relative to this path.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[FileInfo]
|
list of FileInfo |
upload_files
¶
download_files
¶
agrep_raw
async
¶
agrep_raw(
pattern: str, path: str | None = None, glob: str | None = None
) -> list[GrepMatch] | str
Async version of grep_raw.
aglob_info
async
¶
Async version of glob_info.
aupload_files
async
¶
Async version of upload_files.