Filesystem
Read files from a scoped local directory.
Read files from a scoped local directory. The provider exposes one tool: query_fs for searching and reading files.
1from kern.agent import Agent2from kern.context.fs import FilesystemContextProvider34fs = FilesystemContextProvider(root="./docs")56agent = Agent(7 model=...,8 tools=fs.get_tools(),9)1011agent.print_response("What topics are covered in the documentation?")The agent calls query_fs("documentation topics"). A sub-agent handles file listing, searching, and reading.
Configuration
| Parameter | Type | Default | Description |
|---|---|---|---|
root | str | Path | required | Directory to scope the provider to. |
id | str | "fs" | Tool becomes query_<id>. |
exclude_patterns | list[str] | None | Glob patterns to exclude (e.g., ["*.pyc", "__pycache__"]). |
model | Model | None | Model for the sub-agent. |
mode | ContextMode | default | default or agent expose query_fs. tools exposes raw FileTools. |
Tools Exposed
| Tool | Description |
|---|---|
query_fs | Search files, read content, list directory structure. Read-only. |
Note
FilesystemContextProvider is read-only. There is no update_fs tool.
Example queries
| Query | What happens |
|---|---|
| "What files are in this project?" | Lists directory structure |
| "Find all Python files that import requests" | Searches file content |
| "Read the README" | Returns file content |