Local File System
LocalFileSystemTools enables agents to write files to the local file system with automatic directory management.
Example
The following agent can write content to local files:
1from kern.agent import Agent2from kern.tools.local_file_system import LocalFileSystemTools34agent = Agent(5 instructions=[6 "You are a file management assistant that helps save content to local files",7 "Create files with appropriate names and extensions",8 "Organize files in the specified directory structure",9 "Provide clear feedback about file operations",10 ],11 tools=[LocalFileSystemTools(target_directory="./output")],12)1314agent.print_response("Save this meeting summary to a file: 'Discussed Q4 goals and budget allocation'", stream=True)Toolkit Params
| Parameter | Type | Default | Description |
|---|---|---|---|
target_directory | Optional[str] | None | Default directory to write files to. Uses current directory. |
default_extension | str | "txt" | Default file extension to use if none specified. |
enable_write_file | bool | True | Enable file writing functionality. |
Toolkit Functions
| Function | Description |
|---|---|
write_file | Write content to a local file with customizable options. |