# bash

Canonical URL: https://developers.iagenify.com/sdk/agent/tools/bash/
Language: en

`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.

Status: category: exec · 120 s, max 600 s · always asked outside full

| Name | Type | Requirement | Description |
| --- | --- | --- | --- |
| `command` | string |  | One command. |
| `commands` | string[] |  | Several, run in order, **in one call**. |
| `timeout_ms` | integer | 120 000 | Per command. 600 000 at most. |
| `stop_on_error` | boolean | true | Stop the sequence at the first non-zero exit code. |
| `background` | boolean | false | Run in a terminal that outlives the answer. One command only. |
| `port` | integer |  | With `background`: the port the server listens on. The terminal publishes it and returns a URL. |
| `description` | string |  | A five-word summary, shown to the user. |

## Several commands in one call {#batching}

> **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 {#shell}

| Where | Shell |
| --- | --- |
| A computer running Windows | PowerShell |
| A computer elsewhere | bash |
| A supplied [shell bridge](/sdk/agent/bridges/shell) | whatever your bridge runs |
| A cloud workspace | bash, and the prompt says so explicitly |

## Servers go in the background {#servers}

```javascript
bash({ command: "npm run dev -- --host", background: true, port: 5173 })
// → the terminal id, its first output, and a URL
```

- 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 {#exit}

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 {#absent}

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

- [terminal](/sdk/agent/tools/terminal): Following what a background command is doing.
- [exec](/sdk/agent/permissions/categories/exec): Why it is asked in auto.
- [Agent tools](/sdk/agent/tools): The 35, by family.

```python
# 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"}
```
