# What does the file toolkit do?

**The `file` toolkit reads, writes, edits and searches files on your computer: plain text, but also Word, PowerPoint, Excel, PDF (including scans), images, video and audio. Each chat has its own folder in `~/.irene/workspaces/`, nothing is uploaded, and edits to one file never collide.**

---

## What makes it different

| what it does | the primitive behind it | what that buys you |
|---|---|---|
| **One reader for everything** | `read_file` picks the right parser from the extension: Word, PowerPoint (with speaker notes), Excel, PDF, images, video, audio | Ask about any file and the agent can open it, with no "please convert this first" |
| **Local, one folder per chat** | Each chat gets its own workspace on your computer; a helper's files land in the folder of the chat that started it | Files stay on your device, and work done by helpers is already where you're looking |
| **Edits never collide** | A lock per file across the whole read-change-write | Several edits to one file in one step used to lose work (the last write won 27 of 30 times). Now they queue, while different files still change in parallel |
| **Big reads don't flood the chat** | A large file read is stored on disk behind a short pointer, and only the needed part is read back | A long file doesn't get paid for again on every later turn |
| **Search that tells the truth** | Content search reads real text only (including Word, PowerPoint and Excel), skips binary files and says how many it skipped | It won't claim "found it" inside a ZIP's compressed bytes |
| **Your secrets are walled off** | Irene's own keys can never be read; `~/.ssh`, `~/.aws`, `.env` files and similar need your approval each time | A file tool can't quietly read your credentials |

---

## How it works

### Where files live

- **Each chat has its own folder:** `~/.irene/workspaces/<chat>/`. Relative paths resolve there.
- **Other paths work too:** full paths, `~/...`, and the words *downloads*, *desktop*, *documents*, *pictures* or *videos* go to those folders.
- **In a Coding chat on another computer,** the Coding agent's own file tools work on that computer, and its project never touches your Mac's disk except through **Save to my Mac**. This toolkit's paths are always on your Mac. → [Coding agent](https://mycelen.com/manual/reference/agents/coding)
- **Helpers write into your chat's folder.** **Why:** nothing has to be copied back afterwards, because the work was never anywhere else. The old approach copied at most 10 files back and once lost a merged PDF from a 16-file deck.
- **Pasted text and attachments become files** in the folder, not uploads.
- **System folders can't be written to.**

### Reading

| file | how it's read |
|---|---|
| text and code | as text, or a line range for big files |
| Word (`.docx`) | text |
| PowerPoint (`.pptx`) | slide text and speaker notes |
| Excel (`.xlsx`) | each sheet as a table (first 500 rows per sheet) |
| PDF | its text; if any page is a scan, the whole document is read with text recognition |
| image | seen directly by a model that can see images, otherwise described by one |
| video | one timestamped grid of frames |
| audio | a transcript with timings |
| old `.doc`, `.ppt`, `.xls` | refused with a note on how to convert them |

- **Very large text files** (over 250,000 bytes) must be read in windows. The reply suggests 120 lines at a time.
- **A large result is stored on disk** if it's over 20,000 tokens and worth moving out (at least 3× the size of the pointer that replaces it). The conversation gets a pointer, and the agent reads back only the lines it needs. **Why 20,000 for file reads:** the agent reads a stored file back fairly often (0.87 times per stored read), and each read-back is a whole extra step that re-sends the conversation.

### Writing and editing

- **`write_file`** creates, overwrites or appends. Writing Markdown can inline local images so the file stands alone.
- **`edit_file`** replaces exact text, tolerating small whitespace differences, and checks the match is unique. It returns a few lines around the change so the agent can see what it did.
- **One change to a file at a time.** Each edit locks the file across its whole read-change-write.
- **Plugin files that are sealed** can be read but not changed. Save your own copy under a new name.

### Searching

- **`search_files`** searches names or contents, through every subfolder.
- **It skips the noise:** `node_modules`, `.git`, virtual environments and build output are pruned, and it stops after 20,000 files.
- **Real text only:** Word, PowerPoint and Excel are read properly. Binary files are skipped and counted ("N held no readable text").
- **Results:** up to 200 (50 by default), with lines of context.
- **Search by meaning** within one long document after it's been indexed with [rag](https://mycelen.com/manual/reference/toolkits/rag): `search_files(..., semantic=True)` returns up to 12 pointers (heading, line range, score).

**Why search went recursive and skips binaries:** a one-folder search once answered "found 0 matches" on a real project, and a plain byte search once "found" a word inside a ZIP file. A search that confidently answers wrong is worse than one that says what it couldn't read.

### Secrets

| path | rule |
|---|---|
| Irene's own keys and connection files | **never** readable, and can't be approved |
| `~/.ssh`, `~/.aws`, gcloud, `.netrc`, Docker and Kubernetes config, any `.env` | one-time approval each time |

A search skips protected files instead of reporting them.

---

## Its tools

| tool | does |
|---|---|
| `read_file` | read any supported file, whole or a line range |
| `write_file` | create, overwrite or append |
| `edit_file` | replace text, with a uniqueness check |
| `search_files` | search names or contents across folders, or by meaning within one indexed document |
| `change_workspace` | move this chat's file anchor (and its terminal) to another folder |

**Deliberately not tools:** listing a folder or getting file info. Those are [shell](https://mycelen.com/manual/reference/toolkits/shell) jobs (`ls`, `stat`). **Why:** keeping them off the file toolkit saves their descriptions on every turn.

---

## How agents are told to use it

- **Read before changing.** Find the exact text before an edit.
- **Big files in windows,** and big results through the stored pointer, not re-read whole.
- **Many files:** four or more files go to a helper or a [reflex](https://mycelen.com/manual/guides/make-a-reflex), so the contents never enter the main conversation.

---

## Approvals

- **Every file tool asks first, reads included.** Reading a file reaches into your filesystem, so "reads pass, writes ask" was dropped. **Always allow** makes it one approval per tool for the chat, not one per call.
- **Auto mode:** reading and searching count as reads; writing, editing and moving the workspace count as local changes. Protected paths still ask.

---

## Where you see it

- **The workspace rail** in the main chat: this chat's files.
- **Show in folder** (**Show in Finder** on a Mac, **Show in Explorer** on Windows) **/ preview:** only for files in the chat's folder, or ones this chat actually touched.
- **Tool cards** for every read, write, edit and search.

---

## What it costs

- **Free to use.** File tools run on your computer with no model call.
- **The exceptions:** recognising text in a scanned PDF, describing an image for a model that can't see, and transcribing audio each use a model.

---

## Limits

- Very large text files are read in windows (over 250,000 bytes).
- Excel sheets show the first 500 rows when read as text. Use the [Spreadsheets agent](https://mycelen.com/manual/reference/agents/spreadsheets) for real work on workbooks.
- Search stops after 20,000 files and returns at most 200 results.
- Old Office formats (`.doc`, `.ppt`, `.xls`) need converting first.
- In cloud-deployed agents, video and audio can't be read, and files stay inside the agent's own folder.

---

## Related

- [Shell](https://mycelen.com/manual/reference/toolkits/shell) · [Search your documents (rag)](https://mycelen.com/manual/reference/toolkits/rag) · [Toolkits overview](https://mycelen.com/manual/reference/toolkits/overview)
- Skill: **working-with-a-pdf** (Capabilities → Skills)

[Ask Irene about this]
