# Built-in tools

Each needs nothing unless its row says so. Approval and live changes: [tool permissions](https://fzkuji.github.io/OpenProgram/docs/capabilities/permissions.html).

## Files and code

| Tool | What it does |
| --- | --- |
| `read` | Read file contents |
| `write` | Create a file or overwrite one wholesale |
| `edit` | String replacement inside a file |
| `apply_patch` | Structured multi-file patches in Codex or OpenClaw format |
| `list` | List directory contents |
| `glob` | Find files by name pattern |
| `grep` | Content search: ripgrep when present (faster), else Python `re` |
| `semble_search`, `semble_find_related` | Semantic and lexical code search returning ranked blocks. In every supported release; source developers install the `search` extra through the locked environment. |
| `lsp_diagnostics`, `lsp_references`, `lsp_definition` | Type-checker errors, real call sites, true definitions: [language server tools](https://fzkuji.github.io/OpenProgram/docs/capabilities/lsp.html). Needs `pyright` (Python) or `typescript-language-server` (TypeScript); the tools name the install command when missing. |

### Files, previews and versions

| Format | In the file window |
| --- | --- |
| Supported UTF-8 text | Preview, then Edit. Autosaves; `Ctrl/Cmd+S` flushes. Switching keeps undo history. |
| PDF | Pages, zoom, text search over the first 500 pages (longer documents state the limit). Read-only. |
| PSD | Saved composite and layer names, 8-bit RGB. Read-only. |
| TIFF | First page. Read-only. |
| Common images | Preview by default. |
| PNG, JPEG, WebP (static) | Edit: crop, rotate, draw, shapes, text. Autosaves; **Convert to PNG** makes a separate file and rejects an existing destination. |
| Animated PNG/WebP, 16-bit PNG | Read-only |
| Audio, video | Browser controls; codecs depend on the browser |
| DOCX, PPTX, XLSX, ODT, ODP, ODS | **ONLYOFFICE** application, ready to edit, no Preview switch |
| DOC, PPT, XLS | Convert to a new DOCX, PPTX or XLSX path; original kept, existing destination rejected |

Damaged or unsupported files keep an original-file download. Chat attachments and history previews are read-only.

**Publish a generated document from the model**

- `write(file_path="/absolute/final.docx", source_path="/absolute/staged.docx")` publishes a separate temporary result, for Word, PowerPoint, PDF, images and other binaries. `source_path` and `content` are mutually exclusive; the source is a regular local file of at most 64 MiB. Existing targets must be read first; binary reads return metadata and set the same freshness check.
- Records complete before/after bytes in the turn's file history, surviving reopen and restart. Undo and reapply refuse to overwrite conflicting later changes. New files can be undone. No Git repository needed. Local generators use this same interface.
- A failed later history commit keeps the previously published version. An interrupted write is reported as unconfirmed and blocks exact recovery. Corrupt history blocks further recorded writes rather than being replaced. After a failed first attempt, reread before retrying. Versions follow the turn's retention.
- Binary versions keep formatting and media; Review does not compare layout or show Word tracked changes. Shell commands overwriting the final file are not recorded, and unrecorded versions cannot be rebuilt from a card or output: write a separate result and publish it.

**Manual edits and history**

- Project-file edits keep before/after bytes independently of conversations. Each successful write publishes at once. Changes from one editor group for at most five minutes; closing the group or an intervening outside change starts another version.
- History lists retained versions and restores a selected one, creating a new entry after checking the current revision.
- A failed save or an outside change keeps the draft for retry, export or explicit discard. Closing a file with unsaved changes asks first: Save, Don't Save or Cancel. Saving never holds the close: the tab goes at once, and a save that fails shows a notice and keeps the changes as a draft.
- History combines manual edits and confirmed model changes for the project-relative file. Model entries read retained bytes from the original session checkpoint, without a second archive. Restoring changes only this file.
- Archived sessions keep their file history; permanent deletion makes their model versions unavailable; manual history is independent.
- Older history indexes in bounded batches: **Continue loading history**. Incomplete or unverifiable history is labeled. Legacy paths appear only when project ownership can be established.
- History follows the project when it moves and stays readable while its disk is disconnected; writing and restoring need an available location.
- The document API accepts bounded binary content up to 64 MiB, which does not itself provide an editor for every format.
- PDF, PSD and TIFF decoders accept at most 64 MiB, bound the rendered size, are local and load only when that format opens. Previewing a history version uses its retained bytes.

**Office editing (ONLYOFFICE)**

- Built-in application `office_editor`, an optional local install shared by all Office formats; not in the default App or runtime. Disabled on **Applications**: the file offers only its download and nothing installs.
- Without the component, **Install** or **Cancel**; nothing downloads until you choose. About 699 MiB, with resources, fonts, licenses and source materials, downloaded from your version's GitHub release. Files process locally.
- Releases before 1.3.0 do not carry it: such a version says so and asks you to update OpenProgram first, instead of offering a retry.
- The pinned archive and all resources are verified before a complete version is selected. Failures can retry and existing installs remain. On success the document opens without restarting. **Cancel** leaves the download, and **Installation options** lets you choose again.
- Unavailable through remote application access. PDF viewing does not need it.
- A centered status shows preparation and opening. Closing during startup cancels; a failure offers **Retry**.
- Editing starts once the native editor is writable; autosaves. Tabs, split layouts and History keep the editor and its undo history. Closing waits for pending input; a failed write keeps the document for retry.
- History previews are read-only and restoring creates a new version. No semantic Office redlines. The download stays when the editor cannot load.

**Image editing limits**

At most 64 MiB, 16 million pixels and 16,384 pixels per side. Changes save through the document history controller; Preview, History, tabs and routes keep undo and redo. Failed publication keeps the draft; closing waits for export. Exports rendered pixels, so embedded metadata may not survive.

## Execution

| Tool | What it does |
| --- | --- |
| `bash` | Run a shell command; returns output and exit code. Still running after its wait: keeps running as a session. |
| `write_stdin` | Wait for more output from that session, interrupt it, or type into it |
| `execute_code` | Python snippet in a fresh isolated subprocess. Returns stdout, stderr, exit code. Success needs exit 0; nonzero or timeout is an error with partial output kept. |

### Commands that keep running

`bash` waits up to `yield_time_ms` (250 minimum, 30000 default and maximum), then returns either `Process exited with code N` or `Process running with session ID <id>` with the output so far. No separate start step.

| `write_stdin` `chars` | Effect | `yield_time_ms` |
| --- | --- | --- |
| empty | Returns new output, or the exit code once ended | 5000–300000, default 5000 |
| `"\u0003"` | Interrupts, like Ctrl-C | Default 250 |
| anything else | Typed as is; end a line with `"\n"` | 250–30000, default 250 |

**Limits, notices and approval**

- Typing needs `bash(..., tty=true)` (pseudo-terminal, local backend on macOS or Linux). Without it stdin is closed, so a command waiting for input ends, and only the interrupt is accepted.
- A call keeps up to 1 MiB of output: first and last halves when longer.
- A background command ending unseen sends the conversation a notice turn with command, exit code and last output, after any running turn. While a Goal runs, the notice goes into the Goal's next turn instead, since its turns follow each other with no gap. A command you stop sends none.
- Listed as **Background terminal** under Terminal in Resources, where you can watch and stop them, and in Activity. Record and output are deleted a day after it ends or its status became unknown.
- At most 64 per conversation. Another stops the least recently used, never one of the eight most recent, and the result names it. Cancelling a turn stops a command in its first wait; background ones keep running.
- Polling and interrupting are never asked about. Typing follows the permission mode, like `bash`.

### `workdir`

Each `bash` call is a new shell: `bash(command="npm test", workdir="apps/web")`. A `cd` or `export` does not carry over. It does not change the worktree binding or the file tools' base, and it is not the Desktop terminal (that is `terminal_use`).

**Path rules**

- Relative paths resolve from the bound worktree, or the host process directory when none. Absolute paths work. Literal: no `~`, variables or expressions. Omit it for the existing default.
- Missing, non-directory or denied directories fail without running; none is created and nothing falls back.
- Selecting a directory grants nothing. Under a local sandbox policy it must satisfy the workspace's policy, including symlinks and extra authorized roots, and execution stays in that boundary. An unavailable configured sandbox is not bypassed.
- SSH and Docker read it as a POSIX path on the backend. Relative remote paths need an absolute POSIX worktree binding. A guarded change prevents the command list from running if the directory is unavailable; Docker does not create it via `-w`. With a host sandbox policy, explicit remote workdirs are refused until backend-native authorization exists.
- Results include the local starting `cwd`, or `requested_cwd` for remote paths. Not an ending directory or persistent state.
- Tool-call notation; the Python export is an AgentTool, not a shell function.

## Web

| Tool | What it does |
| --- | --- |
| `web_search` | Keywords to relevant URLs, multiple backends |
| `web_fetch` | URL to readable text; `trafilatura` gives cleaner extraction |

| Backend | Key |
| --- | --- |
| DuckDuckGo, arXiv | None, always available |
| Brave | `BRAVE_API_KEY` |
| Exa | `EXA_API_KEY` |
| Firecrawl | `FIRECRAWL_API_KEY` |
| Google PSE | `GOOGLE_PSE_API_KEY` and `GOOGLE_PSE_CX` |
| Jina | `JINA_API_KEY` |
| Kagi | `KAGI_API_KEY` |
| MiniMax | `MINIMAX_CODE_PLAN_KEY`, `MINIMAX_CODING_API_KEY` or `MINIMAX_API_KEY` |
| Moonshot (Kimi) | `KIMI_API_KEY` or `MOONSHOT_API_KEY` |
| Perplexity | `PERPLEXITY_API_KEY` |
| SearXNG | `SEARXNG_URL`, a self-hosted instance |
| Serper | `SERPER_API_KEY` |
| Tavily | `TAVILY_API_KEY` |
| You.com | `YDC_API_KEY` or `YOU_API_KEY` |
| Ollama | Local Ollama (`ollama signin`), or `OLLAMA_API_KEY` for Ollama Cloud |

**The Web Search switch and backend selection**

- Per message. Providers with their own search (ChatGPT subscription, OpenAI Responses API, Anthropic) search through the provider: one "Searched the web" step per search with sources, a sources row on the answer, and no local `web_search`.
- Other providers, Gemini included (its grounding cannot combine with function tools), get the local tool.
- Off excludes both, even in automatic tool mode. On makes the schema available immediately, including when Tools is off, and still respects disabled tools and permissions. Tool profiles belong to each conversation and survive tab changes and refreshes.
- Keys apply to the next call without restart. An unavailable saved default falls back; a named unavailable provider gives the reason and lists usable ones.
- An unpinned search tries the saved default, then every other available web backend (arXiv only when named). When all fail with no key configured, the error points to **Settings > Search**.
- DuckDuckGo reads its no-JavaScript page and returns about ten first-page hits; a bot challenge or unreadable page is an error, not an empty search.
- `combine="race"` returns the first nonempty success; unrunnable `providers` are skipped, and if none runs the error lists each reason. `combine="rrf"` keeps results completed before the deadline. Total failure is an error, distinct from an empty search. Running requests finish under their transport timeouts.

## Desktop

| Tool | What it does |
| --- | --- |
| `computer_use` | Operate application windows in the background (screenshot and Accessibility tree), the whole screen when you turn it on, built-in browser Pages, your own Chrome or Edge, or the screen of a machine you set up. One step, a batch or Python code. One approval per application; a machine you set up asks nothing. Needs macOS Accessibility and Screen Recording for the runtime, Linux X11 with AT-SPI and xdotool, or Windows UI Automation. [Computer use](https://fzkuji.github.io/OpenProgram/docs/capabilities/computer-use.html) |
| `terminal_use` | The built-in Desktop Terminal, including one you already opened |

## Images and PDF

| Tool | What it does |
| --- | --- |
| `image_generate` | Prompt to a saved PNG. One of OpenAI (`OPENAI_API_KEY`), Gemini (`GEMINI_API_KEY` or `GOOGLE_API_KEY`), fal (`FAL_KEY`) |
| `image_analyze` | Describe or answer about an image, local path or URL. Any configured OpenAI, Anthropic or Gemini vision key. |
| `pdf` | Extract text, with offset and limit paging. `pypdf`, bundled with the complete release. |

Image tools return an error when the provider is unavailable, its request fails, or an image cannot be saved.

## Session and collaboration

| Domain | Tool | What it does |
| --- | --- | --- |
| Open work | `open_work` | What the Agent still owes you here, in its instructions every turn: [Open work](https://fzkuji.github.io/OpenProgram/docs/capabilities/agents.html#open-work) |
| Planning | `task_start`, `task_step`, `task_list` | A task names a stretch of work and lists its steps; one is open per agent. `task_step` finishes the current step and starts the next, adds or drops steps, or ends the task with its result. Writing starts nothing. Web shows it as a [task block](https://fzkuji.github.io/OpenProgram/docs/interfaces/web.html#task-list) in the reply, with each step's work under it. |
| Execution | `list_jobs`, `job_output` | List this session's background tasks; wait for or inspect a result. Access checks the dispatching session and ancestors. |
| Entity | `agent` | Spawn an agent and collect its reply, or `to=` hand a tracked task to an existing one. `run_in_background=true` returns a task id. `start_from`: `clean`, `inherit` or `SID:MSG_ID`. `archive_when_done=true` archives after the result returns. |
| Entity | `list_agents` | Names, addresses, sizes, busy state; `scope="archived"` for archived ones |
| Entity | `archive_agent` | Leaves `list_agents`, refuses `send_message` and `agent(to=)`; `read_conversation` and `agent(start_from="SID:MSG_ID")` still work. Any session may archive any agent. One-way. |
| Communication | `send_message` | To an existing agent, by `"SID:HEAD"` or name. No task or id, so anyone may write to anyone. Empty `message` with `notify_when_idle=true` gets one notice with its latest reply when idle. |
| Communication | `read_conversation` | Any agent's history as plain text, tool calls included, with turn ranges and a character budget |

The four domains: [agent collaboration](https://fzkuji.github.io/OpenProgram/docs/reference/design/runtime/collaboration/agent-collaboration.html).

**When a background agent finishes**

- The sender gets a notice turn marked automated, after any running turn; every agent finished meanwhile arrives in the same notice.
- None if already read with `job_output` (which also waits for a `send_message` reply by `delivery_id`), handed back by `notify_when_idle`, or cancelled.
- The notice carries the task and final reply, not the transcript; use `read_conversation` for the steps.
- A message to a busy agent queues until it is free.
- `job_output` works when the collaboration message allowance is exhausted and does not consume it. New deliveries still obey limits.
- Cancel through execution controls: API `execution.command` with `action="execution.cancel"` and the current version. There is no `job_stop`.

| Tool | What it does |
| --- | --- |
| `program` | Invoke any registered `Agent` method |
| `mixture_of_agents` | Ask N models in parallel, then synthesize; defaults take one per provider from the model registry, at least 2 needed. Error for unknown references, all references failing, or failed synthesis; success stands if some fail or its text says Error. |
| `ask_user_question` | Ask 1–N questions with options. Needs an interactive frontend; missing input infrastructure, invalid arrays and non-interactive contexts return tool errors. |
| `chat_send` | Post into the originating chat channel; hidden elsewhere. In an [ambient group](https://fzkuji.github.io/OpenProgram/docs/integrations/channels.html#group-behavior) the only way to speak; elsewhere a short note before long work. At most 5 per turn. |
| `send_file` | Attach a file for the person; each surface delivers it when the turn ends |
| `exit_plan_mode` | Leave Plan and restore the prior mode. Plan is entered from the selector; the model cannot enter it. |
| `canvas` | Write into named blocks of a markdown file. `set` with `content=""` clears; omitted content is an error. Explicit validation and process failures are errors; content beginning `Error:` stays successful. |
| `memory_search`, `memory_get`, `memory_update` | Search by meaning or exact string; get what exists, one file, section, block or a cited chat message; add or correct records. Recording the conversation happens in the background. One workspace per instance, shared by every agent and conversation, chat channels included: [who can talk to your bot](https://fzkuji.github.io/OpenProgram/docs/integrations/channels.html#who-can-talk-to-your-bot). |
| `worktree_create`, `worktree_merge`, `worktree_discard`, `worktree_list`, `worktree_keep` | Git worktrees. `worktree_create` also opens a PR: `pr="123"`, `"#123"` or a URL, via `gh`. Needs git. |
| `remind` | Notify at a time or wake the agent: [reminders](https://fzkuji.github.io/OpenProgram/docs/capabilities/reminders.html) |
| `scheduler` (alias `cron`) | Register, list and delete recurring agent tasks |
| `save_routine` | Save this work as a skill: [routines](https://fzkuji.github.io/OpenProgram/docs/capabilities/skills.html#save-work-as-a-routine) |
| `skill` | Load a skill's instructions into this turn: [skills](https://fzkuji.github.io/OpenProgram/docs/capabilities/skills.html) |
| `plugin` | Guide, install and reload a plugin: [plugins](https://fzkuji.github.io/OpenProgram/docs/capabilities/plugins.html) |
| `create_goal`, `get_goal`, `update_goal` | A persistent objective for this chat, only when explicitly asked: [Goal](https://fzkuji.github.io/OpenProgram/docs/capabilities/goal.html) |
| `handoff`, `always_on_schedule`, `always_on_report`, `always_on_preference` | Always-on conversations: hand work to another conversation, set the next check-in, report findings, remember preferences: [Always-on Agents](https://fzkuji.github.io/OpenProgram/docs/capabilities/always-on-agents.html) |
| `list_mcp_resources`, `read_mcp_resource`, `list_mcp_prompts`, `get_mcp_prompt` | MCP resources and prompts (the `mcp_meta` directory). Needs a configured [MCP](https://fzkuji.github.io/OpenProgram/docs/capabilities/mcp.html) server. |
| `tool_search` | Load a deferred tool; its schema joins the next request |
| `help` | A tool guide by name (`help("self_update.prepare")`), or a tool's overview |
| `self_update` | Change OpenProgram from an isolated worktree through build, trial, switch, rollback and repair. `status` (default), `begin`, `prepare`, `retry`, `cancel`, `versions`, `undo`; each follows the permission mode. Needs an installation from sealed versions, or the development instance of a source checkout. [Self-update](https://fzkuji.github.io/OpenProgram/docs/capabilities/self-update.html) |

**Tool guides**

Tools with many rules keep their schema short and deliver the rest as guides.

| When | Guide |
| --- | --- |
| First result of `computer_use` for a target, or of `self_update` | Starts with its guide and lists further ones |
| First `self_update(action="prepare")` | Refused once with the guide; the next call runs |
| After compaction | Delivered again when needed |

Plain Python `execute(...)` calls keep their string results.
