Persistent file storage and management for agent workflows
Agent file systems provide persistent, isolated storage that survives across sessions, enabling complex workflows with data persistence and file management.
The File System primitive gives agents the ability to create, read, write, and manage files within their execution environment. Each agent session has access to a complete Linux file system with persistent storage, allowing agents to:
Store Data: Save files, datasets, configurations, and artifacts
Process Files: Read, modify, and transform file contents
Organize Content: Create directory structures and manage file hierarchies
Persist State: Maintain files across multiple requests in the same session
Generate Outputs: Create reports, code files, images, and other deliverables
Full Read/Write Access
Complete file system operations - create, read, update, delete files and directories
10GB Storage
Each session gets 10GB of persistent disk space
Session Persistence
Files remain available across all requests in the same session
Automatic Management
Agents handle file operations automatically based on your instructions
// Agent automatically uses str_replace_editorconst result = await agentbase.runAgent({ message: "Create a file called config.json with database settings"});
bash - File Operations
Shell commands for file manipulation:
Copy: cp source dest
Move: mv source dest
Delete: rm file
List: ls -la
Permissions: chmod, chown
Copy
const result = await agentbase.runAgent({ message: "Copy all .txt files to the backup folder"});
glob - File Search by Pattern
Find files matching patterns:
Pattern matching: *.js, **/*.ts
Recursive search: **/test/*.py
Multiple patterns: {*.json,*.yaml}
Copy
const result = await agentbase.runAgent({ message: "Find all Python files in the project"});
grep - Content Search
Search for text within files:
Regex patterns: grep "pattern" file
Recursive search: grep -r "pattern" .
Case-insensitive: grep -i "pattern"
Copy
const result = await agentbase.runAgent({ message: "Find all TODO comments in the codebase"});
// Create a single fileconst result = await agentbase.runAgent({ message: "Create a file called hello.py with a simple hello world program"});// Create multiple filesconst multi = await agentbase.runAgent({ message: "Create a React project structure with App.js, index.js, and package.json"});// Create file with specific contentconst config = await agentbase.runAgent({ message: `Create config.json with this content: { "apiKey": "xxx", "endpoint": "https://api.example.com" }`});
// Read file contentsconst read = await agentbase.runAgent({ message: "Read the contents of data.csv and summarize it"});// Read multiple filesconst readMulti = await agentbase.runAgent({ message: "Read all .md files in the docs folder and create a table of contents"});// Read and processconst process = await agentbase.runAgent({ message: "Read config.json and validate all required fields are present"});
// Edit existing fileconst edit = await agentbase.runAgent({ message: "Update the version number in package.json to 2.0.0", session: existingSession});// Find and replaceconst replace = await agentbase.runAgent({ message: "Replace all instances of 'oldFunction' with 'newFunction' in src/utils.js", session: existingSession});// Append to fileconst append = await agentbase.runAgent({ message: "Add a new route to routes.js for the profile page", session: existingSession});
// Create directory structureconst structure = await agentbase.runAgent({ message: "Create folders for src, tests, and docs"});// Move filesconst organize = await agentbase.runAgent({ message: "Move all .js files to the src folder", session: structure.session});// Copy with organizationconst backup = await agentbase.runAgent({ message: "Create a backup folder and copy all important files there", session: structure.session});
// Find files by patternconst find = await agentbase.runAgent({ message: "Find all TypeScript files in the project"});// Search contentconst search = await agentbase.runAgent({ message: "Search for all files containing 'API_KEY'"});// Complex searchconst complexSearch = await agentbase.runAgent({ message: "Find all Python test files that import the requests library"});
Generate complete projects with proper file organization:
Copy
const project = await agentbase.runAgent({ message: `Create a FastAPI project with: - main.py with basic setup - requirements.txt with dependencies - .env.example for configuration - README.md with setup instructions - tests/test_main.py with sample tests`});// All files persist in the session
// Step 1: Upload data (in practice, you'd create the file)const upload = await agentbase.runAgent({ message: "Create a sample sales_data.csv with 100 rows of sales data"});// Step 2: Processconst process = await agentbase.runAgent({ message: "Analyze sales_data.csv and create a summary report as report.md", session: upload.session});// Step 3: Visualizeconst viz = await agentbase.runAgent({ message: "Create a Python script to visualize the data and save charts as images", session: upload.session});// All files (CSV, report, scripts, charts) persist
const config = await agentbase.runAgent({ message: `Create configuration files for dev, staging, and prod environments: - config/dev.json - config/staging.json - config/prod.json Each should have appropriate API endpoints and settings`});// Later, update configsconst update = await agentbase.runAgent({ message: "Update the prod config to use the new API endpoint", session: config.session});
const docs = await agentbase.runAgent({ message: `Read all Python files in src/ and generate API documentation: - docs/api.md with function signatures - docs/examples.md with usage examples - docs/index.md as main entry point`});
const transform = await agentbase.runAgent({ message: "Convert data.json to CSV format and save as data.csv"});const convert = await agentbase.runAgent({ message: "Read all markdown files and convert them to HTML", session: transform.session});
// Good: Clear, descriptive namesconst result = await agentbase.runAgent({ message: "Create customer_analysis_report.md"});// Avoid: Generic or unclear namesconst result = await agentbase.runAgent({ message: "Create file1.txt"});
Organize into Directories
Copy
// Good: Organized structureconst result = await agentbase.runAgent({ message: `Create organized structure: - src/ for source code - tests/ for test files - docs/ for documentation - data/ for data files`});// Avoid: Everything in rootconst result = await agentbase.runAgent({ message: "Create 20 files in the main folder"});
// Check disk usageconst check = await agentbase.runAgent({ message: "Check disk usage and list the largest files"});// Clean up when neededconst cleanup = await agentbase.runAgent({ message: "Delete temporary files and cache folders", session: check.session});
const result = await agentbase.runAgent({ message: `Read config.json. If it doesn't exist, create a default one with: { "apiKey": "", "endpoint": "https://api.example.com" }`});
// Files are isolated per sandbox/sessionconst session1 = await agentbase.runAgent({ message: "Create secret.txt with password"});const session2 = await agentbase.runAgent({ message: "Create secret.txt with different password"});// Each session has its own secret.txt
// Efficient: Process large file in chunksconst efficient = await agentbase.runAgent({ message: "Read large_data.csv in chunks of 1000 rows and process each chunk"});// Inefficient: Loading entire large fileconst inefficient = await agentbase.runAgent({ message: "Load all of large_data.csv into memory and process"});
// Create JSONconst create = await agentbase.runAgent({ message: 'Create data.json with {"users": [], "settings": {}}'});// Read and modify JSONconst modify = await agentbase.runAgent({ message: "Add a new user to data.json", session: create.session});// Validate JSONconst validate = await agentbase.runAgent({ message: "Validate that data.json is valid JSON", session: create.session});
CSV Files
Copy
// Create CSVconst csv = await agentbase.runAgent({ message: "Create sales.csv with columns: date, product, amount"});// Process CSVconst process = await agentbase.runAgent({ message: "Read sales.csv and calculate total sales by product", session: csv.session});// Convert CSVconst convert = await agentbase.runAgent({ message: "Convert sales.csv to JSON format", session: csv.session});
Text Files
Copy
// Create and writeconst write = await agentbase.runAgent({ message: "Create notes.txt with a list of tasks"});// Read and searchconst search = await agentbase.runAgent({ message: "Search notes.txt for tasks containing 'urgent'", session: write.session});// Appendconst append = await agentbase.runAgent({ message: "Add a new task to notes.txt", session: write.session});
Code Files
Copy
// Create source filesconst code = await agentbase.runAgent({ message: "Create a Python module utils.py with helper functions"});// Modify codeconst modify = await agentbase.runAgent({ message: "Add error handling to all functions in utils.py", session: code.session});// Test codeconst test = await agentbase.runAgent({ message: "Create test_utils.py to test the functions", session: code.session});
Binary Files
Copy
// Download and saveconst download = await agentbase.runAgent({ message: "Download image from URL and save as logo.png"});// Process binaryconst process = await agentbase.runAgent({ message: "Resize logo.png to 200x200 pixels", session: download.session});
File Persistence: Files persist within a session until the session expires or is deleted. For long-term storage, consider downloading files or using external storage solutions.