Skip to main content
ancha run runs your agent against each scene in ancha.yaml, trials times, on a fresh world each time, evaluates every scene’s checks and exits with a code that says whether the agent passed.

Example

Output
The first line says where the worlds run. After ancha login it reads running locally (worlds in a server this command starts; logged in to https://app.ancha.io/t/<workspace>: --upload sends the results there): the login keeps the worlds on this computer and names the workspace that --upload sends results to. The last line names the next command. Pass scene files to run only those: ancha run scenes/support/scene.yaml. --agent "<command>" overrides agent.command for one run. Without ancha.yaml, run exits 2 and tells you to run ancha init.

How a run works

  1. ancha run chooses a server for the worlds: the one --server-url, server.url or ANCHA_SERVER_URL names, else a private local server it starts for this run. A saved login does not move the worlds; it names the workspace for --upload. The first line names the server, for example running on hosted https://app.ancha.io/t/<workspace> (from ANCHA_SERVER_URL; --local to run here). --local keeps the worlds on this computer whatever is configured. See CLI overview.
  2. For each scene and trial, it creates a fresh world from the scene’s seed and starts your agent with the task and the tool variables. See Environment variables.
  3. When the agent exits or the scene’s timeout passes, it captures the final state and every API call, then evaluates the checks.
  4. A trial passes when all required checks pass. A scene passes when its pass rate reaches min_pass_rate. The run passes when every scene passes and nothing regressed.
Results go to .ancha/runs/<run-id>/, and .ancha/runs/latest points at the newest completed run. See Attempts and runs.

What the agent gets

The agent runs as a process on this computer, in the project directory. It is not sealed: it can reach this computer’s network. Its environment is limited to a base set from your shell (PATH, HOME, USER, LOGNAME, SHELL, LANG, LC_*, TERM, TMPDIR, TZ, NODE_EXTRA_CA_CERTS, SSL_CERT_FILE, VIRTUAL_ENV, CONDA_PREFIX and PYTHONPATH), plus Ancha’s variables and the tools’ variables. Real credentials in your shell, such as GITHUB_TOKEN or DD_API_KEY, never reach it unless you name them:
ancha.yaml
--pass-env NAME adds a name for one run and can be repeated. --inherit-env passes the whole shell environment, as 0.1.1 did, and prints a warning. The run summary says what the agent got, and ancha explain says how many variables were withheld. With agent.execution.mode: container, the agent gets only the names in agent.execution.env. See ancha.yaml.

Exit codes

When several apply, 3 wins over 4, and 4 wins over 1.

JSON output

ancha run --json prints NDJSON: run_started, then trial_started and trial_finished for each trial, then run_finished with the summary and the next commands. run_started and the summary carry workspace (the world server, or local:<project path>) and target (local for a process on this computer, docker for a container). See For coding agents for the fields, and ancha schema run_finished for the schema.

Compare with a baseline

Output
--compare takes a baseline name or a run ID. Every scene and every required check is compared. A scene whose pass rate drops fails the run with exit 1, even when the overall pass rate is fine. So does a check whose pass rate drops, even when the scene’s rate holds, for example when one check went from 3/3 to 0/3 while another went from 0/3 to 3/3. Dropped checks are listed first:
Output
Comparison needs the same scenes with the same content and checks; trial counts may differ. The summary’s comparison field holds baselineRunId, regressed, droppedChecks and a per-scene before, after and delta.

Coverage gaps and --strict

When the agent calls an endpoint a replica does not implement, the output lists it:
Output
The call gets an error in the tool’s own shape, unknown_method for Slack, so the agent sees a failure. Without --strict, a gap does not change the exit code. With --strict, any gap exits 4 and the output adds --strict: the agent hit an endpoint Ancha does not implement (see coverage gaps). ancha explain lists the gaps either way. Check ancha twins coverage <tool> for what each tool implements.

Where the agent runs

--on picks where the agent itself runs; the default is what ancha.yaml says. --on cloud and --upload do not combine: a run in the workspace already lives there.

Results in your workspace

--upload, or ANCHA_UPLOAD=1 in the environment, sends the finished run to your workspace, where the console shows it at https://app.ancha.io/runs/<run id>. It needs a workspace: ancha login, or ANCHA_SERVER_URL and ANCHA_API_KEY. The run’s own files stay in .ancha/runs/.
Output
A failed upload is a warning: the run keeps its own exit code, and ancha runs upload <run id> tries again. --upload-required makes a failed upload fail the command instead. A run started with --detach uploads when it finishes, and ancha wait and ancha status say where the results went. With --json, run_finished carries upload: url, bytes and files, replaced: true when the run was uploaded before, or error. See Results in your workspace for what the upload holds and what is redacted.

Retrying safely

A caller whose command can time out, such as a coding agent or a CI step, passes --idempotency-key <key> (1 to 200 visible ASCII characters). Running the same command again with the same key returns the original run instead of starting another: its summary and exit code, with replayed: true in the JSON. While the original is still running, the retry fails with SESSION_CONFLICT and a hint to ancha wait <id>. The same key with a different scene set, agent or options is a usage error:
Output

Detached runs

--detach hands the run to a background worker and returns at once:
Output
Follow it with ancha logs <id> --follow, ancha wait or ancha status. logs --follow and wait exit with the run’s own exit code. Pass the same --out to all of them if you changed it. A detached run survives the launching shell, but not a reboot or a killed worker.

Timeouts and failures

An agent that runs past the scene’s timeout is stopped and the trial records exit=timeout. An agent that exits non-zero records its exit code. In both cases the checks still run against what the agent did, and ancha explain shows the end of its log. Ctrl-C stops the run the same way and keeps the evidence collected so far.

Model-graded checks

Judge checks need OPENROUTER_API_KEY in the environment of ancha run. Without it they are skipped, and a skipped required check fails its trial. The key is read by ancha run itself; the agent does not get it unless you list it in agent.pass_env. See Checks.

Your own harness

To start the agent yourself and still grade it with the scene’s checks, start a world with ancha world up, run the agent against it, and grade it with ancha check. See World lifecycle.