Agent tools

bash

bash({ command | commands, timeout_ms?, stop_on_error?, background?, port?, description? })

Run shell commands in the workspace and get the exit code and output. The widest-reaching tool there is, and the one asked in every mode but full.

category: exec120 s, max 600 salways asked outside full
Using Python?

Switch any code block to Python: the choice applies to every page. Python SDK guide and resource reference.

commandstring

One command.

commandsstring[]

Several, run in order, in one call.

timeout_msinteger120 000

Per command. 600 000 at most.

stop_on_errorbooleantrue

Stop the sequence at the first non-zero exit code.

backgroundbooleanfalse

Run in a terminal that outlives the answer. One command only.

portinteger

With background: the port the server listens on. The terminal publishes it and returns a URL.

descriptionstring

A five-word summary, shown to the user.

Several commands in one call

Each separate call costs a whole turn

commands: ["npm ci", "npm run build"] is one turn; two calls are two. The instruction to batch is in the tool's own description and in the system prompt, because a model does not do it on its own.

A sequence is approved as a sequence: the user saw three commands in that order, so approving them does not approve any one of them alone later.

Which shell

WhereShell
A computer running WindowsPowerShell
A computer elsewherebash
A supplied shell bridgewhatever your bridge runs
A cloud workspacebash, and the prompt says so explicitly

Servers go in the background

bash({ command: "npm run dev -- --host", background: true, port: 5173 })
// → the terminal id, its first output, and a URL
# The Python bash tool runs one command and returns when it ends:
#   bash {"command": "npm test", "timeout_ms": 120000}
#   → {"exitCode": 0, "stdout": "…", "stderr": ""}
# A server that must keep running goes through terminal {"action": "create", "command": "npm run dev"}
  • Never in the foreground: a server that does not finish is killed at the timeout.
  • Never detached with nohup, & or a job — it would run where the user cannot see or stop it.
  • Make the server listen on all interfaces (--host, -H 0.0.0.0), or the URL answers nothing.

The exit code is the signal

The agent is told to check it and fix errors. A shell bridge that always returns zero makes every failure invisible.

It is not always there

On a phone or a cloud workspace with no shell bridge, the tool is not declared at all — nothing would run it.