> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tokenfactory.nebius.com/llms.txt
> Use this file to discover all available pages before exploring further.

# operation - Manage operations

Manage operations under a single namespace. Aggregates `ps` (list),
`show` (inspect), and `kill` (cancel), and adds **multi-UUID support** to
`show` and `cancel` so several operations can be acted on in one call.

`op` is the short alias.

## Subcommands

| Subcommand              | Aliases     | Description                                                  |
| ----------------------- | ----------- | ------------------------------------------------------------ |
| `list`                  | `ls`        | List operations. Same flags as `contree ps`.                 |
| `show UUID [UUID...]`   | `sh`        | Show one or more operation results.                          |
| `wait UUID [UUID...]`   | `w`         | Wait for operations to reach a terminal status (or `--all`). |
| `cancel UUID [UUID...]` | `kill`, `k` | Cancel one or more operations (or `--all`).                  |

## Examples

```bash theme={null}
# List active operations (same as `contree ps`)
contree op list
contree op ls
contree op ls -a --status FAILED # all flags from ps are accepted

# Inspect a single operation
contree op show 3f2a7b...

# Inspect several operations at once
contree op show 3f2a7b... a1b2c3... 9d8e7f...

# History references (inherited from `contree show`)
contree op show @5 @4 @3

# Cancel one or more operations
contree op cancel 3f2a7b...
contree op cancel a1b2c3... 9d8e7f...

# Cancel every active operation
contree op cancel --all
```

## Help output

The top-level `op` command is a dispatcher: by itself it only prints
usage and routes to the three subcommands described below.

