# agent-change

> A billing tool in a git repository and a change a coding agent made to it, recorded before and after.

A small billing tool. Every day it reads the orders (`orders.json`) and the returned goods (`returns.json`) and writes `invoices.csv` (one row per order, with its total) and `refunds.csv` (one row per return, with the amount to give back). `tiers.json` has the loyalty tier of each customer. All amounts are in cents. `billing.py` has the prices; `run.py` reads and writes the files. `change.patch` is a change a coding agent made to it.

- Source: [`ormaos-examples/use-cases/agent-change`](https://github.com/ormaos/ormaos-examples/tree/6e27be59220856263a6a5905400d8630dafe73dd/use-cases/agent-change)
- Guide: [Agent checking a change](/python/guides/agent-change.md)

## Run it

```bash
python run.py
```

```console
$ python run.py
12 invoices, 3 refunds written
```

## Recorded

```bash
ormaos run -- python run.py
```

```console
$ ormaos run -- python run.py
12 invoices, 3 refunds written
ormaos: r1 exit 0 in …: 1 Python process, 75 calls, 0 exceptions, 6 io
ormaos: not collected: io: writes to the 2 files opened at run.py:18: opened for writing, and no `write` call by Python code was seen on a file of that name: if it was written, that was inside C code (`print(..., file=f)`, `csv.writer`)
ormaos: saved in .ormaos/r1, next: ormaos tree r1:c1
```

```console
$ ormaos show
r1 exit 0 in …: 1 Python process, 75 calls, 0 exceptions (0 swallowed, 0 uncaught)
command: python run.py
code: git commit 5b23406de1, no uncommitted changes
io: 6 events (file 6)
not collected: io: writes to the 2 files opened at run.py:18: opened for writing, and no `write` call by Python code was seen on a file of that name: if it was written, that was inside C code (`print(..., file=f)`, `csv.writer`)
never recorded: values, and 20 more kinds of things (`ormaos show --full` lists them with the reason)
next: ormaos tree r1:c1 | ormaos io r1
```

## After the change

```bash
git apply change.patch
ormaos run -- python run.py
ormaos diff r1 r2
```

```console
$ ormaos diff r1 r2
r1 -> r2, matched by place in the code and order, not by address
  r1: exit 0, 75 calls, 0 exceptions, 6 io events
  r2: exit 0, 113 calls, 0 exceptions, 82 io events
code: the two code versions differ: the same git commit 5b23406de1, and the uncommitted changes are not the same (none in r1, 1 file changed in r2)
calls: 1 of 11 places differ
  discount_percent at billing.py:10: none in r1, 38 in r2  [r2:c9]
exceptions: the same in both (0 groups)
io: 2 of 8 groups differ
  file open tiers.json (read)  at billing.py:11 in discount_percent: none in r1, 38 in r2  [r2:i5]
  file read tiers.json  at billing.py:12 in discount_percent: none in r1, 38 in r2  [r2:i6]
logs: the same in both (0 groups)
data: the same in both (0 places)
not compared: values, shapes of arguments and results, durations, cpu and memory, the lines of `path`, which process or thread an event was in
next: ormaos tree r2:c9 | ormaos io r2:i5 | ormaos io r2:i6 | ormaos show r1 | ormaos show r2
```

On this site the folder is made a git repository with one commit before the first recording, so that the recordings say which code ran.

---

Source: https://docs.ormaos.com/examples/agent-change/ · ormaos 0.0.1 · ormaos-python 968f69776c · ormaos-examples 6e27be5922
