Skip to content

Conversation

@DEENUU1
Copy link

@DEENUU1 DEENUU1 commented Nov 29, 2025

Summary

Add new FileSystemToolset that allows agents to access the local file system with security controls.

Features

  • Operations: read, write, list, info, search, delete
  • Security controls:
    • allowed_paths - restrict access to specific directories
    • allow_write / allow_delete - control write/delete permissions
    • max_file_size - limit readable file size
    • allowed_extensions - filter by file extensions
  • Path traversal protection (prevents ../ attacks)

Usage

from pydantic_ai import Agent
from pydantic_ai.toolsets import FileSystemToolset

agent = Agent(
    'openai:gpt-4.1',
    toolsets=[
        FileSystemToolset(
            allowed_paths=['/home/user/data'],
            allow_write=True,
            allowed_extensions=['.txt', '.json'],
        ),
    ],
)

Also available as FileSystemTool builtin tool configuration:

from pydantic_ai import Agent
from pydantic_ai.builtin_tools import FileSystemTool

agent = Agent(
    'openai:gpt-4.1',
    builtin_tools=[
        FileSystemTool(
            allowed_paths=['/home/user/data'],
        ),
    ],
)

Test plan

  • Path validation tests (allowed paths, traversal attacks, cwd restriction)
  • Extension filtering tests
  • Operation permission tests (read, write, delete)
  • File size limit tests
  • All file operations (read, write, list, info, search, delete)
  • Tool definition generation tests
  • Edge cases and error handling
  • ToolManager integration test
  • 100% coverage for filesystem.py

  - Add FileSystemToolset with read, write, list, info, search, delete operations
  - Add security controls: allowed_paths, allow_write, allow_delete, max_file_size, allowed_extensions
  - Add FileSystemTool builtin tool configuration
  - Add comprehensive tests with 100% coverage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant