# shell

Canonical URL: https://developers.iagenify.com/sdk/agent/bridges/shell/
Language: en

`shell: { run(command, { timeoutMs, signal }) }`

One function, and bash exists somewhere other than this machine. It replaces the computer's own shell wherever you supply it.

Status: one function · exit code matters · always asked

## The shape {#shape}

```javascript
const shell = {
  async run(command, { timeoutMs, signal } = {}) {
    // …run it somewhere…
    return { stdout: "", stderr: "", exitCode: 0 };
  },
};
```

| Name | Type | Requirement | Description |
| --- | --- | --- | --- |
| `command` | string |  | What to run. |
| `timeoutMs` | integer |  | What the tool asked for. Honour it — a command that never ends holds the run. |
| `signal` | AbortSignal |  | Fires when the run is stopped. Kill the process. |
| `returns` | object |  | `{ stdout, stderr, exitCode }`. Anything else is refused at creation with `invalid_shell`. |

## The exit code is the contract {#exitcode}

> **The agent is instructed to check it and fix errors**
>
> 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 {#permission}

`bash` is [exec](/sdk/agent/permissions/categories/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 {#prompt}

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

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

`bash { background: true }` starts something that outlives the answer, which needs [terminals](/sdk/agent/bridges/terminals), not a shell. With a shell alone, a long-running server is started in the foreground, where the timeout kills it.

- [bash](/sdk/agent/tools/bash): The tool.
- [terminals](/sdk/agent/bridges/terminals): For anything that must keep running.

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