Simulate quickstart

Build a simulation environment from your agent folder, run its suite, read the failing calls and start an Epoch to fix them, all from the terminal

Build an environment from your agent folder, run it, read the failures and start an Epoch to fix them.

Prerequisites
  • A CLI with fagi sim, which ships in a later CLI release (see the Overview)
  • Signed in to the CLI (see Sign in)
  • A workspace with environment versioning (without it, the fagi sim suites commands exit 4)
  • Your agent’s code in a local folder
  • jq, to read IDs from the JSON output

Steps

Build an environment

From your agent’s folder, upload it and build. The build is charged, so --yes confirms it:

fagi sim env create --repo . --yes --wait --json > build.json
ENV_ID=$(jq -r .environment_id build.json)

Preview the upload first with --dry-run; Build an environment lists what it includes.

Answer the builder

The build exits 8 when the builder asks a question. Answer it, or approve the design it proposes, then wait again; repeat until the wait exits 0:

jq -e '.question' build.json        # prints the question; prints null and exits 1 when there is none
fagi sim env chat "$ENV_ID" -m "ANSWER"
# or, when the question asks you to confirm a design
fagi sim env approve "$ENV_ID"
fagi sim env status "$ENV_ID" --wait --json > build.json

Exit 8 with no question means the build ended without a result, and exit 6 means an infrastructure failure or that the wait timed out while the build keeps running; see Follow the build and answer the builder.

Find the suite version

fagi sim suites list --env "$ENV_ID"
SUITE_VERSION_ID=$(fagi sim suites list --env "$ENV_ID" -o jsonl | jq -r 'select(.is_default) | .id')

The table marks the default version; its ID column is the suite version ID a run takes.

Run the suite

Start the run and save its Run ID, then wait for it and gate on a 90% pass rate:

RUN_ID=$(fagi sim run --env "$ENV_ID" --suite "$SUITE_VERSION_ID" --yes --no-input --json | jq -r .job_id)
fagi sim runs status "$RUN_ID" --wait --fail-under 0.9

Exit 5 means the pass rate is below 0.9; Wait and gate on the pass rate lists the other exits. Keep RUN_ID; you can’t get it back from fagi sim runs list (see Start a run).

Read the failures

fagi sim runs results "$RUN_ID" --status failed
fagi sim runs trial show "$RUN_ID" CALL_ID --include checks,transcript

CALL_ID is the ID column of results. The checks section gives each failed check with its reason.

Start an Epoch

An Epoch takes the run’s test execution ID. Preview it, then start it, and check on it:

TEST_EXECUTION_ID=$(fagi sim runs status "$RUN_ID" --json | jq -r .test_execution_id)
fagi epoch run "$TEST_EXECUTION_ID" --dry-run
fagi epoch run "$TEST_EXECUTION_ID"
fagi epoch status EPOCH_ID

fagi epoch run starts at once with no confirmation (see Start an Epoch). EPOCH_ID is on its Next: line; see Follow an Epoch.

Dive deeper

Was this page helpful?

Questions & Discussion