# Terminal

Bub provides two terminal commands that share the same model, tools, and Tape storage:

- `bub run`: processes a single message and exits; suited for one-off tasks and scripts.
- `bub chat`: starts an interactive REPL for multi-turn conversations.

## Start an interactive session {#start-session}

Run the following command in your terminal to open an interactive session, then type a message and press Enter to send it:

```bash
bub chat
```

You can also pass an initial prompt at startup:

```bash
bub chat "Inspect this repository and suggest a first task."
```

Type `,help` to list internal commands. Press <kbd>Ctrl+D</kbd> or enter `,quit` or `,exit` to leave.

The bottom status bar shows metrics for the latest model call:

- `ttft` (time to first token): elapsed time before the first streamed chunk arrives.
- `speed`: average output tokens per second from the first chunk to the end of the response (includes reasoning tokens; excludes `ttft` and tool execution time; shows `speed:- tok/s` if the provider omits usage).

## Steer a running agent {#steering}

If the agent starts going off track while you are waiting for a response or tool call—or if you want to add a quick constraint—you do not have to wait for the current turn to finish. Just type your new instruction and press Enter:

```text
Do not modify files yet. List the problems and suggestions first.
```

Adding instructions while a Turn is still running is called **Steering**. Bub places the message in the steering inbox; in-flight model or tool calls are not interrupted, and the agent reads the new instruction on the very next Step.

When a session is busy, Bub supports two admission actions:

| Action | When it takes effect | Use it for |
| --- | --- | --- |
| `steer` | Injected into the next Step of the current Turn (or queued for the next Turn if the current Turn finishes first) | Correcting direction, adding constraints, or supplying info for the current task |
| `follow_up` | Queued and run as a new Turn in order after the current Turn finishes | Queuing an independent next task |

In `bub chat`, ordinary input entered during a run uses `steer` by default. To abort the running task immediately, enter `,quit` (clears the pending queue and cancels active tasks).

## View and adjust reasoning {#reasoning}

Expand or collapse the model's reasoning output in the terminal (display-only):

```text
,thinking
```

Change the model's reasoning effort (takes effect on the next Turn and persists in the session Tape):

```text
,reasoning_effort high
```

## Choose a session ID {#choose-session}

`bub run` defaults to session ID `cli:local`, while `bub chat` defaults to `cli_session`. Pass `--session-id` to share history between them:

```bash
bub chat --session-id cli:echo
bub run --session-id cli:echo "Summarize what we discussed."
```

## Run direct commands {#commands}

Input starting with `,` (the default command prefix) skips the model and calls the matching tool directly:

```bash
bub run ",help"
bub run ",fs.read path=README.md"
```

You can enter commands directly inside `bub chat` as well. Press <kbd>Ctrl+X</kbd> to toggle between Agent mode and Shell mode (Shell mode prepends `,` automatically). Common commands include:

| Command | Purpose |
| --- | --- |
| `,model openai:gpt-5-mini` | Switch the model for the current session |
| `,reasoning_effort high` | Set reasoning effort for the current session |
| `,code_mode enable=true` | Enable code mode |
| `,tape.info` | Show entry count, anchors, and token usage |
| `,tape.search query=error` | Search current session history |
| `,tape.anchors` | List context anchors |
| `,tape.handoff name=reviewed summary='...'` | Advance the default context start and save a summary |
| `,tape.reset archive=true` | Back up and clear the current Tape |
| `,thinking` | Expand or collapse reasoning output |

Notes:

- `,tape.reset archive=true` backs up the main Tape and sidecar to `<BUB_HOME>/tapes/` with a UTC timestamp and `.bak` suffix, then resets the Tape with a new `session/start` anchor. Omitting `archive=true` clears without backing up.
- `,tape.handoff` advances the context start and stores `summary` in the anchor's `state`, without automatically generating a summary. See [Tape](/docs/concepts/tape/#anchors).

:::caution
Unregistered comma commands are passed to `bash`. Before running an unfamiliar command, make sure it is a shell command you intend to execute.
:::

## Run background processes {#background-shell}

In `bub chat`, pass `background=true` to start a long-running command in the background:

```text
,bash command='npm run dev' background=true
```

Use the returned `shell_id` to read output incrementally or stop the process:

```text
,bash.output shell_id=bsh-12345678
,bash.output shell_id=bsh-12345678 offset=1200 limit=4000
,bash.kill shell_id=bsh-12345678
```

- `offset` and `limit` are **character offsets** (not line numbers); pass the returned `next_offset` to the next read.
- Foreground `bash` calls wait **30 seconds** by default (configurable via `timeout_seconds`). On timeout, the process moves to the background and returns a `shell_id` instead of failing. Background processes are cleaned up when the app exits.