Environments

Build a simulation environment from a local agent folder, answer the builder, save versions, and manage agent credentials and nudges

Build a simulation environment from your agent’s code, answer the builder’s questions, then review and save later changes. For the whole path from build to fix in a few commands, see the Simulate quickstart.

Prerequisites
  • Signed in to the CLI (see Sign in)
  • A workspace with environment versioning
  • Your agent’s code in a local folder
  • A CLI with fagi sim, which ships in a later CLI release

fagi sim works with the same environments as the Environments product, where Build an environment covers the build in the dashboard. Actors and evals are on Actors and evaluations, and scenarios on Scenarios, suites and personas.

Every command here takes the environment ID (ENV_ID), which is the environment_id field of the create output and the ID column of fagi sim env list. Confirmation, --wait-timeout and idempotency keys work as fagi sim flags describes.

Find an environment

fagi sim env list --workspace WORKSPACE_ID
fagi sim env show ENV_ID
fagi sim env rename ENV_ID --name checkout-agent
CommandWhat it does
fagi sim env listList environments in the workspace, newest first, with agent type, source kind, status, stage, scenario and run counts. --agent AGENT_ID keeps only the environments that run that agent; --page and --limit (1-100, default 10) page through
fagi sim env show ENV_IDShow the overview, contract, world, scenarios, evaluations and settings. --section tools prints only the contract’s tools and --section actors only the world’s personas, one per row
fagi sim env rename ENV_ID --name NAMERename the environment (1-255 characters). The name is the only editable field, and a rename makes no new version

A section the build has not produced yet prints building, or not built when the build failed or was canceled. With --section, the command exits 8 when that section is not built. The actors that scenarios bring in are a separate list, read with fagi sim env actors list.

Build an environment

fagi sim env create uploads a local folder and builds the environment in the cloud. The output gives the new ENV_ID.

fagi sim env create --repo ./my-agent --name support-bot --count 5 --dry-run --json
fagi sim env create --repo ./my-agent --name support-bot --yes --wait --wait-timeout 30m --json

The build is charged, so it asks for confirmation (--yes to skip). In the create’s JSON, read environment_id, state, and, with --wait, question when the builder needs an answer. The dry run never prompts and exits 0 even when the build can’t start yet; in its JSON, read ready_to_submit, the checks (including missing credentials), and source.files and source.skipped.

FlagWhat it does
--repo PATHThe agent’s local folder, such as . (required unless --source-id). See What the upload includes
--name NAMEEnvironment name, 1-255 characters (default: the folder name). Required with --source-id (exit 2): pass the name the first create used
--connectorHow the platform reaches the agent: auto (default, detected from the source), livekit, vapi, retell, retell_chat or phone
--artifactsEvidence runs keep: metadata-only, traces (default), traces-and-recordings or full
--count NScenarios to write, 1-1000 (default 10)
--config KEY=VALUEA non-secret agent setting, repeatable. true and false are sent as booleans
--secret NAME=KEYA credential already stored in the platform vault, sent as a reference: NAME is the variable your agent reads and KEY is the vault key. Repeatable. Credential values are never taken on the command line
--source-id IDReuse an earlier upload instead of --repo, to replay a create
--idempotency-key KEYKey for the create; see If create fails
--wait, --interval NWait for a question or the end of the build, polling every N seconds (default 2)
--dry-runUpload and check the build without creating an environment. It can’t be combined with --wait or --idempotency-key (exit 2)

What the upload includes

  • In a git checkout: the files git tracks plus untracked files that are not ignored
  • Otherwise: every file except .git, node_modules, .venv, venv and __pycache__. .gitignore is not applied, so check the file list with --dry-run
  • Never, in either case: symlinks, nested git checkouts and submodules
  • At most 999 files and 200 MiB. A folder that holds only an archive (.zip, .tar, .tar.gz, .tgz, .rar or .7z) exits 2: expand it and upload the folder

Files that usually hold secrets (.env files, cloud and SSH credential folders, private keys, .pem/.key files, credential JSON and similar) are never uploaded, even when git tracks them; --dry-run lists the ones it left out under source.skipped. Secrets under other file names are uploaded, so keep them out of the folder: pass them by reference with --secret, or store them with fagi sim env agent secrets set.

If create fails

If create exits 6, don’t rerun it with --repo: that uploads again and creates a second environment. Rerun with the values printed in the error, or check fagi sim env list first:

fagi sim env create --source-id SOURCE_ID --name support-bot --idempotency-key KEY --yes --wait

Follow the build and answer the builder

