folder-openAgent Filesystem

Give agents a managed filesystem during execution so they can read, write, edit, and search files as part of a run.

Use this guide when you need stateful file operations across a run, large tool output capture, or multi-agent workflows that share artifacts.

circle-info

For document ingestion (attachments, chunk IDs, artifact retrieval), use the File Processing Guidearrow-up-right. This page focuses on runtime filesystem tooling.

Quick Start

from glaip_sdk import Agent

agent = Agent(
    name="file-agent",
    instruction="Use files to plan, draft, and revise outputs.",
    filesystem=True,  # Defaults to Local Disk
)

agent.run("Create /reports/summary.txt and then read it back.")

Backend Options

Backend
Best For
Execute Default
Persistence

filesystem=True / LocalDiskConfig

Local development

Disabled ⚠️

Yes

InMemoryConfig

Testing, ephemeral work

N/A

No

SandboxConfig

Untrusted code, isolation

Enabled

No

triangle-exclamation

Usage Examples

Local Disk (Default)

In-Memory (Testing)

Sandbox (Isolated Execution)

Available File Tools

When filesystem is enabled, agents receive these file operation tools:

read_file - Read File Contents

Purpose: Read all or part of a file.

When to use: Inspecting file contents, reading configuration, examining logs, accessing evicted tool outputs.

Examples:

Key parameters:

  • path - Absolute file path (required)

  • line_offset + limit - Line-based pagination

  • char_offset + max_chars - Character-based pagination

See Reading Large Files for pagination details.

write_file - Create New Files

Purpose: Create a new file. Errors if the destination already exists.

When to use: Creating new files, writing initial content, saving outputs that don't exist yet.

Examples:

Important: This tool creates new files only. It will error if the file already exists. Use edit_file to modify existing files.

edit_file - Modify Existing Files

Purpose: Make targeted changes to specific parts of a file using exact string replacement.

When to use: Fixing bugs, updating values, refactoring code, making surgical edits without rewriting the whole file.

Examples:

Key points:

  • Uses exact string matching

  • Errors if multiple matches found unless replace_all=True is provided

  • Must match exactly (including whitespace)

ls - List Directory Contents

Purpose: List files and directories at a given path.

When to use: Exploring directory structure, finding files, checking what exists, understanding the workspace layout.

Examples:

Output: Returns a Python list-style string of absolute file paths (e.g., ['/workspace/file1.txt', '/workspace/file2.txt']).

grep - Search File Contents

Purpose: Search for text patterns within files.

When to use: Finding specific text across multiple files, searching logs for errors, locating code patterns, filtering large files.

Examples:

Key points:

  • pattern supports basic text matching

  • path can be a directory (searches recursively) or specific file

  • Filesystem tools (ls, grep, read_file, write_file, edit_file) are excluded from auto-eviction and always return inline


All paths must be absolute (start with /).

Reading Large Files & Outputs

Pagination Strategy

When reading files, agents can use line-based or character-based pagination. Choose one mode per file and never mix them.

Line-Based (Default)

Best for normal code/text files with reasonable line lengths:

Use case: Reading source code, logs, configuration files.

Character-Based

Best for large/long-line files (JSON, minified JS, CSV, database query results):

Use case: GL Connectors SQL MCP results that return as single-line JSON blobs, minified JavaScript bundles, or large CSV files where lines exceed typical limits.

triangle-exclamation

Tool Output Auto-Eviction

When tool outputs exceed ~80,000 characters, they're automatically saved to /tool_outputs/<tool_call_id>.txt.

Applies to: Non-filesystem tools (e.g., execute tool output, large API responses)

Excluded from eviction: Filesystem tools (read_file, write_file, edit_file, ls, grep) always return inline

Why this matters:

  • Large command outputs from execute tool

  • Big API responses that would overflow context window

  • Long-running command results

What the agent receives:

  • File path where content was saved

  • Preview (first 500 chars + last 500 chars)

  • Instructions to use read_file for full access

Example scenario:

See Sandbox Filesystemarrow-up-right for detailed sandbox configuration and use cases.

When to Use Each Backend

Local Disk

  • ✅ Local development and debugging

  • ✅ Need persistence across runs

  • ✅ Working with existing files

  • ⚠️ Execute disabled by default

In-Memory

  • ✅ Unit testing

  • ✅ Ephemeral operations

  • ❌ No execute capability

  • ❌ Files lost after run

Sandbox

  • ✅ Running untrusted code

  • ✅ CI/CD automation

  • ✅ Security-critical workflows

  • ✅ Execute enabled by default

circle-exclamation

Troubleshooting

"Why can't I run commands with filesystem=True?"

Cause: Local Disk defaults to allow_execute=False.

Fix:

Sandbox Not Available

Cause: Missing E2B API key or glaip-sdk[local] extras.

Fix:

Last updated

Was this helpful?