The shape
const shell = {
async run(command, { timeoutMs, signal } = {}) {
// …run it somewhere…
return { stdout: "", stderr: "", exitCode: 0 };
},
};# The Python engine runs bash itself, on a LocalFiles workspace (subprocess in the
# workspace folder). A machine without a local workspace gets no bash tool.
pc = api.storage.get()
api.agents.create(runtime="local", machine=pc, model=model, tools=["read", "list", "bash"])commandstringWhat to run.
timeoutMsintegerWhat the tool asked for. Honour it — a command that never ends holds the run.
signalAbortSignalFires when the run is stopped. Kill the process.
returnsobject{ stdout, stderr, exitCode }. Anything else is refused at creation with invalid_shell.
The exit code is the contract
A bridge that always returns 0 makes every failure invisible: the agent reads the output, sees no failure, and carries on. Return the real code — it is the one signal that keeps a command loop honest.
It is still asked
bash is exec whatever runs it, so it is asked in every mode but full. One difference: an « always » on a supplied shell lasts for the session only — it is never written to this computer's permanent list, because the command did not run on this computer.
Say what the shell is
The system prompt describes the shell from the machine: a phone gets « a sandboxed bash-like shell » with its limits named; a cloud workspace is told the shell is Linux and the paths are POSIX. Getting this wrong is expensive — an agent that believes it is on another platform writes commands that all fail for one reason.
Without it
On a phone or a cloud workspace, no shell means no bash at all: the tool is not declared and the instructions about running commands disappear with it. On a computer, the machine's own shell is used.
Background commands need terminals
bash { background: true } starts something that outlives the answer, which needs terminals, not a shell. With a shell alone, a long-running server is started in the foreground, where the timeout kills it.