> ## Documentation Index
> Fetch the complete documentation index at: https://docs.agno.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Local File System Tools

> Demonstrates local file system tools for reading from and writing to files.

Demonstrates local file system tools for reading from and writing to files. The agent can create files and read their contents using the local file system.

```python local_file_system_tools.py theme={null}
"""
Local File System Tools
========================

Demonstrates local file system tools for reading from and writing to files.
The agent can create files and read their contents using the local file system.
"""

from agno.agent import Agent
from agno.models.openai import OpenAIResponses
from agno.tools.local_file_system import LocalFileSystemTools

# ---------------------------------------------------------------------------
# Create Agents
# ---------------------------------------------------------------------------

# Example 1: Read and write files (default)
agent = Agent(
    model=OpenAIResponses(id="gpt-5.5"),
    tools=[LocalFileSystemTools(target_directory="tmp/local_file_system")],
    markdown=True,
)

# Example 2: Write-only mode (disable read_file)
write_only_agent = Agent(
    model=OpenAIResponses(id="gpt-5.5"),
    tools=[
        LocalFileSystemTools(
            target_directory="tmp/local_file_system", enable_read_file=False
        )
    ],
    markdown=True,
)

# ---------------------------------------------------------------------------
# Run Agent
# ---------------------------------------------------------------------------
if __name__ == "__main__":
    # Write a file and then read it back
    agent.print_response(
        "Write a short poem about programming to a file named poem.txt, then read it back to me.",
        stream=True,
    )

    # Write-only agent: generate code and save it to disk
    # write_only_agent.print_response(
    #     "Write a Python function that calculates fibonacci numbers and save it to tmp/local_file_system/fib.py",
    #     stream=True,
    # )
```

## Run the Example

<Steps>
  <Snippet file="create-venv-step.mdx" />

  <Step title="Install dependencies">
    ```bash theme={null}
    uv pip install -U agno openai
    ```
  </Step>

  <Step title="Export your OpenAI API key">
    <CodeGroup>
      ```bash Mac/Linux theme={null}
      export OPENAI_API_KEY="your_openai_api_key_here"
      ```

      ```bash Windows theme={null}
      $Env:OPENAI_API_KEY="your_openai_api_key_here"
      ```
    </CodeGroup>
  </Step>

  <Step title="Run the example">
    Save the code above as `local_file_system_tools.py`, then run:

    ```bash theme={null}
    python local_file_system_tools.py
    ```
  </Step>
</Steps>

Full source: [cookbook/91\_tools/local\_file\_system\_tools.py](https://github.com/agno-agi/agno/blob/main/cookbook/91_tools/local_file_system_tools.py)
