Skip to main content
Pre-built tools for LLMs to read, write, and search files on disks through function calling.

Available Tools

ToolDescription
write_file_diskCreate or overwrite text files
read_file_diskRead file contents
replace_string_diskFind and replace text
list_diskList files and directories
download_file_diskGet public download URL
grep_diskSearch contents with regex
glob_diskFind files by path pattern

Quick Start

import json
import os
from acontext import AcontextClient
from acontext.agent.disk import DISK_TOOLS
from openai import OpenAI

client = AcontextClient(api_key=os.getenv("ACONTEXT_API_KEY"))
openai_client = OpenAI()

# Create disk and context
disk = client.disks.create()
ctx = DISK_TOOLS.format_context(client, disk.id)

tools = DISK_TOOLS.to_openai_tool_schema()
context_prompt = ctx.get_context_prompt()

messages = [
    {"role": "system", "content": f"You have disk access.\n\n{context_prompt}"},
    {"role": "user", "content": "Create a todo.md file with 3 tasks"}
]

# Agent loop
while True:
    response = openai_client.chat.completions.create(
        model="gpt-4.1", messages=messages, tools=tools
    )
    message = response.choices[0].message
    messages.append(message)

    if not message.tool_calls:
        print(f"Assistant: {message.content}")
        break

    for tc in message.tool_calls:
        result = DISK_TOOLS.execute_tool(ctx, tc.function.name, json.loads(tc.function.arguments))
        messages.append({"role": "tool", "tool_call_id": tc.id, "content": result})

Tool Reference

write_file_disk

{"filename": "notes.md", "content": "# Notes", "file_path": "/docs/"}

read_file_disk

{"filename": "notes.md", "file_path": "/docs/", "line_offset": 0, "line_limit": 100}

replace_string_disk

{"filename": "notes.md", "old_string": "TODO", "new_string": "DONE", "file_path": "/"}

list_disk

{"file_path": "/docs/"}

download_file_disk

{"filename": "report.pdf", "file_path": "/", "expire": 3600}

grep_disk

Search file contents with regex:
{"query": "TODO.*", "limit": 100}
Uses regex syntax: .* means any characters, * alone means zero or more of preceding character.

glob_disk

Find files by path pattern:
{"query": "**/*.md", "limit": 100}

Next Steps