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

# Data agent

> The data example end to end, with read-only tools, a figure check, and a twin decision.

The example agent answers questions about one account's sales in one month: gross sales (every order), net sales (cancelled orders left out), or the number of completed orders. It reads a warehouse of synthetic orders and a CRM. It calls no model and changes nothing.

## Run it

```sh theme={null}
mkdir data-guide && cd data-guide
proving init --example data
proving connect
proving record --inputs tasks.jsonl --yes
proving redact
proving twin build
proving run --seed 1
proving results
```

```text Output theme={null}
Pass rate: 87.5% [70.62%, 95.33%] at 95%, n = 25, cases = 5, effective n = 28
  pass^1: 87.5%, too few cases for an interval, cases = 5
  pass^2: 87.5%, too few cases for an interval, cases = 5
  pass^4: 100%, too few cases for an interval, cases = 1
  pass^8: 100%, too few cases for an interval, cases = 1
  Stratum has_cancelled (weight 0.25): 50% [15%, 85%] at 95%, n = 12, cases = 4, effective n = 4
  Stratum typical (weight 0.75): 100% [77.19%, 100%] at 95%, n = 13, cases = 1, effective n = 13
  Stratum other (weight 0): no laps, not covered by this run
  Cluster wrong_figure / write / figure_matches_warehouse / warehouse.list_orders: 6 failures, attribution instruction (clu_<id>)
```

## A twin decision

The twin classes each tool from its name and description. It reads the word "order" in `list_orders` as an act (placing an order) and would treat the tool as an effect. The example ships its decision in `proving/twin.yaml`:

```yaml theme={null}
version: 1
servers:
  warehouse:
    tools:
      list_orders:
        class: read
```

`proving twin build` lists what it could not decide; `proving twin review` walks you through it.

## A figure check

Each case names the figure the answer must state, in `expected.answer.must_mention`. The check `figure_matches_warehouse` asserts the answer contains it:

```yaml theme={null}
- key: figure_matches_warehouse
  type: deterministic
  category: outcome
  station: write
  detects: wrong_figure
  required: true
  description: The answer states the figure the warehouse gives for the question (the case's first must_mention item).
  assert:
    - select: output
      op: contains
      value_from: "expected.answer.must_mention[0]"
```

## What the checks found

For "net" sales the agent sums every order, cancelled ones included, so months with a cancelled order get a net figure that is too high. Gross sales and order counts are right.

## Fix it

Leave cancelled orders out of net sales:

```js theme={null}
const counted = kind === "net" ? orders.filter((o) => o.status !== "cancelled") : orders;
const total = counted.reduce((sum, o) => sum + Math.round(o.amount * 100), 0) / 100;
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.