Every AI agent platform lets agents read and write files. Very few give agents any sense of where files should go — no project structure, no conventions, no discipline. The result: agents scatter work artifacts across the filesystem like a developer who saves everything to the Desktop.
Facio's workspace system solves this with two complementary layers: a file tool surface built for precision (not just reading and writing, but surgical editing, pattern search, and structured discovery) and a WORKSPACE.md layout convention that the agent follows as religiously as a senior engineer follows a monorepo structure. Together, they turn file access into file discipline.
The Tool Surface: Six Tools, Precise Operations
Facio's file tooling covers the full lifecycle of working with files — not just create and read, but search, discover, and surgically modify.
| Tool | What it does | Why it matters |
|---|---|---|
read_file | Read text, images, PDFs, DOCX, XLSX, PPTX | Multi-format awareness — the agent doesn't need different tools for different file types |
write_file | Create or overwrite a file, auto-creating parent directories | Clean creation with ${credentials.KEY} placeholder resolution for secret-safe config files |
edit_file | Replace old_text with new_text in-place, with diff feedback on failure | Surgical edits — the primary tool for inline learning, memory updates, and code changes |
patch_file | Targeted code block replacement | Focused code changes when the exact block can be identified |
grep | Regex search across files with glob/type filtering and context lines | Discovery — find patterns, references, and usages without reading every file |
glob | File discovery by pattern | "Where is the config file?" answered in one call |
This is a more complete surface than most agent platforms offer. edit_file alone — which does find-and-replace with whitespace tolerance, diff display on mismatch, and replace_all support — replaces the edit-validate-retry cycle that dominates agent coding workflows. The agent makes a targeted change, and if the match fails, it sees exactly what the file contains and adjusts.
WORKSPACE.md: Layout Rules the Agent Follows
The tool surface is the how. The where comes from WORKSPACE.md — a layout convention file in the workspace root that defines the directory structure:
- projects/ — cloned repositories, substantial multi-file work
- downloads/ — fetched source material, inbound attachments
- output/ — generated deliverables, exports, reports
- assets/ — reusable inputs: templates, fixtures, reference files
- tmp/ — disposable scratch files, intermediate artifacts
- memory/ — managed memory files and recall data
- skills/ — custom skills discovered by the agent
- scripts/ — reusable Python/Node/shell scripts
The agent reads this file at the start of every session — it's included in passive context alongside MEMORY.md and USER.md. Every time the agent creates a file, it consults these layout rules and places the file in the correct directory.
The rules are simple but enforced:
- Keep the workspace root clean. Bootstrap files (
AGENTS.md,WORKSPACE.md,SOUL.md,USER.md) live at root. Task output stays out. - Use the closest matching base directory. A blog post goes to
output/, not root. A downloaded PDF goes todownloads/, nottmp/. - Create subdirectories for new tasks. Under the closest base directory, with a clear name.
This prevents the "workspace creep" problem that afflicts every long-running agent: root directories filling with report-final-v3.md, data-export.csv, and test-script.sh until nothing is findable.
File Operations That Go Beyond CRUD
Secret-Safe Writing
write_file and edit_file resolve ${credentials.KEY} placeholders at write time. The agent composes a file containing credential references it cannot read:
write_file(
path=".env",
content="DATABASE_URL=postgres://localhost:5432/app\nAPI_KEY=${credentials.OPENAI_API_KEY}"
)
The file is written with the actual API key — resolved by the credential store, never seen by the agent. This is how Facio's secret management extends to file operations: the agent can create configuration files, environment files, and credential-bearing scripts without ever touching a raw secret.
Multi-Format Reading
read_file handles more than plain text. The agent can read PDFs (with page ranges), Office documents (DOCX, XLSX, PPTX), EPUBs, and images — all through the same tool. No separate PDF parser, no image conversion pipeline. When the agent encounters an uploaded invoice PDF or a screenshot attachment, it reads it the same way it reads a markdown file.
This matters because agent workflows routinely involve mixed-format data: a PDF report that needs analysis, an Excel spreadsheet that needs data extraction, a PNG screenshot that needs visual inspection. One tool handles all of them.
Surgical Editing with edit_file
edit_file is the most-used tool in Facio's file surface — and the most architecturally deliberate. Unlike write_file, which replaces an entire file (and risks destroying unrelated content), edit_file makes targeted replacements:
edit_file(
path="memory/MEMORY.md",
old_text="## Important Notes\n",
new_text="## Important Notes\n- Production deployment uses Docker Compose v2.24.6\n"
)
The tool tolerates minor whitespace and indentation differences. It handles curly/straight quote mismatches. On failure, it shows a diff of the closest match — so the agent can see what the file actually contains and adjust.
This is the mechanism behind inline learning and memory updates. The agent reads a file, identifies exactly where to insert or change content, and makes a surgical edit. It never rewrites MEMORY.md from scratch, risking the loss of weeks of accumulated context.
Discovery: Finding Without Reading
Two tools handle the "where is that file?" problem without the agent reading every candidate:
glob for structural discovery. glob(pattern="*.py", path="projects/") finds all Python files. glob(pattern="**/config*", entry_type="files") finds config files anywhere. The agent discovers the filesystem shape without find or ls.
grep for content discovery. grep(pattern="def handle_webhook", type="py") finds where a function is defined. grep(pattern="TODO|FIXME", output_mode="content") surfaces technical debt. The agent searches semantically — "show me where authentication logic lives" — without reading every file in the project.
Combined, they turn file discovery from a brute-force operation into a two-step precision workflow: glob to find candidate files, grep to narrow by content, read_file to inspect the exact target.
Production Patterns
Pattern 1: The Clean Workspace Boot
Every session starts with the agent reading WORKSPACE.md as part of passive context. The first file operation — whether it's creating a blog post, downloading research, or writing a script — respects the layout conventions. The workspace stays organized across hundreds of sessions because the rules are loaded every time.
Pattern 2: The Secret-Safe Config File
An agent needs to create a .env file for a new project. It composes the content using ${credentials.OPENAI_API_KEY} and ${credentials.DATABASE_URL} placeholders. write_file resolves them at write time. The file is correct. The agent never saw the secrets. The audit trail shows: "agent created .env with credential references."
Pattern 3: The Surgical Memory Update
A user corrects the agent: "Actually, our staging environment is on AWS, not GCP." The agent:
- Reads
MEMORY.mdto find the relevant section. - Uses
edit_fileto replace- Staging: GCP us-central1with- Staging: AWS us-east-1. - Confirms the change by re-reading the edited section.
One line changed. No risk to the rest of the file. The correction is durable across all future sessions.
Pattern 4: The Multi-Format Research Pipeline
An agent is researching a competitor. It:
- Downloads a PDF whitepaper →
downloads/competitor-whitepaper.pdf - Reads it with
read_file(pages="1-5")to extract key claims. - Reads a screenshot of the competitor's pricing page → visual analysis via
read_file. - Greps through previous research:
grep(pattern="competitor X", path="output/"). - Writes the synthesis to
output/competitive-analysis-2026-06.md.
Five file operations, three different formats, one consistent workspace. The output lands in output/. The source material stays in downloads/. Nothing pollutes root.
Bottom Line
File access without file discipline is chaos. Every AI agent can write files — but if it doesn't know where to put them, your workspace becomes a digital junk drawer within a week.
Facio's workspace system gives agents both the tooling (six precise file operations, secret-safe writing, multi-format reading, surgical editing) and the conventions (WORKSPACE.md layout rules loaded every session) to keep work organized, findable, and auditable. The agent doesn't just use files — it manages them with the discipline of a senior engineer who knows that structure is the difference between a project that scales and one that collapses under its own weight.
See the workspace documentation for layout conventions, file tool API reference, and credential-safe writing patterns.