Skip to main content

Overview

Kortix agents have comprehensive file system capabilities within the /workspace directory. Agents can create new files, read existing ones, make precise edits, and manage the file structure - all essential for building projects, processing data, and creating deliverables.

Core Functions

The file management tool provides several essential operations:

Create Files

Creates a new file with specified content. Automatically creates parent directories if needed.

Read Files

Reading is handled through a separate read tool that provides file contents with line numbers for precise editing.

Edit Files (AI-Powered)

Performs AI-powered intelligent edits using the Morph API. Only specify changed lines.

String Replace

Performs exact string replacements. Use replace_all=True to replace all occurrences.

Full File Rewrite

Completely replaces file content. Use sparingly - prefer edit_file for modifications.

Delete Files

Deletes a file from the workspace.

Real-World Examples

Example 1: Creating a Python Project

Example 2: Intelligent Code Editing

Example 3: Configuration Updates

Example 4: HTML Preview Support

Implementation Details

From the source code (sb_files_tool.py:79-689):

Path Handling

All paths are relative to /workspace:

AI-Powered Editing

The edit_file function uses the Morph API for intelligent code modifications:

HTML Preview URLs

When creating HTML files, preview URLs are automatically generated:

File Exclusions

Certain files are automatically excluded from operations to prevent issues:
  • .git/ directory contents
  • node_modules/
  • .env files (for security)
  • Binary files (images, PDFs, etc.)
  • Cache directories

Export to PDF

HTML files can be exported to PDF:
Uses Playwright/Chromium for high-quality rendering. Output saved to /workspace/downloads/. From sb_files_tool.py:625-688:

Edit File Format

When using edit_file, use the special marker to indicate unchanged code:
Important: Include 3-5 lines of context around each change. DO NOT omit code without using the // ... existing code ... marker, or the model may inadvertently delete lines.

Best Practices

1. Always Read Before Editing

2. Prefer Editing Over Rewriting

3. Use String Replace for Simple Changes

4. Batch Edits in Single Call

Permissions

Files are created with permission 644 by default. For executable files:

Configuration

File editing with AI requires either:
Without these, edit_file will fail but basic operations (create, delete, str_replace) still work.