Configuration and output

Reference for fagi global flags, environment variables, settings precedence, output formats, JSON errors, exit codes and offline command discovery

Every fagi command shares the same global flags, settings, output formats, errors and exit codes. Use this page to script fagi or drive it from a coding agent.

Global flags

Every command takes these flags.

FlagWhat it does
--profile NAMEProfile to use (or FI_PROFILE); default default
--base-url URLPlatform API URL for a self-hosted install (or FI_BASE_URL)
--workspace IDWorkspace UUID to act in (or FI_WORKSPACE_ID), sent as the X-Workspace-Id header
-o, --output FORMATtable (default), json or jsonl (or FI_OUTPUT)
--jsonShort for --output json
--no-inputNever prompt; fail instead (or FI_NO_INPUT). For CI and coding agents
--timeout DURATIONDeadline for each API request, default 30s. Server work keeps running after it
--insecure-file-storeAllow plaintext credential storage instead of the OS keychain

fagi --version or fagi version prints the installed version.

--timeout limits how long fagi waits for each API request. The server keeps working after the deadline, so check the result before you repeat a write. Long-running commands such as fagi datasets push and fagi trace watch have their own --timeout; see their --help.

--yes is not global. Commands that can ask for confirmation take their own --yes: fagi datasets pull, fagi init, fagi update, fagi skills sync and fagi skills update (CLI 0.3.0 or later), every destructive fagi api command and every fagi sim command (-y; fagi sim ships in a later CLI release). With --no-input or no terminal and no --yes, a command that needs confirmation exits 2. Destructive fagi api commands, fagi init and fagi skills sync and update also set details.code confirmation_required. fagi datasets push has a --yes flag that is reserved: it never bypasses validation or enables replace.

fagi epoch run (CLI 0.3.0 or later) takes no --yes and never asks; see Start an Epoch.

fagi sim flags

fagi sim ships in a later CLI release. Every fagi sim command takes these two flags:

FlagWhat it does
-y, --yesConfirm without a prompt. Commands that remove data or spend credits ask on a terminal; with --no-input or no terminal and no --yes, they exit 2 and change nothing. Declining the prompt exits 1 and sends nothing
--wait-timeout DURATIONThe longest --wait or --follow waits (default 60m, 0 for no limit). When it runs out, the command exits 6 and the work keeps running

Ctrl-C during --wait or --follow stops only the waiting, never the work in the cloud. When --wait-timeout ends a wait, the error prints the command that reconnects to it.

Commands that start or save work, such as fagi sim run, fagi sim env create, fagi sim env save, fagi sim suites save and fagi sim scenarios generate, take --idempotency-key KEY. Without it they make a new key and print it to stderr. After a timeout or exit 6, rerun with the same key to get the first request’s answer instead of doing the work twice. Commands without a key, such as fagi sim runs retry or actor writes, are not safe to repeat blindly: read the current state before you run them again.

Environment variables

VariableWhat it sets
FI_API_KEY, FI_SECRET_KEYYour API key and secret key (key pair), used directly, with nothing stored. Set both or neither; a partial pair is refused
FI_BASE_URLPlatform API URL
FI_PROFILEProfile to use
FI_WORKSPACE_IDWorkspace to act in
FI_OUTPUTtable, json or jsonl
FI_NO_INPUT1, true, 0 or false, like --no-input
FI_PROJECTTracing project name that fagi run and fagi doctor fall back to when nothing else names one
FI_CONFIG_FILEPath of the tracing file that fagi init writes and fagi run reads, instead of ./futureagi.toml
XDG_CONFIG_HOMEMoves the user config directory to $XDG_CONFIG_HOME/fi

A flag on the command line overrides these variables. An invalid value exits 2 and names the variable. FI_OUTPUT and FI_NO_INPUT are read only from the environment, never from a config file. Tracing agents read further variables of their own, covered on Tracing.

Where settings come from

