Tools
查看 MarkdownWorkspace and local tools
The local tools work in the workspace. Each call is its own Dex tool Step, recorded in the session.
| Group | Tools | Approval |
|---|---|---|
| files | read_file, list_directory, search_files | None |
| files | write_file, edit_file | Every call |
| shell | run_shell_command | Every call, unless local_tools.shell.allow has the whole command text |
| web_fetch | fetch_web_page | None |
| browser | browser_navigate, browser_snapshot | None |
| browser | browser_click, browser_fill, browser_submit_form | Every call |
- File paths are relative to the workspace, or absolute inside it. A path that leaves the workspace through .., an absolute path, or a symbolic link fails the call. A file with more than one hard link is refused. edit_file changes files of at most 4 MiB, and fails with a conflict when the file changed after it read it.
- The allow list matches whole commands: ls -la does not match ls.
- A shell command runs with the system shell in the workspace, in its own process group, so Ctrl-C never reaches it. It times out after 120 seconds by default and 600 seconds at most. Changed in 0.6.0: when it ends, the processes it left in its group end too, such as one it started with &: they get SIGTERM, then SIGKILL half a second later. So cmd & answers at once and leaves nothing running. A process that left the group, for example with setsid, is not stopped: once the group is cleaned, the output may still arrive for 1 second, and the result holds what came by then. The result starts with exit code N, the number the shell reports (128 plus the signal's number when a signal ended it), or with killed: timed out after N seconds, and then has a --- stdout --- and a --- stderr --- section, each cut at 64 KiB. A shell that cannot start fails the call with the shell could not start: and the operating system's reason, whose wording differs between platforms.
- A command whose Worker died while it ran records outcome_unknown and never runs again.
- The browser is headless Chromium: Playwright's own when installed, else the system Chrome, else a Chromium that Playwright downloads the first time a browser tool runs. It opens only http and https URLs. Each session has one page in the Worker process, and every tool returns the page's URL, title, and accessibility snapshot as text. The browser tools take no screenshots. After a Worker restart, a session has no page until the agent navigates again.
- approval.always adds approval to any tool by the name the agent sees.
Approval modes
Since 0.6.20, a session can approve some calls without asking. Each session has an approval mode, which you switch in the chat or in Dex Web, and rules that you add when you approve a call. The session decides when the call would wait, so a switch applies from the next model call on. A call that already waits keeps waiting. See Approval modes and rules for how the session decides.
| Mode | Label | Approves |
|---|---|---|
| ask | Ask every time | Nothing; every call that needs approval waits. |
| low_risk | Accept edits | File writes inside the workspace by the file tools and by Claude Code's Write and Edit. |
| all | Auto-approve all | Every call, when approval.auto_modes lists it. |
No mode or rule approves a tool in approval.always, or a file write into a .git or .dex directory of the workspace or to the configuration file, so an agent cannot raise its own limits. Shell commands, browser actions, connector and remote MCP tool writes, and the file tools of Pi and Deep Agents are approved only by all or by a rule.
A rule for a shell command matches that exact command text, as local_tools.shell.allow does. A rule for another tool approves every later call of it, and is accepted only when an allowed mode would approve the call. Rules last as long as the session, and a fork copies them.
The workspace checks are not a sandbox. An approved shell command runs with your permissions and can change anything, inside the workspace or outside it. A concurrent process that swaps a directory for a link during an approved write can make the write land outside; the call then reports an error. Only OS-level isolation, such as a container, closes that gap.
dex-agents-builtin also has two built-in tools that the session runs itself. ask_user asks you a question and waits for the answer. write_todos replaces the session's plan and never waits for approval. Since 0.6.0, plan mode is on in dex-agents-builtin: a planning turn drafts a plan with write_todos and uses no other tool, and approving the draft starts a turn that runs it with every tool. Use plan mode through the terminal UI, with /plan and /run, or through the session API. The plain chat has no plan commands and sends them as ordinary messages.
The two names are reserved, so a Connector or local tool with one of them fails the turn. Changed in 0.6.0: write_todos became reserved. Rename a conflicting Connector or local tool, or use another harness.
Harnesses with their own tools
Three commands replace some local tools with their framework's own tools. Use these names in approval.always. The other groups keep the CLI core's tools. Each Deep Agents tool runs only while the turn switches its group on.
| Command | Group | Tools | Approval |
|---|---|---|---|
| dex-agents-claude-sdk | files | Read, Grep, Glob | None |
| dex-agents-claude-sdk | files | Write, Edit | Every call |
| dex-agents-claude-sdk | shell | Bash | Unless the allow list has the whole command text. A background command always waits. |
| dex-agents-claude-sdk | web_fetch | WebFetch | None |
| dex-agents-pi | files | read, grep, find, ls | None |
| dex-agents-pi | files | write, edit | None, unless approval.always names the tool |
| dex-agents-pi | shell | bash | None, unless approval.always names it. local_tools.shell.allow has no effect. |
| dex-agents-deepagents | files | ls, read_file, glob, grep | None |
| dex-agents-deepagents | files | write_file, edit_file, delete | None, unless approval.always names the tool |
| dex-agents-deepagents | shell | execute | None, unless approval.always names it. local_tools.shell.allow has no effect. |
| dex-agents-deepagents | files and shell | task | None, unless approval.always names any Deep Agents tool |
| dex-agents-deepagents | None | write_todos | None |
- Claude Agent SDK. Claude Code runs in the workspace. Its file tools refuse a path outside the workspace and any path with ... Bash is not confined. Claude Code reads no settings files, so their allow rules cannot skip an approval, and its other tools, such as subagents, are not offered. The command uses only these Claude Code tools, the browser tools, and the Connector tools. It loads no MCP servers and no claude.ai connectors from your Claude Code configuration or login, so external tools come only from Connectors that Dex approves and records. Changed in 0.6.0. Since 0.6.4, the tools of the file's remote MCP servers are offered too, also as Dex tool Steps. These tools run inside the Claude Code CLI, not in their own Steps, so a Worker that dies during a turn segment can run one of them twice. The browser and Connector tools still run in their own Steps.
- Pi. The agent keeps Pi's own tools and behavior and adds the Connector, web fetch, browser, and ask_user tools. As in Pi, no tool call waits for approval unless approval.always names the tool. Connector writes always wait for approval. Since 0.6.4, so do the writes of remote MCP server tools.
- Each Pi tool call is its own tool Step. Reads retry. A write, edit, or bash call never runs twice: a Worker that dies during one records outcome_unknown. A bash command that exits with a non-zero code, or that its timeout killed, records failed with its output.
- Pi's tools have no workspace boundary. The workspace is their working directory, so a relative path resolves against it. An absolute path or ~ reaches any file you can reach, and bash runs any command with your permissions. This is neither a guardrail nor a sandbox. Use OS-level isolation, such as a container, when the agent must not reach other files.
- grep and find run rg and fd, so grep respects .gitignore. When one is missing, Pi downloads it to ~/.pi/agent/bin on first use. With PI_OFFLINE=1 it downloads nothing, and the call fails until you install the tool.
- A bash command's output so far reaches the session as pi.tool_progress events. When the output is cut, the result names the file with the full output. That file exists only on the machine that ran the command.
- A Connector tool whose name a Pi tool has gets the prefix connector_, such as connector_read. approval.always names it that way: read there makes only Pi's read wait. If that name is taken too, the prefix repeats until the name is free.
- Deep Agents. The agent keeps Deep Agents' own tools and adds the Connector, web fetch, and browser tools. As in Deep Agents without interrupt_on, its file tools, execute, and task run without approval. Name a tool in approval.always to make it wait, as interrupt_on does. Connector writes always wait for approval.
- The file tools take absolute paths and work on the real files of the workspace. They refuse a path that resolves outside the workspace, and ls, glob, and grep leave out entries that do. This is a guardrail against mistaken paths, not a sandbox: execute runs /bin/sh in the workspace with your permissions and can reach any path.
- Large tool results and long user messages go to a private directory of the session under ~/.dex/agents/deepagents-artifacts. The command checks that you own each of its directories and that none is a link. When it starts, it deletes the directories of sessions whose files changed more than 30 days ago.
- Each call is its own tool Step, whose attempts also run Deep Agents' tool middleware, such as the eviction of a large result to a file. An edit_file, execute, or task call never runs twice.
- write_todos updates the agent's todo list. The list lasts for one turn.
- task runs a subagent inside the tool Step of its call. The subagent's model and tool calls have no Steps or approvals of their own, use the configuration file's model, and do not count in the session's usage. A Worker that dies during the call runs none of it again: the call records outcome_unknown.
- A Connector tool whose name a Deep Agents tool has gets the prefix connector_, such as connector_read_file. approval.always names it that way. If that name is taken too, the prefix repeats until the name is free.
Connectors
The agent calls Connector operations as tools through the Connectors MCP server. With connectors.mcp: auto, the command serves the Connector tools authorized on this machine, from ~/.dex/connectors/connections.json. It runs dexcli connectors mcp with the dexcli it finds as for dex.server, and uses the URL that command prints. When the command exits, it stops that command first, before a dexcli dev it started, also on SIGTERM, SIGHUP, or Ctrl-C. It closes the command's input, then sends SIGTERM and then SIGKILL to its process group while that command still runs. Changed in 0.6.9: this also works with dex.server set to a URL, such as Dex Cloud, and needs no dexcli dev. Before 0.6.9, auto used the /mcp path of the dexcli dev Dex Web port, and Connector tools were off with a URL dex.server.
There is one Connectors MCP server for each connections.json. With dex.server: auto, the command starts dexcli connectors mcp after dexcli dev is ready, so it reuses the server of that dexcli dev. A dexcli dev started later reuses the server of dexcli connectors mcp.
With dex.server set to a URL, Connector tools are off when connections.json is missing or lists no connection. The command prints a hint to authorize one on the Connectors page of Dex Web in a local dexcli dev. They are also off when dexcli connectors mcp cannot start. The command then prints the reason, and the log is in ~/.dex/agents/dexcli-connectors-mcp.log. It waits at most 120 seconds for the ready line and reads at most 1 MiB of it. When dexcli connectors mcp prints nothing and exits with code 2, as a DEXCLI older than 1.47.7 does, the hint says that this dexcli may not support the command and names that version. With dex.server: auto, either failure falls back to the /mcp path of the dexcli dev Dex Web port.
Authorize connections on the Dex Web Connectors page, at /v1/connectors on the Dex Web URL. Credentials stay in those connections, never in the configuration file. When an entry of connectors.enabled has no tool on the server, the command prints a hint with the Connectors page, and opens it in an interactive terminal. connectors lists the authorized connections and the configured ones.
Each connectors.enabled entry is one of:
- a connector, such as hackernews, for every connection of that connector;
- a connector and a connection, such as slack/support-slack;
- a map with one such key and a tools list, which limits the operations.
A tools list names each operation by its snake-case name, such as get_message, or by its operationId, such as getMessage. An acronym stays one word, so listStoryIDs is list_story_ids. Two entries must not cover the same connection, so slack and slack/work cannot appear together. A tools list names at least one operation. An empty connectors.enabled list gives the agent no Connector tools.
The agent sees each Connector tool by its MCP name, such as slack_post_thread_reply. approval.always names it the same way. Each call is a Dex tool Step with the effect class, approval, and idempotency key that the server gives the tool. Before it sends a call, the command checks that the tool name still belongs to the connection and operation the call was made for. Otherwise the call records failed and nothing is sent.
When an auto server does not answer at startup, such as while it starts, the command warns and runs without Connector tools. It lists the server again in every model call, so the tools appear once the server is ready. An explicit connectors.mcp URL that does not answer stops the command with exit code 1.
The Python dex-agents-openai-sdk fixes its tools when it starts. It offers only the Connector tools that the server listed at startup. Restart it when the server did not answer at startup, or after you authorize a connection while it runs. The TypeScript commands list the tools in every model call and need no restart.
Remote MCP servers
Since 0.6.4. mcp_servers adds the tools of MCP servers that are not Dex Connectors, such as a team's own tool server. Each key is the server's name. Each server speaks the Streamable HTTP transport. Stateless servers work: every request opens its own connection and protocol session.
mcp_servers:
studio:
url: https://mcp.example.com/mcp
headers:
Authorization: "Bearer ${STUDIO_API_KEY}"
local-notes:
url: http://127.0.0.1:9000/mcp
trust_tool_annotations: true
| Field | Default | Meaning |
|---|---|---|
| The key | None | The server's name: 1 to 32 ASCII letters, digits, _, or -, starting with a letter. |
| url | Required | The server's endpoint: https, or http on localhost, 127.0.0.0/8, or [::1]. It takes no user info and no fragment, and follows the URL rules of dex.server. |
| headers | Empty | HTTP headers sent with every request to the server. A value is printable ASCII. |
| trust_tool_annotations | false | Whether the server's readOnlyHint and idempotentHint annotations, and the effects it declares by the Dex MCP conventions, pick each tool's effect. |
The agent sees each tool as SERVER__TOOL, such as studio__search_assets. approval.always names it the same way. Each call is a Dex tool Step with the session's idempotency key. With trust_tool_annotations: false, every call waits for approval and runs at most once. With true, a tool the server marks read-only or idempotent runs without approval, unless approval.always names it, and may be retried. Set it only for a server whose hints you trust. dex-agents-pi and dex-agents-deepagents still make every call that is not a read wait for approval.
Secrets belong in environment variables. In a header value, each ${NAME} is replaced by the value of the environment variable NAME when the command starts. NAME has ASCII letters, digits, and _, and does not start with a digit. Any other $ stays as written. The value is used exactly as set: it is not trimmed and not expanded again. A header value may also be literal text, but a literal secret then sits in the file, so use a ${NAME} reference for every secret. An http URL on another host fails with insecure_mcp_server_url.
DEX_API_KEY, DEX_CREDENTIAL, and DEX_CREDENTIAL_FILE count as not set, so a Dex credential never reaches another server. A variable that is not set or is empty stops the command with exit code 2 and a message that names it, never its value:
mcp_servers.studio.headers.Authorization needs the environment variable STUDIO_API_KEY, which is not set or is empty.
A value outside printable ASCII stops the command the same way. Only the Worker expands the values. The command never prints, logs, or stores them. The session, the log file, and the terminal UI see the header text as written.
The server itself can still send a header value back. Error text from the server, such as an HTTP 401 body or a tool error, is redacted on a best-effort basis: each header value, each part of it between spaces, =, :, ,, or ;, and each variable value of at least 8 characters becomes [redacted] in the log file, the terminal, tool output, and errors. Other content the server returns is not covered, such as progress and task status messages and tool descriptions. Give a token only to servers you trust with it.
Each Worker checks a call again before it runs it. For a server whose annotations this Worker does not trust, a call that ran without approval, or that may be retried, records failed and is not sent, even when another Worker with trust_tool_annotations: true made it.
A server that cannot be listed offers no tools. The command prints one line and lists the servers again in every model call, so the tools return when the server answers. The error goes to the log file. Session settings cannot change mcp_servers; they ignore the key with a warning.
Images
/image PATH attaches an image file to the next message. A leading ~ is the home directory, and a relative path is relative to the directory you started the command in. The file must be a regular file of at most 3,750,000 bytes, in PNG, JPEG, GIF, or WebP. The command copies a valid image into the media store and shows its name, type, and size. A message carries at most 20 images. A file that fails a check is not attached, and the command says why. In the terminal UI, Tab completes the path, and each attached image shows as a chip with its name, type, and size above the input. Backspace in an empty input removes the last chip. The terminal UI does not draw the image itself.
In the terminal UI, pasting image paths attaches the images at once, as does dropping image files on the terminal window, which most terminals paste as their paths. A paste may name several files, separated by spaces or line breaks, in quotes or with backslash-escaped spaces. Text already typed stays in the input. Enter while a pasted image is still being stored waits, shows attaching image… sends when ready, and sends the message with the image once it is stored. If the image does not attach, the message stays unsent with a notice; press Enter again to send it without the image. A pasted path that does not attach stays in the input as text. When the paste also names an image, or the path itself ends in an image extension, a one-line notice says why: the file is not a PNG, JPEG, GIF, or WebP image, does not exist, or cannot be read. An image over the size limit, or one the media store cannot store, is not attached either, and its notice says why; its path does not return to the input. Text that is more than paths, such as a sentence that names a file, stays text. A paste while a panel or list has focus closes it and goes to the input; a waiting approval keeps waiting. Changed in dexcli 1.47.8: before, a pasted path asked Attach NAME?, attached only one image on Enter, an Enter right after a paste could send the message without the image, and a paste while a panel had focus was lost.
Session state keeps only a reference to each image. The bytes stay in the media store, one copy per distinct image, named by its SHA-256. Moving or deleting the original file changes nothing. Images that Connector tools return go to the same store.
- media.store: auto keeps images in ~/.dex/agents/media. Only Workers on this machine can read them.
- media.store: s3://BUCKET/PREFIX keeps them in an S3 bucket, for Workers on other machines. Credentials come from the environment or the standard AWS credential chain, never from the file. With media.endpoint, the command addresses the bucket in the URL path, as most S3-compatible services need. The S3 store needs the agents library's S3 support in the command's environment: dex-agents[s3] in Python, the @aws-sdk/client-s3 package in TypeScript. Without it the command stops with exit code 2.
Session settings cannot change the store. Keep every image for as long as a later model call of its sessions may need it: a missing image fails the turn.
Every command shows the images to its model. In dex-agents-pi, an image that read returns reaches the model too, after the result's text.