Drive Storage Tools

📦 Persistent Cloud Storage for Agents

Drive Storage Tools provide agents with persistent, cloud-based file system capabilities that survive across all agent sessions and turns. Unlike temporary code execution sandboxes, Drive storage maintains files indefinitely until explicitly deleted.

Key Features

  • Persistent Storage: Files remain available across all agent sessions

  • Workspace Isolation: Each agent has private, isolated storage within its project

  • Working Directory Scoping: Optionally restrict operations to specific subfolders

  • Cloud-Based: All files are stored in secure cloud storage

  • Full CRUD Operations: Create, read, update, delete, rename, and organize files

  • URL Upload: Download files from internet URLs directly to Drive storage

  • Binary File Support: Handle images, PDFs, and other binary formats with download URLs


⚙️ Configuration Options

Enable Drive Storage

Toggle to activate Drive storage tools for your agent:

  • Enabled: Agent can create, read, modify, and organize files in Drive storage

  • Disabled: Agent has no access to persistent file storage

Working Directory (Optional)

Restrict all file operations to a specific subfolder:

Example Configuration:

Behavior:

  • Agent can only access files within agent-workspace/

  • Paths are automatically scoped (e.g., data.csv becomes agent-workspace/data.csv)

  • Prevents agents from accessing files outside their designated folder

  • Empty path operates on the working directory itself

Use Cases:

  • Multi-agent systems where each agent needs isolated storage

  • Security isolation to prevent cross-contamination

  • Organized project structure with dedicated agent folders

Individual Tool Permissions

Control which specific file operations the agent can perform:

Tool
Description
Default

View

Read file contents or list directory contents

 Enabled

Create

Create new files or overwrite existing files

 Enabled

String Replace

Replace exact string matches in files

 Enabled

Insert

Insert content at specific line numbers

 Enabled

Delete

Delete files or directories

 Enabled

Rename

Rename or move files/directories

 Enabled

Upload from URL

Download files from URLs to Drive storage

 Enabled

Permission Settings:

  • Allowed: Tool is available to the agent

  • Not Allowed: Tool is hidden and cannot be used

Security Considerations:

  • Disable Delete for read-only agents

  • Disable Create and String Replace for analysis-only agents

  • Disable Upload from URL if external downloads are not needed


🔧 Available Drive Tools

1. View (_drive_view)

Purpose: Read file contents or list directory contents

Parameters:

  • file_path (string, required): Path to file or directory

  • start_line (integer, optional): First line to display (1-indexed, for text files)

  • end_line (integer, optional): Last line to display (inclusive, for text files)

Behavior:

  • Text Files: Returns content with line numbers (max 500 lines per view)

  • Binary Files: Returns download URL (images, PDFs, archives, etc.)

  • Directories: Lists all files and subdirectories, one per line

  • Empty Directories: Returns "(empty directory)"

Examples:


2. Create (_drive_create)

Purpose: Create new files or overwrite existing files

Parameters:

  • file_path (string, required): Path where file should be created

  • content (string, required): Content to write to the file

  • replace (boolean, optional, default: False): Allow overwriting existing files

Behavior:

  • Automatically creates parent directories if they don't exist

  • Fails if file exists and replace=False (prevents accidental overwrites)

  • Supports any text-based content (JSON, CSV, TXT, code files, etc.)

Examples:


3. String Replace (_drive_str_replace)

Purpose: Replace an exact string match in a file

Parameters:

  • file_path (string, required): Path to the file to edit

  • old_str (string, required): Exact string to find (must appear exactly once)

  • new_str (string, required): Replacement string

Behavior:

  • Searches for exact match of old_str

  • Fails if old_str appears 0 times (not found)

  • Fails if old_str appears 2+ times (ambiguous match)

  • Use \n for newlines in multi-line replacements

  • Only replaces first occurrence (enforced uniqueness)

Examples:


4. Insert (_drive_insert)

Purpose: Insert content at a specific line number

Parameters:

  • file_path (string, required): Path to the file to edit

  • line (integer, required): Line number where content should be inserted (1-indexed)

  • content (string, required): Text to insert

Behavior:

  • Line numbers are 1-indexed (line 1 is the first line)

  • Content is inserted before the specified line

  • Use line=1 to insert at the beginning

  • Automatically adds newline if inserting in the middle of the file