Each setting is taken from the first place that has it:

  1. Command-line flags
  2. Environment variables
  3. The project file .fi/config.toml, found by searching up from the current directory
  4. The user file ~/.config/fi/config.toml, or $XDG_CONFIG_HOME/fi/config.toml
  5. The endpoint saved with the profile by fagi auth login, then Future AGI Cloud

The active profile is --profile, then FI_PROFILE, then the one fagi profiles use set, then default. When no profile is active, the profile you log in to becomes the active one. The API key and secret key always come together from one source: environment variables, then a config file, then the profile saved by fagi auth login. Config file gives the file format.

Config file

Both config files use the same TOML format: one [profiles.NAME] table per profile.

[profiles.default]
workspace_id = "11111111-1111-4111-8111-111111111111"
project = "my-app"

[profiles.staging]
base_url = "https://staging.futureagi.example.com"
workspace_id = "22222222-2222-4222-8222-222222222222"
KeyWhat it sets
base_urlPlatform API URL, like --base-url
workspace_idWorkspace UUID to act in, like --workspace
projectTracing project name, like FI_PROJECT
api_key, secret_keyA key pair. Prefer fagi auth login, which keeps the pair in your OS keychain; never commit a file that holds keys
FileWhere it lives
User file~/.config/fi/config.toml, or $XDG_CONFIG_HOME/fi/config.toml
Project file.fi/config.toml, found by searching up from the current directory. Its values win over the user file’s

FI_OUTPUT and FI_NO_INPUT are never read from a file. A base_url in the project file that differs from the URL your key pair was configured for exits 3, until you confirm it with --base-url or FI_BASE_URL, so a repository can’t send your keys elsewhere.

Output formats

FormatStdout
tableColumns sized for an 80-column terminal. Long values end in ..., with a note on stderr pointing to JSON
jsonThe full response object, including pagination fields and fields the table leaves out
jsonlOne selected row per line, without the surrounding response

fagi schema always prints JSON, whatever -o says. A successful response with no body prints OK in a table. An empty list prints a No ... found. line and a suggested next step. To keep only some row keys of a fagi api read, use --fields; see Shape the output.

What goes to stderr

Stdout carries only the result, so you can pipe it. Errors, warnings and the records below go to stderr; with --json or -o jsonl each is one JSON value, so read stderr as a stream of JSON values.

RecordWhen
{"target":...}Before a fagi api command that changes or deletes data sends its first request, and before fagi datasets push. Fields: profile, base_url, workspace_id, workspace_source. A table prints a Target: line instead
{"pagination":...}After a list that has more pages. Fields include has_more, shown, total, total_is_lower_bound (true when total is only a minimum), next_flags, cursor_flag and cursor_field. A table prints a Warning: line such as Showing 2 of 7. Next page: --page 2
{"warning":...}A warning, which can come before an error record

next_flags is the flag and value for the next request, such as ["--page","2"]. cursor_flag names the cursor flag when the list pages by cursor, and cursor_field names the path in the --json output that holds the cursor value, such as result.metadata.next_cursor. Read the value from there, since the CLI never prints it or follows pages for you. Reads print no target record. Judge success by the exit code, not by an empty stderr.

JSON errors

With --json or -o jsonl, an error is one JSON object on stderr. A mistyped flag, fagi datasets list --pagesize 50 --json, gives:

{
  "details": {
    "code": "unknown_flag",
    "flag": "--pagesize",
    "hint": "see fagi datasets list --help; did you mean --page-size?",
    "suggestions": ["--page-size"]
  },
  "error": "unknown flag: --pagesize; see fagi datasets list --help; did you mean --page-size?",
  "exit_code": 2
}

error and exit_code are always present. Usage errors, missing credentials and some refused confirmations set details.code:

details.codeMeaning
unknown_commandNo such command
unknown_flagNo such flag on this command
invalid_flag_valueThe flag’s value doesn’t parse
missing_flag_valueThe flag needs a value
invalid_enumThe value isn’t one of the allowed values
unexpected_argumentsThe command takes fewer arguments
invalid_argumentsThe arguments don’t fit the command
confirmation_requiredThe command needs --yes without a terminal or with --no-input (destructive fagi api commands, fagi init, fagi skills sync and update)
credentials_missingNo key pair was found

