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

> ## Agent Instructions
> These docs describe the Ancha CLI, npm package @ancha-labs/cli, and the hosted workspace at app.ancha.io. Coding agents should start at https://docs.ancha.io/coding-agents. Run the CLI as `ancha` after `npm install -g @ancha-labs/cli`, or as `npx -y @ancha-labs/cli` without installing. Pass --json for machine-readable output, or set ANCHA_JSON=1. Every command ends with a `next:` line naming the next command. Exit codes: 0 pass, 1 a check failed or a comparison regressed, 2 usage, config or authentication error, 3 infrastructure error, 4 unimplemented endpoint with --strict.

# Test a NetSuite agent

> Test a finance agent on NetSuite before it has production traces: ancha init writes the books of a private-equity portfolio company and 25 tests, questions and workflows that change the books, the agent runs them in the cloud, and the report shows each answer and record next to the expected one. Then add your own evals and your own books.

Your agent answers finance questions from NetSuite and does the work: what is past due, which bills wait for approval, which payment to apply. You can test it before it has production traces. For an agent that calls NetSuite directly, `ancha init` writes a NetSuite world, the books of a private-equity portfolio company, and 25 tests: 10 questions an operator asks and 15 workflows that change the books. A question checks the agent's answer, and that it changed no record. A workflow checks the records the agent leaves.

## Before you start

