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 Agent
2from kern.context.fs import FilesystemContextProvider
3
4fs = FilesystemContextProvider(root="./docs")
5
6agent = Agent(
7 model=...,
8 tools=fs.get_tools(),
9)
10
11agent.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

ParameterTypeDefaultDescription
rootstr | PathrequiredDirectory to scope the provider to.
idstr"fs"Tool becomes query_<id>.
exclude_patternslist[str]NoneGlob patterns to exclude (e.g., ["*.pyc", "__pycache__"]).
modelModelNoneModel for the sub-agent.
modeContextModedefaultdefault or agent expose query_fs. tools exposes raw FileTools.

Tools Exposed

ToolDescription
query_fsSearch files, read content, list directory structure. Read-only.
Note

FilesystemContextProvider is read-only. There is no update_fs tool.

Example queries

QueryWhat 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

Resources