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

> ## Agent Instructions
> The canonical docs host is https://momentic.ai/docs. Append .md to any page URL for clean Markdown. Fetch https://momentic.ai/docs/llms.txt for the page index and https://momentic.ai/docs/llms-full.txt for every page in one file.
> For an unattended setup, run `npx --yes @momentic/wizard@latest -y --platform web --editor-tools skills` (use `--platform ios` or `--platform android` for mobile). Never run an interactive command in a non-TTY shell.
> You cannot complete the browser sign-in yourself. Read the API key from the MOMENTIC_API_KEY environment variable, or ask the user to create one at https://app.momentic.ai/settings/api-keys and paste it back.
> Momentic's capability summary for agents is at https://momentic.ai/docs/skill.md. Install the skills with `npx skills@latest add momentic-ai/skills`.
> Tests are YAML files in the user's repository. Use only the step names listed at https://momentic.ai/docs/reference/commands.md and the file structure at https://momentic.ai/docs/core-concepts/file-format.md. Do not invent step names, config keys, or CLI flags.
> Web tests run on Chromium, iOS tests on simulators, and Android tests on emulators. Physical devices are not supported.

# mo read

> Read new output from a Mo session.

Read what Mo has said in a session. By default the command returns immediately
with the transcript so far; pass `--timeout` to block until Mo finishes its
current turn or asks a question, which is the usual way to follow a running
session from a script or coding agent.

```bash theme={null}
mo read <session-id> --timeout 290s
```

## Arguments

<ParamField path="<session-id>" type="string" required>
  The session to read, from the output of `mo start`.
</ParamField>

## Options

<ParamField path="--timeout <duration>" type="string" default="0">
  Maximum time to wait for new output. Accepts `0` (return immediately) or a
  value such as `30s`, `2m`, or `500ms`, up to `290s`. Loop the command to
  follow a long session.
</ParamField>

<ParamField path="--from <origin>" type="string" default="start">
  Where to read from. `start` returns the whole transcript plus anything Mo says
  while the command waits. `latest` skips the existing transcript and returns
  only output produced while the command waits, so a polling loop does not
  reprint earlier messages.
</ParamField>

<ParamField path="--json" type="boolean">
  Print the raw response as one JSON object instead of plain text.
</ParamField>

## Output

In plain-text mode, the command prints each message on stdout. Two status lines
can appear on stderr:

* `Mo is still working.` when the timeout ran out before Mo finished.
* `Mo was stopped.` when the session state is `stopped`, for example after
  `mo stop` or a stop from the dashboard.

With `--json`, the object has this shape:

```json theme={null}
{
  "sessionId": "<session-id>",
  "state": "waitingOnUser",
  "timedOut": false,
  "messages": [
    { "role": "assistant", "text": "Which environment should I test?" }
  ],
  "pendingInput": {
    "id": "<input-id>",
    "question": "Which environment should I test?",
    "options": ["staging", "production"]
  }
}
```

`state` is one of `starting`, `working`, `waitingOnUser`, `waitingOnAgents`,
`idle`, or `stopped`. `timedOut` is `true` when the command returned because the
timeout ran out while Mo was still working. `pendingInput` is present only when
Mo is waiting for an answer; reply with
[`mo send`](/docs/cli-reference/mo/commands/send).

## Examples

Follow a session until Mo stops working:

```bash theme={null}
while true; do
  output=$(mo read "$session_id" --from latest --timeout 290s --json)
  jq -r '.messages[].text' <<<"$output"
  [[ $(jq -r .timedOut <<<"$output") == true ]] || break
done
```
