# Builds and chat

> Follow a generation, talk to its agent, and recover when a build fails.

A **build** is one generation of a CLI. In the terminal, okibi calls it a run (`okibi runs`, `<run-id>`). You can talk to the agent while it works, from the app's chat or with `okibi message`.

## Stages and statuses

A CLI created in the app builds v1 straight from its OpenAPI spec, with no chat. Its ready page lists each step as it runs, then agent ready optimization's suggestions. See [Create a CLI](https://okibi.ai/docs/guides/create-a-cli.md).

A build that an agent runs, such as one from `okibi generate`, moves through four stages. `okibi status` prints the finer steps inside each one.

| Stage in the app | Steps okibi prints | What happens |
| --- | --- | --- |
| Generate | `research`, `absorb`, `scaffold`, `generate` | The agent reads the source and writes the commands |
| Validate | `verify` | The CLI is built and checked |
| Package | `dogfood` | The built CLI runs in live checks |
| Publish | `ship` | The version and its installer are published |

| In the app | In okibi | Meaning |
| --- | --- | --- |
| Queued | `queued` | Waiting to start |
| Building | `running` | Working through the stages |
| Needs review | `awaiting-spec-approval` | Paused on the spec. See [Approve the spec](https://okibi.ai/docs/guides/approve-the-spec.md) |
| Built | `succeeded` | Finished |
| Failed | `failed` | Stopped. The app shows the stage where it stopped |
| Cancelled | `cancelled` | Someone cancelled it |

## Follow builds

**In the app**

Open the project and click **Builds**. Builds are listed beside the one you pick, which shows its steps, what it made, and what to do next. **Load older builds** shows more.

![A successful build on the Builds page, with Try your CLI and Reopen session](https://okibi.ai/docs-screens/run.webp)

The picked build offers what fits it, such as **View logs**, **Try it**, **Connect this version (MCP)**, **Cancel**, and **Delete**. To install a version, use the project's **CLI** page.

**In the CLI**

```sh
okibi runs --cli my-cli
okibi status <run-id>
okibi pull <run-id> --out ./my-cli
okibi runs cancel <run-id> --yes
```
`okibi runs` lists recent builds in one workspace (25 by default, 50 at most). `okibi runs history my-cli` pages through older ones. `okibi pull` works once the build has succeeded.

## Chat with the agent

**In the app**

A build that an agent runs has a chat. Click **Reopen session** on the newest build, or **Reopen chat** in an older build's menu. A v1 build from a spec has no chat.

- While the agent works, the box reads "Okibi is working · steer anytime". Your messages wait in a queue. **Steer now** sends the next one right away.
- An idle session goes to sleep. Send a message to wake it.
- Once the build's sandbox is gone, the chat opens read-only with the saved conversation.

**In the CLI**

```sh
okibi message <run-id> --text "Add a whoami command" --wait
okibi message status <run-id> <message-id>
```
- Works for queued and running builds from any source. The agent picks the message up at its next safe point. Messages are 16 KiB at most, and `--file -` reads one from stdin.
- `--wait` waits until the agent accepts the message (30 seconds by default, `--timeout` to change). Accepted does not mean done: follow the build with `okibi status`.
- Reuse the same `--request-id` and text to retry without sending twice. See [Agent and CI mode](https://okibi.ai/docs/cli/agent-mode.md#retry-safely).
- For a build paused on its spec, use `okibi spec reject --feedback` instead.
- `okibi attach <run-id>` rejoins a live session in the [TUI](https://okibi.ai/docs/cli/tui.md) while the build is still going. `okibi runs transcript <run-id>` reads the saved chat once the sandbox is gone.

## Fix a finished build

Send `okibi message` to a build that succeeded and still has its conversation. The agent repairs that same build and version, at no extra generation charge. When `okibi status <run-id>` says the corrected artifact is available, run `okibi pull <run-id>` again. Release pins do not change. To build a new version instead, click **Regenerate** on the CLI page, or run `okibi generate` again with the same `--name`.

## When a build fails

- The CLI keeps its last good version. Its official release and install command do not change. If a repair fails, the earlier artifact stays too.
- Failed and cancelled builds do not count toward your generation usage.
- Find the cause: the build card names the stage that stopped, and **View logs** shows the output. `okibi generate` prints the last lines of output when it sees a failure.

## Publish edits to the generated repository

The generated CLI's source lives in its own repository. If you commit changes there, publish them as the next version. This does not change the official or testing release; choose those separately in [Releases and install](https://okibi.ai/docs/guides/releases.md).

**In the app**

Open the project's **Settings**. In **Updates**, click **Check for changes** next to **Repository**. If there are unpublished commits, click **Publish commits**.

**In the CLI**

```sh
okibi clis changes my-cli
okibi clis publish my-cli --commit <commit-sha>
```
`clis changes` counts new commits on the default branch and prints the exact publish command. `--commit` makes the publish stop if new commits landed after you checked.

## Next steps

- [Review and iterate](https://okibi.ai/docs/guides/review-and-iterate.md): Check the CLI, then make the smallest change that fixes it.
- [Releases and install](https://okibi.ai/docs/guides/releases.md): Choose which version your users install.
- [Command reference](https://okibi.ai/docs/cli/reference/runs.md): Every okibi runs flag.
