Skip to content

Add filesystem tools for AI agents#651

Open
pushpak1300 wants to merge 1 commit into
0.xfrom
add_filesystem_tools
Open

Add filesystem tools for AI agents#651
pushpak1300 wants to merge 1 commit into
0.xfrom
add_filesystem_tools

Conversation

@pushpak1300
Copy link
Copy Markdown
Member

@pushpak1300 pushpak1300 commented May 22, 2026

Currently there's no built-in way to give an agent access to a Laravel filesystem disk. If you want an agent that can browse, read, or manage files on a Storage disk, you have to hand-roll a Tool for every operation.

This PR adds a set of Storage-backed tools (modeled on files-sdk) and a FileStorageTools factory, so you can hand a set to an agent:

use Laravel\Ai\Tools\FileStorageTools;

public function tools(): iterable
{
    return FileStorageTools::all('local');       // all 8 tools
    // return FileStorageTools::readOnly('local'); // just the 5 read-only tools
}

Both return a Collection, so you can narrow further:

FileStorageTools::all('s3')->reject(fn ($t) => $t instanceof DeleteFile);

Every tool takes a disk name or Filesystem instance (default disk if omitted), so you can sandbox an agent to a folder with Laravel's scoped driver and it cannot escape it. Tools are #[Strict], descriptions are written for tool-calling, and there are end to end tests (agent prompt to real disk side effect) using Storage::fake().

@pushpak1300 pushpak1300 marked this pull request as ready for review May 22, 2026 19:39
@peterjthomson
Copy link
Copy Markdown

Makes a lot of sense to give agents (bounded) file system access. Also rounds out the previously confusing difference between giving agents:
Database Access (query builder, eloquent or schema)
Embedding Access (create vector embedding "file" from models, upload to vector "file" store, and search/access vector "file")
File Access (this PR)

@pushpak1300 pushpak1300 force-pushed the add_filesystem_tools branch from bdc788c to a8a35aa Compare May 23, 2026 09:25
@pushpak1300 pushpak1300 requested a review from taylorotwell May 23, 2026 09:27
@danielhe4rt
Copy link
Copy Markdown

I kinda liked and it would replace a few agents which I build myself.

But I also would like to see some concrete usage examples in the docs. In the future, would be good to have another page in Laravel Docs with explicit tools and how to use it, like we have to Arr/Helpers etc.

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.

3 participants