Epoch

Start an Epoch on a finished simulation run to find a safe fix for its failing scenarios, preview it first, and follow its progress from the terminal

fagi epoch run TEST_EXECUTION_ID starts an Epoch on a finished run: it reproduces the run’s failing scenarios, tries changes to the agent, and keeps one only if it passes every check within its limits. fagi epoch status EPOCH_ID shows its state, its result and its limits. fagi epoch stop and fagi epoch retry stop a running Epoch or start a failed one again, and fagi epoch brief, submit and verdict fix a failed run with your own coding agent; see fagi epoch --help.

Prerequisites
  • CLI 0.3.0 or later
  • Signed in to the CLI (see Sign in)
  • A finished simulation run with failing scenarios (see Runs)
  • Credits for the Epoch’s budget
  • On a self-hosted install, a platform with Epoch support (see Self-hosted)

Find the run

fagi epoch run takes the run’s test execution ID, not the Run ID (job_id) that fagi sim run prints and the other fagi sim runs commands take (fagi sim ships in a later CLI release). These pages call it TEST_EXECUTION_ID; fagi epoch run --help and its error messages call the same argument RUN_ID. Find it in any of these places:

  • The test_execution_id field of fagi sim runs status, run on the Run ID
  • The ID column of fagi sim runs list --env ENV_ID
  • The last part of the run’s page address (.../runs/<test>/<TEST_EXECUTION_ID>)

From a saved Run ID:

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

A test execution ID can’t be turned back into a Run ID; see Find and follow runs.

Preview the Epoch

fagi epoch run 8d6f3a52-1c4e-4b7a-9f20-6a1d2e3b4c5d --dry-run
Dry run          no Epoch started and no credits spent
Allowed changes  Instructions, Tools
Time cap         1 h 30 min
Budget           2,500 credits
...
Next: run the same command without --dry-run to start this Epoch; it spends credits up to its budget

--dry-run prints the Epoch it would start (allowed changes, time cap, budget, protected cases, models and margins) and starts nothing. With --json, it prints the request instead, with the keys dry_run (true), method, path and request.

Start an Epoch

Warning

fagi epoch run has no --yes and never asks for confirmation, even with --no-input: it starts the Epoch, and spends credits up to its budget, as soon as you run it. Passing --yes exits 2 with unknown_flag. Always run it with --dry-run first. The CLI never retries the launch, so check the run’s page before you run the command again after an error.

fagi epoch run 8d6f3a52-1c4e-4b7a-9f20-6a1d2e3b4c5d --cost-limit 0.5
Started          Epoch 7
State            Queued
Allowed changes  Instructions, Tools
Time cap         1 h 30 min
Budget           2,500 credits
Spent            0 of 2,500 credits
Protected cases  1 protected
Must-pass        A case that passed every time before must not drop beyond
                 normal noise. A case that fails every run is run again to
                 confirm before it counts.
Models           openai/gpt-4o-mini
Reply time       +25%
Agent's cost     +25% · at most $0.5 a conversation
Next: check its progress with fagi epoch status
      9a8b7c6d-5e4f-4a3b-9c2d-1e0f9a8b7c6d

The Epoch uses the same defaults as the Start Epoch form on the run’s page: its suggested failing and protected scenarios, allowed changes, budget and time cap. From this command you can set only the models the agent may call and the reply-time and cost limits below. Any you leave out keep the form’s default. To choose the scenarios, budget or time cap, use the form or fagi api epoch launch.

FlagWhat it does
--model NAMEModels the agent may call; repeat or comma-separate. Default: every model the run called. The list must include all of them (compared without provider and ignoring case, so gpt-4o-mini matches openai/gpt-4o-mini)
--reply-time-margin PCTHow much slower a reply may get, as a whole percentage from 0 to 1000. Default: the form’s
--cost-margin PCTHow much more a conversation may cost, as a whole percentage from 0 to 1000. Default: the form’s
--cost-limit USDThe most one conversation may cost, in US dollars above 0. Default: no limit
--dry-runPrint the Epoch it would start, without starting it

If the run’s traces don’t record the agent’s model calls, or name no models, the Models line reads unknown: this agent's model calls weren't measured.... When cost isn’t measured, the Agent's cost line adds the same text after the margin, such as +25% · unknown: .... Add traceAI tracing to the agent to measure them.

With --json, fagi epoch run prints the full Epoch: its id is the EPOCH_ID, and state and step hold the raw values in the table below.