Examples:


5. Delete (_drive_delete)

Purpose: Delete files or directories

Parameters:

  • file_path (string, required): Path to file or directory to delete

Behavior:

  • Files: Deleted immediately

  • Directories: Recursively deletes all contents

  • Permanent for agent: Agent cannot recover deleted items

Examples:


6. Rename (_drive_rename)

Purpose: Rename files/directories or move them to different locations

Parameters:

  • old_path (string, required): Current path of the file or directory

  • new_path (string, required): New path (can be in a different directory)

Behavior:

  • Can rename in place: notes.txtreadme.txt

  • Can move to different directory: notes.txtdocs/notes.txt

  • Can move and rename: old/file.txtnew/renamed.txt

  • Automatically creates parent directories if needed

Examples:


7. Upload from URL (_drive_upload_from_url)

Purpose: Download files from internet URLs and save to Drive storage

Parameters:

  • url (string, required): HTTP/HTTPS URL to download from

  • file_path (string, required): Where to save the downloaded file in Drive

  • replace (boolean, optional, default: False): Allow overwriting existing files

Behavior:

  • Supports HTTP and HTTPS URLs only

  • SSRF Prevention: Blocks private IP addresses and localhost

  • Maximum download timeout: 60 seconds

  • Preserves original MIME type from download

  • Fails if file exists and replace=False

Examples:


📋 Typical Agent Workflows

Workflow 1: Data Processing Pipeline

Workflow 2: Configuration Management

Workflow 3: Report Generation


🔒 Security & Best Practices

Security Features

  1. Path Validation

    • No path traversal (..) allowed

    • No backslashes (Windows-style paths) allowed

    • No null bytes allowed

  2. Working Directory Isolation

    • Enforces subfolder restrictions

    • Prevents access outside designated directory

    • Automatically prefixes all paths

Best Practices

  1. Use Working Directories for Multi-Agent Systems

  2. Organize Files in Logical Folders

  3. Use Descriptive File Names

  4. Leverage replace=False to Prevent Overwrites

  5. Handle Large Files Efficiently


⚠️ Important Limitations

Drive vs Code Execution Sandbox

Drive storage is completely separate from the code execution sandbox:

Feature
Drive Storage
Code Sandbox

Persistence

Permanent (until deleted)

Temporary (deleted after turn)

Access Tools

_drive_* tools

_code_* tools

File Transfer

Requires explicit upload/download

Direct file system access

Survival

Survives all sessions

Cleared every turn

To Use Drive Files in Code Execution:

File Size Considerations

  • View Tool: 500-line limit per view operation (prevents context overflow)

  • Binary Files: Not loaded into context; download URLs provided instead

  • Large Text Files: Use start_line and end_line parameters to view in chunks

Path Restrictions

  • Must use forward slashes: folder/file.txt

  • No leading slash needed: data.csv not /data.csv

  • Path . or "" refers to root (or working directory if configured)

  • Working directory paths are automatically prefixed


💼 Use Cases by Agent Type

Data Analysis Agents

Recommended Configuration:

  •  Enable: View, Create, String Replace, Rename, Upload from URL

  • L Disable: Delete (preserve all data)

  • Working Directory: data-analysis/

Workflow: Download datasets, process data, generate reports, organize results


Content Management Agents

Recommended Configuration:

  •  Enable: All tools

  • Working Directory: content/

Workflow: Create articles, update documentation, organize media files, archive old content


Configuration Management Agents

Recommended Configuration:

  •  Enable: View, String Replace, Create (with replace=True)

  • L Disable: Delete, Rename (prevent structure changes)

  • Working Directory: configs/

Workflow: Read configurations, update settings, maintain version history


Read-Only Audit Agents

Recommended Configuration:

  •  Enable: View only

  • L Disable: All modification tools

  • Working Directory: audit-logs/

Workflow: Read logs, analyze data, generate audit reports without modification


File Organization Agents

Recommended Configuration:

  •  Enable: View, Rename, Delete, Create

  • L Disable: String Replace, Insert (no content editing)

  • Working Directory: None (full access)

Workflow: Organize files, clean up old data, maintain folder structure


💡 Tips & Tricks

1. Check Before Creating

2. Incremental File Building

3. Safe Configuration Updates

4. Batch Organization


Last updated

Was this helpful?