<div className="contree-terminal" style={{"border":"1px solid rgba(255,255,255,0.15)","borderRadius":8,"overflow":"hidden","margin":"1rem 0"}}><div style={{"background":"#292929","height":24,"display":"flex","alignItems":"center","padding":"0 12px","position":"relative"}}><div style={{"display":"flex","alignItems":"center","flexShrink":0}}><span style={{"display":"inline-block","width":10,"height":10,"borderRadius":"50%","background":"#ff5f57","marginRight":6}} /><span style={{"display":"inline-block","width":10,"height":10,"borderRadius":"50%","background":"#febc2e","marginRight":6}} /><span style={{"display":"inline-block","width":10,"height":10,"borderRadius":"50%","background":"#28c840"}} /></div><div style={{"position":"absolute","left":0,"right":0,"textAlign":"center","fontFamily":"-apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif","fontWeight":"bold","color":"#999"}}>\$ contree op --help</div></div><pre style={{"margin":0,"borderRadius":0,"padding":"8px 10px","background":"#1e1e1e","overflowX":"auto"}}><code style={{"fontFamily":"JetBrains Mono, SF Mono, SFMono-Regular, Menlo, Monaco, Cascadia Mono, Segoe UI Mono, Roboto Mono, Oxygen Mono, Ubuntu Monospace, Source Code Pro, Fira Mono, Droid Sans Mono, Consolas, Courier New, monospace","color":"#c5c8c6","whiteSpace":"pre-wrap"}}><span style={{"color":"#61afef","fontWeight":"bold"}}>usage: </span><span style={{"color":"#c678dd","fontWeight":"bold"}}>contree operation</span><span style={{"color":"#c5c8c6"}}> \[</span><span style={{"color":"#98c379"}}>-h</span><span style={{"color":"#c5c8c6"}}>] </span><span style={{"color":"#98c379"}}>\{list,ls,show,sh,cancel,kill,k,wait,w} ...</span><br /><br /><span style={{"color":"#c5c8c6"}}>Manage operations (list, inspect, cancel).</span><br /><br /><span style={{"color":"#c5c8c6"}}>Aggregates ps/show/kill under a single namespace, and adds multi-UUID</span><br /><span style={{"color":"#c5c8c6"}}>support to \`\`show\`\` and \`\`cancel\`\` so several operations can be acted</span><br /><span style={{"color":"#c5c8c6"}}>on in one invocation.</span><br /><br /><span style={{"color":"#c5c8c6"}}>Subcommands:</span><br /><span style={{"color":"#c5c8c6"}}>  list (ls)             List operations. \`\`contree ps\`\` is an alias.</span><br /><span style={{"color":"#c5c8c6"}}>  show UUID \[UUID...]   Show one or more operation results.</span><br /><span style={{"color":"#c5c8c6"}}>  cancel UUID \[UUID...] Cancel one or more operations (or --all).</span><br /><br /><span style={{"color":"#61afef","fontWeight":"bold"}}>positional arguments:</span><br /><span style={{"color":"#c5c8c6"}}>  </span><span style={{"color":"#98c379","fontWeight":"bold"}}>\{list,ls,show,sh,cancel,kill,k,wait,w}</span><br /><span style={{"color":"#c5c8c6"}}>    </span><span style={{"color":"#98c379","fontWeight":"bold"}}>list (ls)</span><span style={{"color":"#c5c8c6"}}>           List operations</span><br /><span style={{"color":"#c5c8c6"}}>    </span><span style={{"color":"#98c379","fontWeight":"bold"}}>show (sh)</span><span style={{"color":"#c5c8c6"}}>           Show one or more operation results</span><br /><span style={{"color":"#c5c8c6"}}>    </span><span style={{"color":"#98c379","fontWeight":"bold"}}>cancel (kill, k)</span><span style={{"color":"#c5c8c6"}}>    Cancel one or more operations</span><br /><span style={{"color":"#c5c8c6"}}>    </span><span style={{"color":"#98c379","fontWeight":"bold"}}>wait (w)</span><span style={{"color":"#c5c8c6"}}>            Wait for operations to reach a terminal status</span><br /><br /><span style={{"color":"#61afef","fontWeight":"bold"}}>options:</span><br /><span style={{"color":"#c5c8c6"}}>  </span><span style={{"color":"#98c379","fontWeight":"bold"}}>-h</span><span style={{"color":"#c5c8c6"}}>, </span><span style={{"color":"#56b6c2","fontWeight":"bold"}}>--help</span><span style={{"color":"#c5c8c6"}}>            show this help message and exit</span><br /><br /><span style={{"color":"#c5c8c6"}}>for coding agents:</span><br /><span style={{"color":"#c5c8c6"}}>  list/show are read-only; cancel mutates remote state</span><br /><span style={{"color":"#c5c8c6"}}>  show and cancel accept multiple UUIDs in one invocation</span><br /><span style={{"color":"#c5c8c6"}}>  show supports @N session-history references inherited from \`contree show\`</span><br /><br /><span style={{"color":"#c5c8c6"}}>agent note:</span><br /><span style={{"color":"#c5c8c6"}}>  Before using this command in an automated workflow, read:</span><br /><span style={{"color":"#c5c8c6"}}>    contree agent</span></code></pre></div>

## `op list` – dynamic columns

`contree op list` (alias `op ls`) accepts the same filter flags as
`contree ps` (`-a`, `--status STATUS`, `-K KIND`, `--since`,
`--until`, `-q`/`--quiet`) and shares its rendering pipeline. Reach
for it when you want the operations namespace to feel symmetric with
the multi-UUID `show` and `cancel`; otherwise `contree ps` is just
as good. `-S` is the global session flag and only works BEFORE the
subcommand.

<div className="contree-terminal" style={{"border":"1px solid rgba(255,255,255,0.15)","borderRadius":8,"overflow":"hidden","margin":"1rem 0"}}><div style={{"background":"#292929","height":24,"display":"flex","alignItems":"center","padding":"0 12px","position":"relative"}}><div style={{"display":"flex","alignItems":"center","flexShrink":0}}><span style={{"display":"inline-block","width":10,"height":10,"borderRadius":"50%","background":"#ff5f57","marginRight":6}} /><span style={{"display":"inline-block","width":10,"height":10,"borderRadius":"50%","background":"#febc2e","marginRight":6}} /><span style={{"display":"inline-block","width":10,"height":10,"borderRadius":"50%","background":"#28c840"}} /></div><div style={{"position":"absolute","left":0,"right":0,"textAlign":"center","fontFamily":"-apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif","fontWeight":"bold","color":"#999"}}>\$ contree op list --help</div></div><pre style={{"margin":0,"borderRadius":0,"padding":"8px 10px","background":"#1e1e1e","overflowX":"auto"}}><code style={{"fontFamily":"JetBrains Mono, SF Mono, SFMono-Regular, Menlo, Monaco, Cascadia Mono, Segoe UI Mono, Roboto Mono, Oxygen Mono, Ubuntu Monospace, Source Code Pro, Fira Mono, Droid Sans Mono, Consolas, Courier New, monospace","color":"#c5c8c6","whiteSpace":"pre-wrap"}}><span style={{"color":"#61afef","fontWeight":"bold"}}>usage: </span><span style={{"color":"#c678dd","fontWeight":"bold"}}>contree operation list</span><span style={{"color":"#c5c8c6"}}> \[</span><span style={{"color":"#98c379"}}>-h</span><span style={{"color":"#c5c8c6"}}>] \[</span><span style={{"color":"#98c379"}}>-q</span><span style={{"color":"#c5c8c6"}}>] \[</span><span style={{"color":"#98c379"}}>-a</span><span style={{"color":"#c5c8c6"}}>]</span><br /><span style={{"color":"#c5c8c6"}}>                              \[</span><span style={{"color":"#56b6c2"}}>--status </span><span style={{"color":"#e5c07b"}}>\{P,PENDING,A,ASSIGNED,E,EXECUTING,S,SUCCESS,F,FAILED,C,CANCELLED}</span><span style={{"color":"#c5c8c6"}}>]</span><br /><span style={{"color":"#c5c8c6"}}>                              \[</span><span style={{"color":"#98c379"}}>-k </span><span style={{"color":"#e5c07b"}}>\{image\_import,instance}</span><span style={{"color":"#c5c8c6"}}>] \[</span><span style={{"color":"#56b6c2"}}>--since </span><span style={{"color":"#e5c07b"}}>SINCE</span><span style={{"color":"#c5c8c6"}}>] \[</span><span style={{"color":"#56b6c2"}}>--until </span><span style={{"color":"#e5c07b"}}>UNTIL</span><span style={{"color":"#c5c8c6"}}>]</span><br /><span style={{"color":"#c5c8c6"}}>                              \[</span><span style={{"color":"#98c379"}}>-M </span><span style={{"color":"#e5c07b"}}>SHOW\_MAX</span><span style={{"color":"#c5c8c6"}}>]</span><br /><br /><span style={{"color":"#c5c8c6"}}>List operations. \`\`contree ps\`\` is an alias of this command.</span><br /><br /><span style={{"color":"#61afef","fontWeight":"bold"}}>options:</span><br /><span style={{"color":"#c5c8c6"}}>  </span><span style={{"color":"#98c379","fontWeight":"bold"}}>-h</span><span style={{"color":"#c5c8c6"}}>, </span><span style={{"color":"#56b6c2","fontWeight":"bold"}}>--help</span><span style={{"color":"#c5c8c6"}}>            show this help message and exit</span><br /><span style={{"color":"#c5c8c6"}}>  </span><span style={{"color":"#98c379","fontWeight":"bold"}}>-q</span><span style={{"color":"#c5c8c6"}}>, </span><span style={{"color":"#56b6c2","fontWeight":"bold"}}>--quiet</span><span style={{"color":"#c5c8c6"}}>           Only show UUIDs, useful for scripting</span><br /><span style={{"color":"#c5c8c6"}}>  </span><span style={{"color":"#98c379","fontWeight":"bold"}}>-a</span><span style={{"color":"#c5c8c6"}}>, </span><span style={{"color":"#56b6c2","fontWeight":"bold"}}>--all</span><span style={{"color":"#c5c8c6"}}>             Show all operations (default: active only)</span><br /><span style={{"color":"#c5c8c6"}}>  </span><span style={{"color":"#56b6c2","fontWeight":"bold"}}>--status</span><span style={{"color":"#c5c8c6"}}> </span><span style={{"color":"#e5c07b","fontWeight":"bold"}}>\{P,PENDING,A,ASSIGNED,E,EXECUTING,S,SUCCESS,F,FAILED,C,CANCELLED}</span><br /><span style={{"color":"#c5c8c6"}}>                        Filter by status (default: EXECUTING only, unless -a is used)</span><br /><span style={{"color":"#c5c8c6"}}>  </span><span style={{"color":"#98c379","fontWeight":"bold"}}>-k</span><span style={{"color":"#c5c8c6"}}>, </span><span style={{"color":"#56b6c2","fontWeight":"bold"}}>--kind</span><span style={{"color":"#c5c8c6"}}> </span><span style={{"color":"#e5c07b","fontWeight":"bold"}}>\{image\_import,instance}</span><br /><span style={{"color":"#c5c8c6"}}>                        Filter by operation kind</span><br /><span style={{"color":"#c5c8c6"}}>  </span><span style={{"color":"#56b6c2","fontWeight":"bold"}}>--since</span><span style={{"color":"#c5c8c6"}}> </span><span style={{"color":"#e5c07b","fontWeight":"bold"}}>SINCE</span><span style={{"color":"#c5c8c6"}}>         Parse +/- intervals (bare seconds or smhdMy) or ISO/date to UTC datetime.</span><br /><span style={{"color":"#c5c8c6"}}>  </span><span style={{"color":"#56b6c2","fontWeight":"bold"}}>--until</span><span style={{"color":"#c5c8c6"}}> </span><span style={{"color":"#e5c07b","fontWeight":"bold"}}>UNTIL</span><span style={{"color":"#c5c8c6"}}>         Show operations before. Parse +/- intervals (bare seconds or smhdMy) or</span><br /><span style={{"color":"#c5c8c6"}}>                        ISO/date to UTC datetime.</span><br /><span style={{"color":"#c5c8c6"}}>  </span><span style={{"color":"#98c379","fontWeight":"bold"}}>-M</span><span style={{"color":"#c5c8c6"}}>, </span><span style={{"color":"#56b6c2","fontWeight":"bold"}}>--show-max</span><span style={{"color":"#c5c8c6"}}> </span><span style={{"color":"#e5c07b","fontWeight":"bold"}}>SHOW\_MAX</span><br /><span style={{"color":"#c5c8c6"}}>                        Show at most this many operations, useful for --all with large history</span><br /><span style={{"color":"#c5c8c6"}}>                        (default: 1000)</span><br /><br /><span style={{"color":"#c5c8c6"}}>for coding agents: read-only command</span></code></pre></div>

The listing renders **every scalar top-level field** the API returns,
not a hard-coded subset. When the server adds a new field (for example
`cost`, `project_id`, `started_at`), it appears in the output without a
CLI release. Nested structures (`metadata`, `result`, `tags`) are
filtered out – use `op show UUID` for the detail view.

Known fields are lightly typed:

| Field                                                   | Transform                                          |
| ------------------------------------------------------- | -------------------------------------------------- |
| `created_at`, `started_at`, `finished_at`, `updated_at` | parsed to UTC datetime                             |
| `duration`                                              | wrapped as `timedelta` (`total_seconds()` in JSON) |
| `error`                                                 | `None` is rendered as empty string                 |

Column order follows the API response, with one exception: **`error`
is pinned to the last column**. Long free-form error messages would
otherwise push the rest of the row out of alignment.

## `op show` – multiple UUIDs

Each UUID is fetched and rendered through the same code path as
`contree show`, so cached terminal results and history references work
uniformly. Accepted reference forms (mirroring `session rollback`
syntax with a git-style alias):

* `@`, `:`, or `HEAD` – the operation at the active branch tip.
* `@N` (or `:N`, bare `N`) – absolute history id.
* `@-N`, `:-N`, or `HEAD~N` – walk N steps back from the tip.
* `HEAD~` – shorthand for `HEAD~1`.
* `@+N` (or `:+N`) – walk N steps forward from the tip, picking the
  latest child at each branch point.

On API errors (e.g. 404 for an unknown UUID), the command logs the
failure and continues with the remaining UUIDs, exiting with status
`1` at the end.

<div className="contree-terminal" style={{"border":"1px solid rgba(255,255,255,0.15)","borderRadius":8,"overflow":"hidden","margin":"1rem 0"}}><div style={{"background":"#292929","height":24,"display":"flex","alignItems":"center","padding":"0 12px","position":"relative"}}><div style={{"display":"flex","alignItems":"center","flexShrink":0}}><span style={{"display":"inline-block","width":10,"height":10,"borderRadius":"50%","background":"#ff5f57","marginRight":6}} /><span style={{"display":"inline-block","width":10,"height":10,"borderRadius":"50%","background":"#febc2e","marginRight":6}} /><span style={{"display":"inline-block","width":10,"height":10,"borderRadius":"50%","background":"#28c840"}} /></div><div style={{"position":"absolute","left":0,"right":0,"textAlign":"center","fontFamily":"-apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif","fontWeight":"bold","color":"#999"}}>\$ contree op show --help</div></div><pre style={{"margin":0,"borderRadius":0,"padding":"8px 10px","background":"#1e1e1e","overflowX":"auto"}}><code style={{"fontFamily":"JetBrains Mono, SF Mono, SFMono-Regular, Menlo, Monaco, Cascadia Mono, Segoe UI Mono, Roboto Mono, Oxygen Mono, Ubuntu Monospace, Source Code Pro, Fira Mono, Droid Sans Mono, Consolas, Courier New, monospace","color":"#c5c8c6","whiteSpace":"pre-wrap"}}><span style={{"color":"#61afef","fontWeight":"bold"}}>usage: </span><span style={{"color":"#c678dd","fontWeight":"bold"}}>contree operation show</span><span style={{"color":"#c5c8c6"}}> \[</span><span style={{"color":"#98c379"}}>-h</span><span style={{"color":"#c5c8c6"}}>] \[</span><span style={{"color":"#56b6c2"}}>--raw</span><span style={{"color":"#c5c8c6"}}>] </span><span style={{"color":"#98c379"}}>UUID\_OR\_REF \[UUID\_OR\_REF ...]</span><br /><br /><span style={{"color":"#c5c8c6"}}>Fetch and display the result of each given operation. Same per-UUID behaviour as \`contree show\`:</span><br /><span style={{"color":"#c5c8c6"}}>terminal results are cached; @N references resolve against session history.</span><br /><br /><span style={{"color":"#61afef","fontWeight":"bold"}}>positional arguments:</span><br /><span style={{"color":"#c5c8c6"}}>  </span><span style={{"color":"#98c379","fontWeight":"bold"}}>UUID\_OR\_REF</span><span style={{"color":"#c5c8c6"}}>  Operations to inspect. Accepts UUIDs and session-history references: @ or HEAD for</span><br /><span style={{"color":"#c5c8c6"}}>               the active branch tip, @N for an absolute history id, @-N or HEAD\~N for N steps</span><br /><span style={{"color":"#c5c8c6"}}>               back, @+N for N steps forward.</span><br /><br /><span style={{"color":"#61afef","fontWeight":"bold"}}>options:</span><br /><span style={{"color":"#c5c8c6"}}>  </span><span style={{"color":"#98c379","fontWeight":"bold"}}>-h</span><span style={{"color":"#c5c8c6"}}>, </span><span style={{"color":"#56b6c2","fontWeight":"bold"}}>--help</span><span style={{"color":"#c5c8c6"}}>   show this help message and exit</span><br /><span style={{"color":"#c5c8c6"}}>  </span><span style={{"color":"#56b6c2","fontWeight":"bold"}}>--raw</span><span style={{"color":"#c5c8c6"}}>        Print each operation's full server payload as JSONL (one JSON object per line) to</span><br /><span style={{"color":"#c5c8c6"}}>               stdout, verbatim. Skips formatter routing and derived columns; streams cleanly into</span><br /><span style={{"color":"#c5c8c6"}}>               \`jq -c\`. Useful for debugging or for fields the table view omits.</span><br /><br /><span style={{"color":"#c5c8c6"}}>for coding agents: read-only command accepts multiple UUIDs; each rendered as its own row</span></code></pre></div>

<Note>
  With table output (`-f table`) and several UUIDs, each operation
  currently renders as its own mini-table. Use `default` or `json` for a
  unified stream view across multiple UUIDs.
</Note>

## `op wait` – block until completion

Poll the given operations until each reaches a terminal status
(`SUCCESS`, `FAILED`, `CANCELLED`) and print one row per completion
with the columns `uuid`, `status`, `exit_code`, `timed_out`,
`duration` (and every other scalar field the API returns; `error` is
pinned to the last column).

`--all` waits for every currently active operation in the project.
`--timeout SECONDS` (default `60`) caps the wait — when the deadline
hits, the command emits one extra row per unfinished operation with
`timed_out=true` and the operation’s last observed status (e.g.
`EXECUTING`), then exits with status `1`.

`status` is the server’s word: it reflects orchestration (did the
API run the job?), not what the sandbox process did with its exit
code. The exit code is a separate column. The CLI’s own exit status
is `1` whenever any operation finished non-`SUCCESS`, or the actual
`exit_code` when a `SUCCESS` op exited non-zero — so
`op wait UUID && next-step` composes correctly with sandbox commands
like `run -- false`.

<Info>
  `op wait` is a **pure observer**: it polls operation status and
  prints rows, but it **never updates session state**. In particular,
  the `detached-<op-uuid>` branch created when you ran
  `contree run -d` keeps pointing at the **starting** image — `op wait` does not advance it to the result image. The pattern therefore
  fits non-image-producing runs (`--disposable`) most cleanly; for
  non-disposable fan-out, the result image of each leg lives only on
  the server and you must recover it explicitly (see the non-disposable
  example below).
</Info>

<Warning>
  `--all` is **project-scoped**. If multiple agents (or multiple shell
  sessions) share the same project, `op wait --all` will block on every
  active operation across all of them — not just the ones you launched.
  The wait still completes correctly; it just waits for more than you
  might expect. For multi-agent setups, prefer the explicit
  `op wait UUID1 UUID2 ...` form with the UUIDs you actually own.
</Warning>

<div className="contree-terminal" style={{"border":"1px solid rgba(255,255,255,0.15)","borderRadius":8,"overflow":"hidden","margin":"1rem 0"}}><div style={{"background":"#292929","height":24,"display":"flex","alignItems":"center","padding":"0 12px","position":"relative"}}><div style={{"display":"flex","alignItems":"center","flexShrink":0}}><span style={{"display":"inline-block","width":10,"height":10,"borderRadius":"50%","background":"#ff5f57","marginRight":6}} /><span style={{"display":"inline-block","width":10,"height":10,"borderRadius":"50%","background":"#febc2e","marginRight":6}} /><span style={{"display":"inline-block","width":10,"height":10,"borderRadius":"50%","background":"#28c840"}} /></div><div style={{"position":"absolute","left":0,"right":0,"textAlign":"center","fontFamily":"-apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif","fontWeight":"bold","color":"#999"}}>\$ contree op wait --help</div></div><pre style={{"margin":0,"borderRadius":0,"padding":"8px 10px","background":"#1e1e1e","overflowX":"auto"}}><code style={{"fontFamily":"JetBrains Mono, SF Mono, SFMono-Regular, Menlo, Monaco, Cascadia Mono, Segoe UI Mono, Roboto Mono, Oxygen Mono, Ubuntu Monospace, Source Code Pro, Fira Mono, Droid Sans Mono, Consolas, Courier New, monospace","color":"#c5c8c6","whiteSpace":"pre-wrap"}}><span style={{"color":"#61afef","fontWeight":"bold"}}>usage: </span><span style={{"color":"#c678dd","fontWeight":"bold"}}>contree operation wait</span><span style={{"color":"#c5c8c6"}}> \[</span><span style={{"color":"#98c379"}}>-h</span><span style={{"color":"#c5c8c6"}}>] \[</span><span style={{"color":"#98c379"}}>-a</span><span style={{"color":"#c5c8c6"}}>] \[</span><span style={{"color":"#98c379"}}>-t </span><span style={{"color":"#e5c07b"}}>TIMEOUT</span><span style={{"color":"#c5c8c6"}}>] </span><span style={{"color":"#98c379"}}>\[UUID\_OR\_REF ...]</span><br /><br /><span style={{"color":"#c5c8c6"}}>Poll the given operations until each reaches a terminal status (SUCCESS, FAILED, CANCELLED) and</span><br /><span style={{"color":"#c5c8c6"}}>print one row per completion. With --all, waits for every currently active operation (PENDING,</span><br /><span style={{"color":"#c5c8c6"}}>ASSIGNED, EXECUTING).</span><br /><br /><span style={{"color":"#61afef","fontWeight":"bold"}}>positional arguments:</span><br /><span style={{"color":"#c5c8c6"}}>  </span><span style={{"color":"#98c379","fontWeight":"bold"}}>UUID\_OR\_REF</span><span style={{"color":"#c5c8c6"}}>           Operations to wait for. Accepts UUIDs and session-history references</span><br /><span style={{"color":"#c5c8c6"}}>                        (HEAD, HEAD\~N, @, @N, @-N, @+N, :N, bare N).</span><br /><br /><span style={{"color":"#61afef","fontWeight":"bold"}}>options:</span><br /><span style={{"color":"#c5c8c6"}}>  </span><span style={{"color":"#98c379","fontWeight":"bold"}}>-h</span><span style={{"color":"#c5c8c6"}}>, </span><span style={{"color":"#56b6c2","fontWeight":"bold"}}>--help</span><span style={{"color":"#c5c8c6"}}>            show this help message and exit</span><br /><span style={{"color":"#c5c8c6"}}>  </span><span style={{"color":"#98c379","fontWeight":"bold"}}>-a</span><span style={{"color":"#c5c8c6"}}>, </span><span style={{"color":"#56b6c2","fontWeight":"bold"}}>--all</span><span style={{"color":"#c5c8c6"}}>             Wait for every active operation</span><br /><span style={{"color":"#c5c8c6"}}>  </span><span style={{"color":"#98c379","fontWeight":"bold"}}>-t</span><span style={{"color":"#c5c8c6"}}>, </span><span style={{"color":"#56b6c2","fontWeight":"bold"}}>--timeout</span><span style={{"color":"#c5c8c6"}}> </span><span style={{"color":"#e5c07b","fontWeight":"bold"}}>TIMEOUT</span><br /><span style={{"color":"#c5c8c6"}}>                        Fail with exit code 1 if not all operations reach a terminal status within</span><br /><span style={{"color":"#c5c8c6"}}>                        this many seconds (default: 60)</span><br /><br /><span style={{"color":"#c5c8c6"}}>for coding agents: read-only command (polls the API; no state mutation) fails with exit code 1 if</span><br /><span style={{"color":"#c5c8c6"}}>--timeout is hit before all complete exit code 1 also when any operation finished non-SUCCESS</span></code></pre></div>

Preferred — `--disposable` fan-out, no image to track. Note the
global `-f json` before `run` so `jq` sees JSON; the default
formatter is plain.

```bash theme={null}
A=$(contree -f json run -d --disposable -- pytest tests/a | jq -r .uuid)
B=$(contree -f json run -d --disposable -- pytest tests/b | jq -r .uuid)
C=$(contree -f json run -d --disposable -- pytest tests/c | jq -r .uuid)
contree op wait "$A" "$B" "$C"
contree op show "$A" "$B" "$C"          # stdout/stderr per leg
```

Non-disposable fan-out — must recover the chosen leg’s image yourself:

```bash theme={null}
A=$(contree -f json run -d -- apt-get install -y curl | jq -r .uuid)
B=$(contree -f json run -d -- apt-get install -y wget | jq -r .uuid)
contree op wait "$A" "$B"

