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.csvbecomesagent-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:
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
Deletefor read-only agentsDisable
CreateandString Replacefor analysis-only agentsDisable
Upload from URLif 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 directorystart_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 createdcontent(string, required): Content to write to the filereplace(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 editold_str(string, required): Exact string to find (must appear exactly once)new_str(string, required): Replacement string
Behavior:
Searches for exact match of
old_strFails if
old_strappears 0 times (not found)Fails if
old_strappears 2+ times (ambiguous match)Use
\nfor newlines in multi-line replacementsOnly 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 editline(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=1to insert at the beginningAutomatically 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 directorynew_path(string, required): New path (can be in a different directory)
Behavior:
Can rename in place:
notes.txt→readme.txtCan move to different directory:
notes.txt→docs/notes.txtCan move and rename:
old/file.txt→new/renamed.txtAutomatically 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 fromfile_path(string, required): Where to save the downloaded file in Drivereplace(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
Path Validation
No path traversal (
..) allowedNo backslashes (Windows-style paths) allowed
No null bytes allowed
Working Directory Isolation
Enforces subfolder restrictions
Prevents access outside designated directory
Automatically prefixes all paths
Best Practices
Use Working Directories for Multi-Agent Systems
Organize Files in Logical Folders
Use Descriptive File Names
Leverage replace=False to Prevent Overwrites
Handle Large Files Efficiently
⚠️ Important Limitations
Drive vs Code Execution Sandbox
Drive storage is completely separate from the code execution 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_lineandend_lineparameters to view in chunks
Path Restrictions
Must use forward slashes:
folder/file.txtNo leading slash needed:
data.csvnot/data.csvPath
.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?