Skip to content

File operations

Host editor, file_read, and file_write can be gated with filesystem_permissions on AgentConfig.

Tools

editor

View, search, and edit files line-by-line — supports insert, replace, pattern matching, and undo for safe in-place changes

Environment variables

VariableRequiredDefaultDescription
EDITOR_DISABLE_BACKUPoptionalunsetSet to true to skip backup files
EDITOR_DIR_TREE_MAX_DEPTHoptional2How deep directory trees go when listing folders

Also respects BYPASS_TOOL_CONSENT (see Tool consent).

file_read

Read local files and parse common formats (JSON, CSV, PDF, code, and more) into text the agent can reason over

Environment variables

VariableRequiredDefaultDescription
FILE_READ_RECURSIVE_DEFAULToptionaltrueSearch subfolders by default
FILE_READ_CONTEXT_LINES_DEFAULToptional2Extra lines shown around matches
FILE_READ_START_LINE_DEFAULToptional0Starting line for reads
FILE_READ_CHUNK_OFFSET_DEFAULToptional0Offset when reading in chunks
FILE_READ_DIFF_TYPE_DEFAULToptionalunifiedDiff format
FILE_READ_USE_GIT_DEFAULToptionaltrueUse git history when available
FILE_READ_NUM_REVISIONS_DEFAULToptional5How many revisions to include

file_write

Create new files or overwrite existing ones with agent-generated content; prompts for consent unless bypassed

Environment variables

No dedicated environment variables beyond:

Examples

Requires OPENAI_API_KEY. Sensitive tools prompt for consent — for demos set BYPASS_TOOL_CONSENT=true (see Tool consent).

bash
pip install --extra-index-url https://elsai-agents.elsai.ai/root/ elsai-agents==0.3.1
pip install --extra-index-url https://core-packages.elsai.ai/root/ "elsai-model[openai]==2.1.0"
pip install --extra-index-url https://elsai-agents.elsai.ai/root/ elsai-agents-tools==0.3.0
python
import os

from elsai import Agent
from elsai.agent import AgentConfig
from elsai_model.openai import OpenAIModel
from elsai_tools.editor import editor
from elsai_tools.file_read import file_read
from elsai_tools.file_write import file_write

agent = Agent(
    model=OpenAIModel(
        model_id="gpt-4o-mini",
        client_args={"api_key": os.environ["OPENAI_API_KEY"]},
    ),
    tools=[editor, file_read, file_write],
    system_prompt=(
        "Use file_read, file_write, and editor to work with local files. "
        "After using tools, answer the user clearly in plain text."
    ),
    config=AgentConfig(name="file_assistant"),
)

result = agent(
    "Create ./output/hello.txt with the text 'Hello from elsai', "
    "then read it back and confirm the contents."
)
print(result)

Parameter reference: File operations API.

See also

Copyright © 2026 elsai foundry.