Follow an Epoch

fagi epoch status 9a8b7c6d-5e4f-4a3b-9c2d-1e0f9a8b7c6d
fagi epoch status 9a8b7c6d-5e4f-4a3b-9c2d-1e0f9a8b7c6d --json

EPOCH_ID is the ID that fagi epoch run prints on its Next: line, or the id field of its --json output. The command shows the Epoch’s state, its result once it has ended, and each limit it holds to. --json prints the complete Epoch.

fagi epoch status exits 0 for every state, so judge the result by state, not the exit code. To wait for the end, poll while state is queued, running or stopping:

while :; do
  STATE=$(fagi epoch status "$EPOCH_ID" --json | jq -r .state)
  case "$STATE" in
    queued|running|stopping) sleep 60 ;;
    *) break ;;
  esac
done
echo "$STATE"   # ready: a change was found
State--json stateWhat it means
QueuedqueuedWaiting to start
RunningrunningWorking. The State line shows the step, e.g. Running · Searching (Writing variations, Reproducing, Searching, Verifying; step is variations, reproduce, search or verify)
StoppingstoppingOn its way to a stop
Ready for reviewreadyFound a change. Winner names the candidate. Strength, when present, is Limited validation or Proven on the targets only (it passed the failing scenarios but has no held-back result)
No safe improvement, Could not reproduce, Stopped at budget, Stopped, Too few failing scenarios, Failedno_improvement, not_reproduced, out_of_budget, stopped, too_few_cases, failedEnded without a change. The Result line says why and, where there is one, what to do next

Review the result

fagi epoch doesn’t apply a winning candidate. Review it on the Epoch’s page in the platform and ship it from there, or use fagi api epoch candidates make-default or fagi api epoch candidates pull-request open.

Errors and exit codes

fagi epoch run refuses, and starts nothing, in these cases.

CaseExitdetails.code
TEST_EXECUTION_ID is not a UUID2invalid_run
The platform blocks the launch, for example too few failing scenarios; the message gives the reason1epoch_blocked
The run has no failing scenarios to fix1epoch_no_targets
The platform doesn’t support Epoch limits yet (self-hosted platform needs upgrading)1platform_too_old
The platform’s launch options aren’t an Epoch launch form; check --base-url1invalid_launch_options
The Epoch started but its output couldn’t be written; check it with fagi epoch status before you run the command again1output_failed
--model leaves out a model the run called, or is empty2invalid_model
--model on a run whose traces name no model2model_lock_unavailable
A margin outside 0 to 10002invalid_margin
A cost limit that is not above 02invalid_cost_limit

When the platform refuses for another reason, the CLI prints its message and exits 2 when the launch was rejected, 1 when another Epoch is already running in this environment, and 4 for an unknown run or a self-hosted platform without Epoch support; other refusals, such as a rejected key or a plan limit, follow the shared exit codes. After exit 6, or exit 1 with invalid_epoch_response or output_failed, the Epoch may have started: check the run’s page before retrying.

fagi epoch status fails with exit 2 (invalid_epoch) when EPOCH_ID is not a UUID and 1 (invalid_epoch_response) when the response can’t be read. The other codes follow the shared exit codes.

Set every launch field yourself

Use fagi api epoch launch when you need settings fagi epoch run doesn’t expose, such as specific failing or protected scenarios, budget or time cap. Read the defaults first, then pass the fields yourself; it fills nothing in. --source-run-id, --target-scenario-keys, --surfaces and --budget-credits are required. --protected-scenario-keys, --max-minutes, --allowed-models, --locked-paths, --reply-latency-margin-pct, --cost-margin-pct and --cost-limit-usd are optional; note that these names differ from the fagi epoch run flags.

fagi api epoch launch-options get --source-run-id TEST_EXECUTION_ID
fagi api epoch launch --source-run-id TEST_EXECUTION_ID --target-scenario-keys KEY1,KEY2 \
  --surfaces SURFACE --budget-credits 2500 --dry-run
fagi api epoch get --id EPOCH_ID

Like fagi epoch run, fagi api epoch launch starts the Epoch and spends credits as soon as it runs, never asks for confirmation and is never retried. Its --dry-run only checks your flags offline and prints the request; it doesn’t read the defaults (see Call any endpoint). fagi api epoch get returns the raw Epoch.

Dive deeper

Was this page helpful?

Questions & Discussion