When known, details also carries hint, flag (the flag’s name, usually spelled --name), suggestions, allowed and usage. Commands add their own details.code values; fagi schema --command lists them for each dedicated command.

Failures from the server or the network add more fields to details:

FailureFields
HTTP errorkind: "http", http_status, request_id, server_code, and when sent, retry_after_seconds or redirect_origin
Connection errorkind: "network", a masked host and a reason such as refused, dns, timeout or tls_handshake. A response cut off mid-read is also network, with an http_status
Either, from a fagi api commandoperation and retryable
A write that may have reached the serverwrite_state: "unknown"

In a table, the error ends with a Request ID: line when the server sent one.

A failing gate is not an error record: the command writes its report to stdout and exits 5.

Exit codes

CodeMeaning
0Success
1Unexpected error, HTTP 409, or another non-2xx response not listed here
2Usage error, refused confirmation, or input the server rejected (HTTP 400 or 422)
3Not signed in, not allowed, or not on this plan or deployment (HTTP 401, 402 or 403)
4Not found (HTTP 404)
5A gate failed. The report or diff is the output
6Network or server error (HTTP 408, 425, 429 or 5xx), or a fagi sim or fagi epoch verdict wait ran out
8fagi sim only: the awaited work ended without a usable result, because it failed, was canceled, needs input or measured nothing. Read it before you rerun anything

These commands can exit 5:

  • fagi trace check
  • fagi eval suite, and fagi eval run once it is available (see Python eval files)
  • fagi gateway try with --expect
  • fagi prompts diff with --exit-code
  • fagi skills update, fagi skills verify
  • fagi sim run, fagi sim verify
  • fagi sim runs status, fagi sim runs results, fagi sim runs compare
  • fagi sim env agent retry, fagi sim env agent secrets set

fagi epoch and fagi skills need CLI 0.3.0 or later, and fagi sim ships in a later CLI release.

fagi run otherwise exits with the status of the program it started, and uses 126 when that program is not executable and 127 when it is not found.

Retry only when the JSON error has details.retryable: true. fagi sim retries a read (never a write) up to twice after a network error or HTTP 429, 502, 503 or 504, waiting 0.25 s, then 1 s, or the server’s Retry-After when that is longer; a Retry-After over 30 s ends the read without a retry, and an error after retries says how many times the request was sent. Otherwise the CLI never retries for you. If a write fails without it, check whether the change landed before you repeat it.

Find commands

fagi schema describes every command as JSON, offline, with no credentials or config files read. With no flags it prints the whole schema: schema_version, exit_codes, global_flags and commands.

fagi schema --search 'trace error' --limit 5
fagi schema --command 'api observability traces error-analysis'
fagi schema --command 'eval test'
FlagWhat it does
--search QUERYFind commands by words in their path, tool name, description, group or notes. Every word must match. Returns matches (each with path, description, required_flags and, where known, access) and total_matches
--limit NMatches to return, 1 to 50 (default 5). Only with --search
--command WORDSFull entries for every command whose path ends in these words, so datasets list matches both fagi api datasets list and fagi datasets list

--search and --command can’t be combined. A search with no matches still exits 0.

A --command entry for a dedicated command gives its flags with their types, required flags and allowed values, plus access (local, read or write), open_world (true when it may incur model charges), side_effects, exit_codes, details_codes and examples. A fagi api entry has a different shape: tool, group, method, http_path, access, idempotent, description, control_flags, data_only_body_fields, rows, columns and notes, with open_world only on charged commands. Use these to avoid charged or file-writing commands while exploring.

An entry lists only the command’s own flags. The global flags, the fagi sim flags -y/--yes and --wait-timeout, and --fields on fagi api reads don’t appear in it, so check --help for those.

fagi help COMMAND prints the same help as fagi COMMAND --help: usage, flags and examples. Walk down a command group a level at a time:

fagi help
fagi help trace
fagi trace check --help

Dive deeper

Was this page helpful?

Questions & Discussion