# Exit codes for agents

> What the exit code of ormaos run and of a reading verb tells an agent, and where the reason is.

## `ormaos run` returns the command's code

`ormaos run -- <command>` exits with the exit code of the command, whatever was or was not recorded. An agent can put `ormaos run --` in front of a command without changing how it checks the result.

```console
$ ormaos run -- python three.py
ormaos: r2 exit 3 in …: 1 Python process, 1 call, 1 exception (0 swallowed)
ormaos: saved in .ormaos/r2, next: ormaos tree r2:c1
# exit code 3
```

A command ended by a signal gives 128 plus the signal number, as a shell reports it:

```console
$ ormaos run -- python term.py
ormaos: r3 (incomplete) exit 143 (signal 15) in …: 1 Python process, 1 call, 0 exceptions
ormaos: not collected: the last events of process …: it was ended by the program (process 1) with signal 15 before it had written everything: what it wrote is here, the calls that had not returned are marked open, and up to 256 records or what happened in its last 0.2 seconds can be missing
ormaos: saved in .ormaos/r3, next: ormaos tree r3:c1
# exit code 143
```

The recording is then `(incomplete)`, and `not collected` says which process may miss its last events.

When the command cannot be started, `ormaos run` exits with `127` (not found) or `126` (not runnable), and nothing is recorded:

```console
$ ormaos run -- no-such-program
ormaos: cannot start 'no-such-program' (FileNotFoundError)
# exit code 127
```

## A reading verb: 0, 1 or 2

| Code | Meaning |
|---|---|
| `0` | it answered |
| `1` | the question has no answer: no such recording or address, nothing recorded there, a recording that cannot be read |
| `2` | the command line was not understood |

The reason is on stderr, or in the JSON document with `--json`.

```console
$ ormaos path r1
ormaos: no path in r1: lines are recorded only inside a scope given when recording
ormaos: next: ormaos run --path ok.py -- python ok.py
# exit code 1
```

An option is written in full: `--lim` is not `--limit`.

```console
$ ormaos tree --lim 5
usage: ormaos [-h] [--version] <verb> ...
ormaos: error: unrecognized arguments: --lim
# exit code 2
```

The full table, with every case, is in [Exit codes](/python/reference/exit-codes.md).

---

Source: https://docs.ormaos.com/python/agents/exit-codes/ · ormaos 0.0.1 · ormaos-python 968f69776c · ormaos-examples 6e27be5922
