# Run work in the background (/background-tasks)



Some commands keep running, like a dev server, or take a while, like a full test run. They can go on in the
background while you and the agent keep working.

## Start something in the background [#start-something-in-the-background]

Ask for it, and the agent starts it in the background:

```text
start the dev server
```

A line above the prompt says what runs and for how long:

```text
 > start the dev server                                                                     

 A dev server keeps running, so it goes in the background and the conversation goes on.

+------------------------------------------------------------------------------------------+
| $ pnpm dev                                                                               |
+--- Output -------------------------------------------------------------------------------+
| [In the background | alt+4 to see it]                                                   |
+------------------------------------------------------------------------------------------+

 The dev server runs in the background on http://localhost:3000. alt+4 shows its output,
 and x there stops it; I keep it running while we work.

 bg [│] pnpm dev 0s · alt+4

--------------------------------------------------------------------------------------------
 Ask jinion anything · / commands · $ skills · @ files
--- Accept edits · shift+tab ---------------------------------------------------------------
 jinion · [M] Opus 5.5 · high · [D] code/api · ctx: 23K/200K · $0.09   Start the dev server
```

A command or subagent the turn is already waiting on can go to the background too. After it has run a few seconds,
the working line above the prompt reads `Running bash · ctrl+b to run it in the background`. Press `ctrl+b`, and
the turn goes on without waiting for it.

## Follow and stop tasks [#follow-and-stop-tasks]

Press `alt+4`, or type `/tasks`, to open the tasks panel. It lists every task of the conversation with how it ended,
and the latest output of the one you're on.

```text
+- Background tasks 1 running -------------------------------------------------------------+
| > 1. [│] pnpm dev                                                                     1s |
|      > acme-api@1.4.0 dev                                                                |
|      > tsx watch src/server.ts                                                           |
|                                                                                          |
|      [watch] starting `node src/server.ts`                                               |
|      Server listening on http://localhost:3000                                           |
|                                                                                          |
+------------------------------------------------------------------------------------------+
| Enter output · x stop · Up/Down move · Esc close                                         |
+------------------------------------------------------------------------------------------+
```

| Key     | Does                                      |
| ------- | ----------------------------------------- |
| `enter` | Shows the whole output, following its end |
| `x`     | Stops the task                            |
| `esc`   | Closes the panel; tasks keep running      |

In the output, `up`, `down`, `pgup` and `pgdn` scroll, `x` stops the task, and `esc` goes back to the list. A subagent
shows as `Agent · ` and what it does, with its tool calls so far instead of output.

## When a task ends [#when-a-task-ends]

The conversation says so, such as `[!] Background pnpm test · failed after 41s · exit 1`, and the agent looks at the
result in a turn of its own. If the window isn't focused, you get a [notification](/notifications).

<Callout>
  Tasks belong to the session. They stop with `/clear`, `/resume`, a [rewind](/conversations/rewind) of the
  conversation, an account switch, or when you quit. `esc` stops the turn but leaves background tasks running.
</Callout>

## Subagents [#subagents]

When the agent hands part of the work to a subagent, the subagent's tool calls grow as a tree under
`Agent · what it is doing`, the latest six in view. When it is done, the tree folds into a line such as
`6 tool calls · 34s`; click it to open it again. Subagents can run in the background like commands.