fagi sim env status ENV_ID --wait --messages
fagi sim env chat ENV_ID
fagi sim env approve ENV_ID
CommandWhat it does
fagi sim env status ENV_IDThe build’s state and stage, scenario counts, failure and the builder’s open question with its options. --messages adds the builder chat (the newest 200 messages); --after SEQ keeps only later ones
fagi sim env chat ENV_IDOn a terminal, an interactive chat: it shows the open question, reads your answer (a number picks an option) and prints the builder’s replies. At a design confirmation, y or approve approves it. An empty line or Ctrl-D ends the chat. -m TEXT sends one message and exits once it is accepted
fagi sim env approve ENV_IDApprove the design the builder proposed, so it goes on building. -m sets the text (default Approved.); --reply-to names another confirmation. Exits 2 when there is no open confirmation
fagi sim env edit ENV_ID --instruction TEXTSend a correction (1-2000 characters) while the builder is still authoring. --target-stage (understand, environment or scenarios) redoes from that stage; --scenario-delta N asks for N more scenarios
fagi sim env cancel ENV_IDStop the whole build. Saved versions are kept. Asks for confirmation (--yes to skip); --wait waits until it has stopped

With --wait, fagi sim env status and fagi sim env create exit 0 when the build completed, 6 when it failed for an infrastructure reason or --wait-timeout ended the wait, and 8 when the builder needs your answer, the build was canceled or it failed otherwise. On exit 8, check question in the --json output: when it holds a question, answer it with chat -m or approve and wait again; when it is null, the build ended without a result, so stop and read the error. A failed build keeps its draft, and the error prints the chat command that asks the builder to repair it.

When the build completes, start a run on one of its suite versions.

-m answers the open question, or sends a new message when there is none. It never approves; use fagi sim env approve. Without a terminal, always pass -m; plain chat exits 2 and prints the open question. --kind sets another message type, such as approval or interrupt, and --input-json attaches a structured answer to the -m text (see fagi sim env chat --help).

fagi sim env edit works only while the build is authoring. A build that has ended, or is past scenario authoring, is refused with exit 1 (adjustment_too_late); change a built environment through fagi sim env chat ENV_ID -m TEXT instead.

Review and save changes

A chat edit on a built environment writes a draft rather than changing the saved version. Review the draft, then save or discard it.

fagi sim env diff ENV_ID
fagi sim env save ENV_ID --piece environment --expected-draft DRAFT_ID:3
CommandWhat it does
fagi sim env diff ENV_IDThe unsaved environment draft and what it changed: draft ID, revision, parent, current default and each added, removed or changed item. --version VERSION_ID shows what a saved version changed instead; --against VERSION_ID compares with that version rather than the parent
fagi sim env save ENV_IDSave the environment draft, and the suite draft when there is one, together in one atomic save. The new versions become the defaults. Saving never starts a run
fagi sim env discard ENV_IDDiscard the environment draft. Saved versions, runs and the suite draft are untouched. Asks for confirmation (--yes to skip)

When a suite draft is open too, a warning names fagi sim suites diff.

Save flagWhat it does
--pieceThe drafts to save: environment, or environment and suite (default: every piece with a draft). A suite-only save is fagi sim suites save --env ENV_ID
--expected-revision NWith --piece environment, the draft revision you reviewed with diff (default: the latest read)
--expected-draft ID:REVISIONThe draft you reviewed, from the ID and revision in diff; repeat once for each --piece, which is then required. Any other draft or revision is refused (exit 1) and nothing is saved
--idempotency-key KEYKey for this save. After exit 6, rerun with the same --piece, --expected-draft and key to get the first save’s answer instead of saving twice

A save is refused (exit 1) if the draft changed after you reviewed it, or while a build, rebuild or builder reply is running; the error names the next step. Nothing to save exits 4.

Pick default versions

fagi sim env versions list ENV_ID
fagi sim env versions set-default ENV_ID --version VERSION_ID

fagi sim env versions list ENV_ID lists the versions of the agent, environment and suite. Use the ID column as VERSION_ID, PIECE to tell them apart, and PICKABLE to see which ones a run can use.

fagi sim env versions set-default makes a saved environment version the one fagi sim run uses when no version is named. A draft or discarded version is refused (exit 1), and an ID that isn’t one of this environment’s environment versions exits 4. --expected-default-id (the default you expect now, or none when there is none) refuses the move (exit 1, version_conflict) if the default changed meanwhile. Repeating a move that already succeeded is a no-op. The agent and suite defaults move with fagi sim env agent set-default and fagi sim suites set-default.

Manage the agent and its credentials

