Skip to main content
These are the agent’s own tools, exposed as plain endpoints. Reach for them when you know exactly what needs to happen and do not want a model deciding: a CI step that writes a build report, a script that greps for a pattern before deciding what to do next, a service that runs one command in a sandbox. Every tool is POST /api/workspaces/{workspace_id}/tools/{tool}.

Two kinds of path

This trips people up once and then never again.
  • File tools (read-file, write-file, edit-file, multi-edit) take workspace paths: /data.csv, /reports/august.mdx. They read and write storage directly and never start a sandbox.
  • Shell tools (run-bash, grep) run inside the sandbox, where the workspace is mounted at /ws - which is also the working directory. So ls lists the workspace root, and /ws/data.csv is the same file as /data.csv.

Run bash

status is completed or failed; a non-zero exit is failed, not an HTTP error. Commands are cut off after 10 minutes. The sandbox keeps a persistent shell between calls, so cd and exported variables survive to the next command. Two consequences worth knowing: a bare exit in your command kills that shell (state is lost, a fresh one starts on the next call), and files written anywhere under /ws land in the workspace. Pass sandbox_id to run in an isolated named container instead of the workspace’s default one - useful for keeping a long build away from everything else. Ids are scoped to the workspace, so the same id in two workspaces cannot collide.

Read a file

Output is line-numbered by default, which is what makes edit-file easy to aim. Set raw: true when a program is going to parse the result. Binary files return 400 - download them instead.

Write a file

This overwrites. To write only if the file does not exist, or to write only if nobody else has changed it since you read it, use PUT /files/content with createOnly or baseRevision.

Edit a file

old_string must appear in the file or the call returns 400. By default only the first occurrence is replaced; set replace_all: true for every occurrence. The response reports how many replacements it made.

Apply several edits at once

Up to 200 edits, applied in order, in one write - so later edits see the text earlier ones produced.
Edits are applied best-effort, not all-or-nothing. Edits that match are written even if others do not. Check the response rather than assuming a 200 means everything applied:
Only a request where nothing matched returns 400.

Grep

Matches come back with /ws-prefixed paths, because grep runs in the sandbox. Output is capped at 10,000 characters, so narrow the path or include rather than paging. Large binary and media files are skipped. For meaning rather than exact text - “the doc about refund policy” - use semantic search.

Permissions

run-bash and grep need workspace-wide access, not access to a single file, because a shell command can reach anything mounted.