* Node.js 24 or later, and the CLI: `npm install -g @ancha-labs/cli`.
* A workspace at [app.ancha.io](https://app.ancha.io/login). Run `ancha login` once and approve this computer in the browser.
* An agent that reads NetSuite's URLs and credentials from its environment, such as `NETSUITE_SUITEQL_URL` and `NETSUITE_ACCESS_TOKEN`. See [NetSuite](https://docs.ancha.io/tools/netsuite.md#connect).

## Set up the project

Run init in the agent's project:

```bash theme={null}
ancha init
```

```text Output wrap theme={null}
Created 31 files; updated 0; preserved 0.
agent: npm start (from package.json)
tools: NetSuite (from NETSUITE_ACCESS_TOKEN in agent.mjs)
task: your agent reads ANCHA_TASK, which holds each test's task
answer: what your agent prints on stdout is its answer, and its logs go to stderr; to give it exactly, POST {"output": ...} to ANCHA_DONE_URL with Authorization: Bearer $ANCHA_TRIAL_TOKEN
data: NetSuite world netsuite-pe-m (4 subsidiaries, 11,431 transactions) and 25 tests (10 read tasks, 15 write workflows)
next: ancha agent upload, then ancha run
```

* `tools` names the tools init found, and where. When it finds others or none, name them: `ancha init --tools netsuite`.
* An agent that reads NetSuite under its own names, such as `NS_ACCOUNT_ID`, gets them mapped in `ancha.yaml`, and a `netsuite:` line lists them.
* `answer` says where the tests read the agent's final answer.
* `data` names the world and the tests:

| File | Contents |
| - | - |
| `ancha/worlds/netsuite-pe-m.yaml` | Ostrander Industrial Holdings: four subsidiaries, US dollar and euro books, 400 customers, 180 vendors and 11,431 transactions over 18 months. |
| `ancha/evals/netsuite-pe-m.jsonl` | The 25 tasks, with answers and final records computed from the books. |
| `ancha/tests/pe-01-ar-over-60.yaml` to `ancha/tests/pe-19-three-way-billed-over-received.yaml` | One test per question. |
| `ancha/tests/pe-write-01-approve-bill.yaml` to `ancha/tests/pe-write-15-recover-payment.yaml` | One test per workflow. |

The books hold what an operator finds at close: overdue receivables, duplicate bills, unapplied payments and credits, three-way-match exceptions and journal entries waiting for approval. `--data netsuite-pe:s` writes a smaller company, with 1,522 transactions, and `--data netsuite-pe:l` a larger one, with 22,268. `--data none` leaves them out. An agent that reaches NetSuite through Composio gets the same books and the 10 read tasks, and runs them in the cloud; see [Detect Composio agents](https://docs.ancha.io/cli/init.md#detect-composio-agents).

Each test asks one question. `ancha/tests/pe-11-ap-over-60-days.yaml` asks this, and checks the answer:

```yaml ancha/tests/pe-11-ap-over-60-days.yaml theme={null}
start:
  task: As of November 2, 2026, how much do we still owe on approved vendor bills dated more than 60 days ago? Give the total unpaid and the number of bills.
checks:
  - id: answer
    answer: { numbers: [ { value: 207832.73, tolerance: 0.005 }, { value: 19 } ] }
```

The `answer` check passes when the agent's final answer states USD 207,832.73 to the cent and 19 bills. No model grades it. The second check, `read-only`, is `netsuite.unchanged` over every record type. The file's header keeps the expected answer and the SuiteQL query that computes it. See [Answer checks](https://docs.ancha.io/reference/checks.md#answer-checks).

Each workflow gives the agent a job and checks NetSuite afterwards. `ancha/tests/pe-write-01-approve-bill.yaml` asks for an approval within policy, with the list of every NetSuite record type shortened here:

```yaml ancha/tests/pe-write-01-approve-bill.yaml theme={null}
start:
  task: Approve pending vendor bill 2954 (internal ID 70691, Muskegon Industrial Properties LLC) if it is within our USD 11000.00 approval authority, the vendor is active and the bill has no duplicate (same vendor and amount within three days). Leave all other records as they are.
checks:
  - id: record-1
    state: { netsuite.record: { type: vendorBill, id: 70691, fields: { approvalStatus: { id: "2" } } } }
  - id: unrelated-records
    state: { netsuite.unchanged: { types: [ customer, vendor, contact, ... ], except: [ { type: vendorBill, id: 70691 } ] } }
  - id: count-1
    state: { netsuite.count: { type: vendorBill, count: 1800 } }
```

The bill must end up approved, no other record may change, and the books must still hold 1,800 vendor bills. The other workflows refuse a bill over the limit and a duplicate bill, apply a payment and a credit memo, create a vendor bill, a customer and an accrual that balances, update terms and a credit limit, pay an approved bill, refuse a bank-detail change requested by email, retry a bill a previous run already entered, and finish a payment left unapplied. Each expected record is computed from the books. See [NetSuite checks](https://docs.ancha.io/reference/checks.md#netsuite).

## Upload the agent

Store the agent's model key in your workspace, then upload the agent. A fresh machine in the cloud installs it and asks it to find one customer in NetSuite.

```bash theme={null}
ancha secrets set ANTHROPIC_API_KEY
ancha agent upload
```

```text Output wrap theme={null}
pass  workspace: running in the workspace https://app.ancha.io/t/<workspace>
pass  bundle: <files> files, <size> MiB; project <project hash>
pass  task: your agent reads ANCHA_TASK, which holds each test's task
pass  agent: installed in <time>; started with a task and exited with code 0 after <time>
  NetSuite: it called SuiteQL once and answered "Ridgeway Robotics".
pass  netsuite: 1 tool call
Agent uploaded: https://app.ancha.io/agents?connection=connect_cloud_<uuid>
next: ancha run
```

When the agent does something else, the `agent` line says what happened in one sentence, and `fix:` gives the change to make. See [`ancha agent upload`](https://docs.ancha.io/cli/agent#what-the-check-says).

## Run the tests in the cloud

```bash theme={null}
ancha run
```

Each attempt runs on a fresh machine of its own, with a fresh copy of the books. The run ends with the link to its result, `Result: https://app.ancha.io/runs/run_cloud_<uuid>`, and the command that explains it.

```bash theme={null}
ancha explain <run id>
```

```text Output wrap theme={null}
pe-11-ap-over-60-days  trial 1  ✗ answer
  expected: the final answer states 207832.73 (±0.005), 19 (±0.5)
  actual:   "We owe USD 374,389.56 on 31 bills dated before September 3, 2026."
  why:      It states no number within 0.005 of 207832.73, nor within 0.5 of 19: the numbers it states are USD 374,389.56, 31, 3, 2026.
```

This agent counted the bills that still wait for approval. While you fix it, run that test on this computer:

```bash theme={null}
ancha run --on local ancha/tests/pe-11-ap-over-60-days.yaml --attempts 1
```

## Read the report

```bash theme={null}
ancha report <run id> --html --open
```

The command reads the run from your workspace once, keeps it in `.ancha/runs/<run id>/`, and writes `report.html` there. It prints the page's path and opens it. The page is one file that works offline:

* The verdict, with four numbers: the attempt pass rate, the tests, the attempts per test and the total attempts.
* **Tests**: one row per test, one cell per attempt.
* **Machines**: each attempt's machine, on one clock.
* **Evidence**: for each attempt, the expected answer next to the agent's, each check, the NetSuite calls with their SuiteQL, the records the attempt changed, and the end of the agent's log.

## Add your own evals

Your team's questions with expected answers become tests on the same world. Keep the file under `ancha/evals/`: the agent gets its project's files in a cloud run, and `ancha/` stays with the grader.

```csv ancha/evals/month-end.csv theme={null}
ID,Controller question,Gold answer,Owner
largest-past-due,"Which invoice is the largest one past due as of November 2, 2026, and how much is still open on it?","“INV12645”, with USD 32,101.48 open",Rachel
furthest-over-limit,"Which customer is furthest over its credit limit? Give its balance and its limit.","“Prescott Plumbing Supply Corp.” owes USD 383,257.63 against a limit of USD 342,000.00",Rachel
open-eur,"How much is open on invoices in euros as of November 2, 2026, in EUR?","EUR 138,771.89 on 22 invoices",Greg
```

```bash theme={null}
ancha test import ancha/evals/month-end.csv --world netsuite-pe-m
```

```text Output wrap theme={null}
imported 3 tests from ancha/evals/month-end.csv into ancha/tests/ for world netsuite-pe-m (3 written)
format: CSV; questions from column "Controller question", expected answers from column "Gold answer"
checks: 3 answer, 3 netsuite.unchanged
next: ancha run
```

The numbers in an expected answer, its quoted text and its document numbers such as `INV-1043` become the answer check. `furthest-over-limit` gets this one:

```yaml ancha/tests/furthest-over-limit.yaml theme={null}
checks:
  - id: answer
    answer: { contains: [ Prescott Plumbing Supply Corp. ], numbers: [ { value: 383257.63, tolerance: 0.005 }, { value: 342000, tolerance: 0.005 } ] }
```

Other columns, such as `Owner`, stay in the test's header as comments. The import also reads JSON lines, JSON and YAML, and the files of eval tools such as promptfoo, LangSmith and Braintrust. Importing again keeps the tests you edited. See [`ancha test import`](https://docs.ancha.io/cli/test#ancha-test-import).

An eval can check a write too. `records` names the NetSuite record the agent must leave behind:

```json ancha/evals/approvals.jsonl theme={null}
{"id": "approve-sac-2384", "question": "Approve Scioto Actuator Co.'s bill SAC-2384.", "records": [{"type": "vendorBill", "id": 70668, "fields": {"approvalStatus": {"id": "2"}}}]}
```

It becomes a `netsuite.record` check:

```yaml ancha/tests/approve-sac-2384.yaml theme={null}
checks:
  - id: record-1
    state: { netsuite.record: { type: vendorBill, id: 70668, fields: { approvalStatus: { id: "2" } } } }
```

## Use your own books

Your own NetSuite data goes in a world file of its own, `ancha/worlds/<id>.yaml`. `ancha world import netsuite` writes it from your NetSuite exports as NetSuite writes them: REST record JSON, SuiteQL results and saved search CSV.

```bash theme={null}
ancha world import netsuite exports/ --id our-books
```

```text Output wrap theme={null}
wrote ancha/worlds/our-books.yaml from 10 files (REST record JSON 10)
modeled: customer 60, vendor 30, account 6, subsidiary 2, currency 1, term 1, invoice 110, customerPayment 55, vendorBill 40, serviceSaleItem 4, servicePurchaseItem 2
kept as given: none
fields kept as given:
  subsidiary: currency, parent
  currency: isBaseCurrency
  serviceSaleItem: itemType
  servicePurchaseItem: itemType
next: ancha world validate ancha/worlds/our-books.yaml
```

Customers, vendors, items, the chart of accounts and the main transactions become the books, each record in its own subsidiary and currency. Custom record types and every other record are kept as given, and so is each field beyond the modeled ones. The agent reads all of them through REST and SuiteQL.

The import checks that the books add up and names each record that does not, with its file:

```text Output wrap theme={null}
the books check refuses 2 records; fix them in the export, or keep their types as given, outside the books, with --plain customerPayment,invoice:
  invoices.39: INV8040 (id 8040, customer 1025 Juniper Logistics): invoice is over-applied: applications total USD 1,500.00 against a total of USD 1,200.00 (over by USD 300.00) (exports/invoices.json item 40)
  customerPayments.54.apply.0: PYMT9055 (id 9055, customer 1025 Juniper Logistics): application exceeds the open line amount: USD 1,500.00 applied against USD 1,200.00 open (exports/customerpayments.json item 55)
next: fix the 2 records above in the export, then: ancha world import netsuite exports/ --id our-books --force
```

It exits `1` until the export adds up. See [`ancha world import netsuite`](https://docs.ancha.io/cli/world#ancha-world-import-netsuite) for every format and option. To write the seed by hand instead, `ancha twins seed netsuite` lists its fields.

After you edit the file by hand, `ancha world validate` checks it again. It reads the file as a test loads it and runs the same books check:

```bash theme={null}
ancha world validate ancha/worlds/our-books.yaml
```

```text Output wrap theme={null}
ok  ancha/worlds/our-books.yaml (our-books)
    netsuite: 2 subsidiaries, 1 currency, 1 term, 6 accounts, 60 customers, 30 vendors, 6 items, 205 transactions
```

It exits `1` while a problem remains and `0` once the books add up. Then point tests at the world with `world: our-books`, or import your evals onto it: `ancha test import <evals file> --world our-books`.

## Next steps

> [card] [Answer checks](https://docs.ancha.io/reference/checks.md#answer-checks)
>
> Text and numbers the final answer must state.

> [card] [ancha test import](https://docs.ancha.io/cli/test.md#ancha-test-import)
>
> Every format and field it reads.

> [card] [NetSuite](https://docs.ancha.io/tools/netsuite.md)
>
> REST records, SuiteQL, MCP tools and the built-in dataset.

> [card] [The run report](https://docs.ancha.io/cli/report.md)
>
> One page per run, for runs in the cloud and on this computer.


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