# terminal

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

`terminal({ action: "list" | "output" | "kill", id?, since? })`

The terminals a run started or the user opened. Reading them is free; killing one is a command — the category depends on the action.

Status: read, or exec on kill · survives the answer · never on a phone

| Name | Type | Requirement | Description |
| --- | --- | --- | --- |
| `action` | string | required | `list` · `output` · `kill`. |
| `id` | string |  | The terminal, e.g. `t_3`. Needed by `output` and `kill`. |
| `since` | integer |  | `output`: read from this position. `0` gives everything kept. |

## Two categories in one tool {#categories}

| Action | Category | Asked |
| --- | --- | --- |
| `list` | read | never |
| `output` | read | never |
| `kill` | exec | in every mode but full |

Reading what a server is printing should not need a prompt; stopping it should. The category is computed from the arguments.

## The working loop {#loop}

```javascript
terminal({ action: "list" })                       // is it already running?
bash({ command: "npm run dev", background: true, port: 5173 })
terminal({ action: "output", id: "t_3" })          // what did it print since last time?
terminal({ action: "kill", id: "t_3" })            // stop it and everything it started
```

> **List before starting**
>
> The agent is told to check for a server that may already be running rather than starting a second one on the same port — which fails in a way that looks like the code is broken.

## They live in your process {#lifetime}

A terminal survives an answer, not a restart of whatever holds the package. Worth saying in any interface that lists them.

## Where there are none {#absent}

Never on a phone. On a cloud workspace only when the application supplies [terminals](/sdk/agent/bridges/terminals). On a computer, from the machine itself.

- [bash](/sdk/agent/tools/bash): Starting one.
- [terminals](/sdk/agent/bridges/terminals): Supplying your own.
- [Agent tools](/sdk/agent/tools): The 35, by family.

```python
# The calls the model makes, in order:
#   terminal {"action": "list"}                                  is it already running?
#   terminal {"action": "create", "command": "npm run dev"}      start it
#   terminal {"action": "output", "id": "t_3"}                   what did it print since last time?
#   terminal {"action": "kill", "id": "t_3"}                     stop it and everything it started
```