# Pull the result image out and bind it back into the session,
# or tag it for later reuse.
IMG_A=$(contree -f json op show "$A" | jq -r .image)
contree use "$IMG_A"
contree tag "$IMG_A" feature/curl-tools
```

Block on the whole project (5 min cap):

```bash theme={null}
contree op wait --all --timeout 300
```

## `op cancel` – multiple UUIDs or `--all`

Either pass UUIDs explicitly or use `--all` to cancel every active
operation (`PENDING`, `ASSIGNED`, `EXECUTING`). Combining both is allowed:
`--all` wins, and the explicit UUIDs are ignored with a `WARNING`. As
with `op show`, errors on individual UUIDs do not abort the run; the
command exits `1` if any cancellation failed.

<div className="contree-terminal" style={{"border":"1px solid rgba(255,255,255,0.15)","borderRadius":8,"overflow":"hidden","margin":"1rem 0"}}><div style={{"background":"#292929","height":24,"display":"flex","alignItems":"center","padding":"0 12px","position":"relative"}}><div style={{"display":"flex","alignItems":"center","flexShrink":0}}><span style={{"display":"inline-block","width":10,"height":10,"borderRadius":"50%","background":"#ff5f57","marginRight":6}} /><span style={{"display":"inline-block","width":10,"height":10,"borderRadius":"50%","background":"#febc2e","marginRight":6}} /><span style={{"display":"inline-block","width":10,"height":10,"borderRadius":"50%","background":"#28c840"}} /></div><div style={{"position":"absolute","left":0,"right":0,"textAlign":"center","fontFamily":"-apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif","fontWeight":"bold","color":"#999"}}>\$ contree op cancel --help</div></div><pre style={{"margin":0,"borderRadius":0,"padding":"8px 10px","background":"#1e1e1e","overflowX":"auto"}}><code style={{"fontFamily":"JetBrains Mono, SF Mono, SFMono-Regular, Menlo, Monaco, Cascadia Mono, Segoe UI Mono, Roboto Mono, Oxygen Mono, Ubuntu Monospace, Source Code Pro, Fira Mono, Droid Sans Mono, Consolas, Courier New, monospace","color":"#c5c8c6","whiteSpace":"pre-wrap"}}><span style={{"color":"#61afef","fontWeight":"bold"}}>usage: </span><span style={{"color":"#c678dd","fontWeight":"bold"}}>contree operation cancel</span><span style={{"color":"#c5c8c6"}}> \[</span><span style={{"color":"#98c379"}}>-h</span><span style={{"color":"#c5c8c6"}}>] \[</span><span style={{"color":"#98c379"}}>-a</span><span style={{"color":"#c5c8c6"}}>] </span><span style={{"color":"#98c379"}}>\[UUID\_OR\_REF ...]</span><br /><br /><span style={{"color":"#c5c8c6"}}>Cancel each given operation. With --all, cancels every active operation (PENDING, ASSIGNED,</span><br /><span style={{"color":"#c5c8c6"}}>EXECUTING).</span><br /><br /><span style={{"color":"#61afef","fontWeight":"bold"}}>positional arguments:</span><br /><span style={{"color":"#c5c8c6"}}>  </span><span style={{"color":"#98c379","fontWeight":"bold"}}>UUID\_OR\_REF</span><span style={{"color":"#c5c8c6"}}>  Operations to cancel. Accepts UUIDs and session-history references (HEAD, HEAD\~N,</span><br /><span style={{"color":"#c5c8c6"}}>               @, @N, @-N, @+N, :N, bare N).</span><br /><br /><span style={{"color":"#61afef","fontWeight":"bold"}}>options:</span><br /><span style={{"color":"#c5c8c6"}}>  </span><span style={{"color":"#98c379","fontWeight":"bold"}}>-h</span><span style={{"color":"#c5c8c6"}}>, </span><span style={{"color":"#56b6c2","fontWeight":"bold"}}>--help</span><span style={{"color":"#c5c8c6"}}>   show this help message and exit</span><br /><span style={{"color":"#c5c8c6"}}>  </span><span style={{"color":"#98c379","fontWeight":"bold"}}>-a</span><span style={{"color":"#c5c8c6"}}>, </span><span style={{"color":"#56b6c2","fontWeight":"bold"}}>--all</span><span style={{"color":"#c5c8c6"}}>    Cancel every active operation</span><br /><br /><span style={{"color":"#c5c8c6"}}>for coding agents: mutating command pass UUIDs to cancel specific operations or --all for</span><br /><span style={{"color":"#c5c8c6"}}>everything</span></code></pre></div>

```bash theme={null}
# Mixed: --all still wins, "ignored-1" is not cancelled
contree op cancel --all ignored-1
```

## Comparison with the top-level commands

`contree ps` and `contree kill` are top-level **shortcuts** that share
the same argparse setup and handler as `op list` / `op cancel`
respectively — there is no separate implementation. `contree show`
keeps its own single-UUID handler (the multi-UUID `op show` wraps it).

| Need                       | Use                                                                     |
| -------------------------- | ----------------------------------------------------------------------- |
| List active operations     | `contree ps` *or* `contree op ls`                                       |
| Inspect one operation      | `contree show UUID` *or* `contree op show UUID`                         |
| Inspect multiple           | `contree op show UUID1 UUID2 ...`                                       |
| Block on multiple          | `contree op wait UUID1 UUID2 ...`                                       |
| Block on everything active | `contree op wait --all`                                                 |
| Cancel one operation       | `contree kill UUID` *or* `contree op cancel UUID`                       |
| Cancel multiple            | `contree kill UUID1 UUID2 ...` *or* `contree op cancel UUID1 UUID2 ...` |
| Cancel everything active   | `contree kill --all` *or* `contree op cancel --all`                     |

## See also

* [ps - List activity](./ps) – top-level shortcut for `op list`
* [show - Inspect an operation](./show) – single-UUID inspect (delegated to by `op show`)
* [kill - Cancel operations](./kill) – top-level shortcut for `op cancel`
* [run - Execute a command in the sandbox](./run) – the command that creates operations