Each change to your agent’s code or credentials makes a new agent version. The platform checks it, and only a version that passes can be used by runs or made the default.

fagi sim env agent retry ENV_ID VERSION_ID --wait --json
fagi sim env agent diff ENV_ID VERSION_ID
fagi sim env agent set-default ENV_ID VERSION_ID
CommandWhat it does
fagi sim env agent set-default ENV_ID VERSION_IDMake an agent version the default that runs use. A version a run can’t use (its PICKABLE column in versions list is false), or an environment that is still building, is refused with exit 1, and an ID that isn’t one of this environment’s agent versions exits 4. --expected-default-id refuses the move (exit 1) if the default changed meanwhile. Repeating it is a no-op
fagi sim env agent retry ENV_ID VERSION_IDCheck again a version whose check failed or is stuck pending. A re-check that passes makes it the default. A version whose check passed or that was discarded is refused (exit 1)
fagi sim env agent discard ENV_ID VERSION_IDSet a version aside so it can no longer be picked or made the default. It can’t be undone from the CLI. The current default is refused (exit 1): make another version the default first. Asks for confirmation (--yes to skip)
fagi sim env agent diff ENV_ID VERSION_IDWhat a version changed against its parent, or --against VERSION_ID another agent version
fagi sim env agent secrets set ENV_ID NAMEStore one credential as a new agent version. See Set a credential

The CLI can’t upload changed agent code to an existing environment: fagi sim env agent only makes versions the default, checks them again, discards and compares them, and stores credentials. To change a built environment, message the builder with fagi sim env chat ENV_ID -m TEXT. To build from new code, create a new environment with fagi sim env create --repo.

With --wait, retry and secrets set poll every --interval seconds (default 2) until the check ends: 0 check passed, 5 check failed, 6 wait timed out or network/server error, 8 the version was discarded. After exit 6, check fagi sim env versions list ENV_ID before retrying.

Set a credential

The value is never taken from the command line and never printed. Pipe it in, or type it at the prompt on a terminal:

printf %s "$OPENAI_API_KEY" | fagi sim env agent secrets set ENV_ID OPENAI_API_KEY --from-stdin --wait
fagi sim env agent secrets set ENV_ID GOOGLE_APPLICATION_CREDENTIALS --from-file ./sa.json --wait

Pass exactly one of the two sources:

  • --from-stdin reads the value from stdin without its final newline. On a terminal the value is typed with echo off
  • --from-file PATH accepts only GOOGLE_APPLICATION_CREDENTIALS with a service-account JSON file of at most 5 MiB. stored_as in the output names the variable the credential was stored under. Pass any other file’s contents with --from-stdin < PATH

NAME is an environment variable name: letters, digits and _, not starting with a digit. The server keeps the value encrypted on a new agent version, the current one with NAME set, which is checked and becomes the default once its check passes. Setting a variable the agent doesn’t use yet, or a credential for an agent managed on the Agents page, may be refused with exit 1; the error gives the reason and no version is made.

Answer nudges

When something the environment was built on changes, such as a new agent version, changed credentials or a new environment version its suite should follow, the environment raises a nudge: an offer to rebuild the environment or suite with that change.

fagi sim env nudges list ENV_ID --state pending
fagi sim env nudges answer ENV_ID NUDGE_ID rebuild --yes --wait
CommandWhat it does
fagi sim env nudges list ENV_IDList the newest 100 nudges with their target, state and what changed (file paths and variable names, never values). The ID column is NUDGE_ID. Filter with --state pending (repeatable or comma-separated; see --help for all states)
fagi sim env nudges answer ENV_ID NUDGE_ID rebuildQueue a rebuild of the nudge’s target with the change, for a pending nudge or a failed one to try again. It starts builder work, so it asks for confirmation (--yes to skip)
fagi sim env nudges answer ENV_ID NUDGE_ID skipRecord that nothing should be rebuilt, for a pending nudge only. Never asks
fagi sim env nudges stop ENV_ID NUDGE_IDStop a queued or running rebuild. The nudge ends failed and can be answered rebuild again later. Asks for confirmation (--yes to skip); --wait waits until the stop is confirmed

With --wait, answer ENV_ID NUDGE_ID rebuild exits 0 on applied or no_change, 8 on failed (with its error code, message and problems), and 6 when --wait-timeout ends the wait. A closed or replaced nudge exits 1 and an unknown one exits 4. After exit 6, run fagi sim env nudges list ENV_ID to check the nudge’s state before answering again.

Dive deeper

Was this page helpful?

Questions & Discussion