CLI Reference¶
The fastaiagent CLI wraps the most common operational tasks: managing traces, running evals, serving agents, exposing them over MCP, and connecting to the Platform.
Installation¶
Installed automatically with the SDK:
Top-level commands¶
| Command | Purpose |
|---|---|
fastaiagent version |
Show SDK version and which optional extras are installed |
fastaiagent connect |
Save Platform credentials and verify the API key |
fastaiagent disconnect |
Remove saved Platform credentials |
fastaiagent auth |
Inspect saved credentials (status, env) |
fastaiagent traces |
List, export, prune, scrub and purge local traces |
fastaiagent replay |
Show, inspect, and fork traces for debugging |
fastaiagent eval |
Curate eval datasets from traces; run evaluations |
fastaiagent prompts |
Browse the prompt registry |
fastaiagent kb |
Manage local knowledge bases |
fastaiagent ui |
Start the Local UI — traces, prompts, evals, guardrails, approvals |
fastaiagent agent |
Run an Agent or Chain as an HTTP service |
fastaiagent mcp |
Expose an Agent or Chain as an MCP server |
fastaiagent skills |
Install Agent Skills that teach coding assistants this SDK (list, install, path) |
fastaiagent studio |
Build an agent through Agent Studio, headless: send a spec, try it, eval it, export it (context, new, spec, show, try, eval, export …) |
fastaiagent resume |
Resume a paused execution (durability) |
fastaiagent list-pending |
List pending interrupts awaiting human approval |
fastaiagent inspect |
Show checkpoint history for an execution |
fastaiagent setup-checkpointer |
Provision the durability backend (SQLite or Postgres) |
fastaiagent migrate |
Copy legacy traces.db / checkpoints.db / .prompts/ into local.db, once per source (--force re-imports); imported history is never pushed to a plane |
fastaiagent export-trace |
Export one trace as a self-contained JSON file (same payload as the Local UI's Export button) |
fastaiagent version¶
Brackets list the optional extras whose upstream package is importable. Useful when debugging "which extras did this env install?" in bug reports.
fastaiagent connect / disconnect / auth¶
Persist Platform credentials to ~/.fastaiagent/credentials.toml (mode 0600) so scripts and CI don't need to pass the API key each time.
connect exits 0 only when the plane verified the key. A target that cannot
be reached (or answers 5xx) saves the credentials, says they are not verified,
and exits 1; a target that answers anything else, such as a 404 from a server
that is not a plane, saves nothing and exits 1. Before 1.97.0 both printed
"✓ Connected" and exited 0.
--target is your program address, shown in the console when you create an API
key. It falls back to FASTAIAGENT_TARGET; with neither, connect saves nothing
and exits 1. Until 1.100.0 it defaulted to https://app.fastaiagent.net, a host
that no longer exists.
# Save + verify
fastaiagent connect --api-key fa_k_... --target https://<label>-dev.api.fastaiagent.net
# Self-hosted plane, with a project
fastaiagent connect --api-key fa_k_... --target https://platform.mycorp.com --project billing
# Inspect
fastaiagent auth status
# Connected (source: file)
# Target: https://<label>-dev.api.fastaiagent.net
# Project: (default)
# API key: fa_liv…ab34
# Print shell exports for sourcing
eval "$(fastaiagent auth env)"
# -> exports FASTAIAGENT_API_KEY, FASTAIAGENT_TARGET, FASTAIAGENT_PROJECT
# Remove
fastaiagent disconnect
Python interaction. fa.connect(api_key=...) in Python stays explicit — the CLI does not auto-connect your scripts. The intended pattern is to either (a) eval "$(fastaiagent auth env)" before starting your process and read os.environ["FASTAIAGENT_API_KEY"] in fa.connect(...), or (b) parse ~/.fastaiagent/credentials.toml yourself. Environment variables always win over the file.
fastaiagent traces¶
# List recent traces (last 24h by default)
fastaiagent traces list
fastaiagent traces list --last-hours 168
# Export a trace as JSON — printed to stdout, so redirect to save it
fastaiagent traces export <trace_id> > trace.json
fastaiagent traces export <trace_id> --format json
There is no --limit and no --output
traces list windows by time, not by row count — --last-hours N is its
only option. traces export takes --format (only json; any other value
is a usage error, exit 2, since 1.97.0) and writes to stdout; shell
redirection is how you get a file.
traces scrub-secrets¶
New in 1.89.0. Removes credentials that an SDK older than 1.89.0 may have
written into local.db: a key inside a guardrail's llm config (in the root
span's agent.guardrails), and a key a provider echoed back in an error
message. Versions from 1.89.0 on never store either; see
Security posture.
fastaiagent traces scrub-secrets --dry-run # report, write nothing
fastaiagent traces scrub-secrets # asks before rewriting
fastaiagent traces scrub-secrets -y # no prompt
The command scrubs exception text, keeps only the shareable fields of each
guardrail llm config, and replaces any credential currently in your
environment wherever it appears verbatim. It cannot recall spans that were
already sent to the control plane, so it counts them separately: rotate any
key it reports there.
fastaiagent replay¶
# Show replay steps
fastaiagent replay show <trace_id>
# Inspect a specific step
fastaiagent replay inspect <trace_id> <step>
# Fork a trace at a step, optionally modify the prompt or input, then rerun
fastaiagent replay fork <trace_id> --step 3 --prompt "New system prompt" \
--output rerun.json
fastaiagent replay fork <trace_id> --input "Try a different question"
# Recorded model turns; run the read-only lookup, stub the charge
fastaiagent replay fork <trace_id> --mode recorded --on-miss error \
--allow-tool lookup_order --stub 'charge_card="charged 0.00"'
replay fork is the CLI surface for
Replay.load(trace_id).fork_at(step).modify_prompt(...).modify_input(...).rerun().
Without --output it prints the result as JSON on stdout (before 1.97.0, a
Python dict that did not parse).
A rerun runs only the tools you give it (1.89.0). Every other tool is blocked,
and the result reports tool_dispositions and blocked_tool_calls. See
Replay guarantees.
| Flag | Default | Effect |
|---|---|---|
--step N |
0 |
Fork at this step. |
--prompt TEXT / --input TEXT |
none | Modify the system prompt / the input. |
--mode |
live |
live, recorded or deterministic: how the model is called. |
--on-miss |
live |
recorded mode: live or error when the rerun asks for more model turns than were recorded. |
--tools |
block (or FASTAIAGENT_REPLAY_TOOL_POLICY) |
block, error or live: what to do with tools you did not --stub or --allow-tool. |
--allow-tool NAME |
none | Run this tool for real. Repeatable. Required for REST and MCP tools. |
--stub NAME=JSON |
none | This tool returns JSON (or the bare string) instead of running. Repeatable. |
--db PATH |
the configured store | The local.db holding the trace to fork. |
--rerun-db PATH |
the configured store | Write the rerun's trace to this local.db instead. |
--export / --no-export |
--no-export |
Export the rerun to the platform. A rerun is local-only by default. |
--output PATH |
Write the result JSON here. |
fastaiagent eval¶
# Curate an eval dataset from captured agent traces
fastaiagent eval curate --filter favorites --out cases.jsonl
fastaiagent eval curate --filter guardrail --agent support --since 24 --out fixme.jsonl
# Run a dataset against an agent and gate on the result
fastaiagent eval run \
--agent app/agents.py:support_agent \
--dataset cases.jsonl \
--scorers exact_match,faithfulness \
--fail-under "overall.pass_rate=0.9" \
--max-error-rate 0.1 \
--run-name main \
--json report.json
# Compare two persisted runs (baseline first)
fastaiagent eval compare main pr --tolerance 0.02
# Inspect what Agent-CI evidence would leave this machine (connected mode)
fastaiagent eval export --status # posture + runs queued for the plane
fastaiagent eval export --dry-run # the literal JSON that would be sent
Each agent.<name> span (root, or nested inside a chain/supervisor/swarm) becomes
one case. See Trace Curation.
--agent accepts path/to/file.py:attr or pkg.module:attr (a callable, or any
object with a .run method). Thresholds use <scorer>.<pass_rate|avg_score>=v,
overall.pass_rate=v (the checks rate) or cases.pass_rate=v (the cases rate,
1.89.0); a bare scorer name means its pass_rate. overall.avg_score is
refused.
Exit codes: 0 gate passed · 1 quality gate failed (threshold miss or
regression) · 3 run invalid (infra error rate exceeded, nothing scored, a
gated scorer could not run or applied to no case, a threshold that is not a
metric, the dataset was not found, or the agent module failed to import; before
1.97.0 those two exited 1 with a traceback). 2 is a usage error, including a
malformed --agent spec or a missing attribute.
For gating your existing pytest suite — with baselines and regression detection — see Agent CI.
eval export only inspects; it never sends. When connected, gate verdicts are
pushed automatically in the background — run aggregates, gate outcome, thresholds,
git provenance and per-case scorer verdicts + trace_ids. Case inputs and outputs
are never sent. Disable with connect(export_evals=False) or
FASTAIAGENT_EXPORT_EVALS=0; see
Agent CI → Connected mode.
fastaiagent prompts¶
# List registered prompts
fastaiagent prompts list
# Diff two versions (version numbers, positional)
fastaiagent prompts diff <name> 1 2
fastaiagent kb¶
# List all KBs under the default root (.fastaiagent/kb/)
fastaiagent kb list
# List under a custom root
fastaiagent kb list --path /srv/fastaiagent/kb/
# Status of one KB
fastaiagent kb status --name product-docs
# Ingest a file or directory
fastaiagent kb add docs/ --name product-docs
fastaiagent kb add docs/refund.md --name product-docs
# Delete by source file
fastaiagent kb delete docs/old.md --name product-docs
# Clear the whole KB
fastaiagent kb clear --name product-docs
kb status, kb delete and kb clear exit 1 for a KB that does not exist,
and kb add exits 1 for a path that does not exist. Before 1.97.0 a mistyped
--name created an empty KB, and a mistyped path was stored as a document
holding the path itself.
fastaiagent ui¶
Start the Local UI — traces, prompts, evals, guardrails,
datasets, and approvals over ./.fastaiagent/local.db.
fastaiagent ui # http://127.0.0.1:7842
fastaiagent ui start --no-auth --port 8080
fastaiagent ui reset-password
| Flag | Default | Effect |
|---|---|---|
--host |
127.0.0.1 |
Bind address. Non-loopback requires --insecure-bind. |
--port |
7842 |
Port. |
--no-auth |
off | Skip login. Throwaway use only. |
--no-open |
off | Don't open a browser. |
--insecure-bind |
off | Acknowledge the risk of a non-loopback bind. |
--db PATH |
./.fastaiagent/local.db |
Override the DB path. |
--auth-file PATH |
./.fastaiagent/auth.json |
Override the credentials file. |
--agent SPEC |
none | Register an agent with the server. Repeatable. |
--agent¶
Most of the UI reads the trace database, so it needs no setup. Three features need the live object: resuming an approval, evaluating a dataset against a real agent, and listing an agent's tools before its first run.
fastaiagent ui --agent app.py:support_agent
fastaiagent ui --agent app.py:support --agent mypkg.agents:billing
Takes path/to/file.py:attr or pkg.module:attr — the same syntax as
fastaiagent agent serve and fastaiagent eval run — resolving to an
Agent, Chain, Swarm, or Supervisor. Targets that fail to resolve are
reported and skipped; the UI still starts. The module is imported, so guard
module-level side effects with if __name__ == "__main__":.
Where pkg.module is looked up
Every command that takes a pkg.module:attr target (ui --agent,
agent serve, mcp serve, eval run --agent, resume --runner, push
--module, runner --tools) finds a package that is installed or sits
in the directory you run the command from, like python -m does. The
current directory is searched last, so an installed package or the
standard library always wins over a same-named file in it. Before 1.95.0
an uninstalled package in the project directory failed with No module
named … unless you set PYTHONPATH=..
Unlike agent serve, this does not expose an endpoint that runs your
agent on request. Import paths are read only from the command line, never
from a request body.
Security¶
The Local UI binds to loopback and refuses anything else unless you pass
--insecure-bind, since the session cookie travels over plain HTTP. This is
the opposite default from agent serve, which binds 0.0.0.0 for
containers.
fastaiagent agent serve¶
Run any Agent or Chain as a FastAPI service that exposes the uniform deployment contract:
# path/to/file.py:attr
fastaiagent agent serve examples/01_simple_agent.py:agent --port 8000
# pkg.module:attr
fastaiagent agent serve mypkg.agents:research_bot --port 9000
Exposes:
- GET /health
- POST /run — {"input": "..."} → {"output", "latency_ms", "tokens_used", "trace_id", "status", "execution_id", "pending_interrupt"}. status is "paused" when the run stopped for a decision — a managed approval policy or an interrupt() — with empty output and the reason and context (for a policy pause, the tool and its arguments) in pending_interrupt.
- POST /run/stream — Server-Sent Events (Agent targets only). A run that pauses ends with a {"type": "paused", "reason", "execution_id", "context"} event before done (1.77.0).
- POST /resume — {"execution_id": "...", "approved": true, "metadata": {}} → the same response as /run (since 1.92.0). Resumes a paused run: approved and metadata become the Resume the paused tool receives. A run that is not waiting (or was already resumed) answers 409; an unknown Chain execution answers 404. The target needs a checkpointer, as for any resume.
- POST /cancel — {"execution_id": "..."} → {"execution_id", "cancelled": true} (since 1.93.0). Stops a run in progress; its own /run request then answers status="cancelled". Name the run by passing "execution_id" in the /run or /run/stream body. A run not in progress answers 404.
- GET /openapi.json and /docs — the API description (it answered 500 before 1.93.0).
A /run whose client hangs up is cancelled within half a second (since 1.93.0;
before, an abandoned run kept calling the model and its tools to the end). A
/run/stream whose client stops reading ends failed, as before.
curl -X POST localhost:8000/run -d '{"input": "Refund order 42"}' -H 'Content-Type: application/json'
# {"status": "paused", "execution_id": "4f1c…", "pending_interrupt": {...}, ...}
curl -X POST localhost:8000/resume -H 'Content-Type: application/json' \
-d '{"execution_id": "4f1c…", "approved": true, "metadata": {"resolver": "alice"}}'
# {"status": "completed", "output": "...", ...}
--reload was removed in 1.92.0: uvicorn reloads only from an import string, and
serve hands it an app object, so the flag never worked. Restart the command after a change.
Security¶
/run, /run/stream and /resume execute your agent — including its tools and LLM calls — so treat the port as sensitive. --auth-token covers them and /cancel.
- Default bind is
0.0.0.0so the service is reachable when running inside a container (binding127.0.0.1would make it unreachable through Docker/Kubernetes port mapping). Pass--host 127.0.0.1for a purely local service. - The execution routes are unauthenticated by default. Enable a bearer token with
--auth-token <token>(or theFASTAIAGENT_SERVE_TOKENenv var); callers then sendAuthorization: Bearer <token>.GET /healthstays open for liveness probes. - When bound to a non-loopback address without a token, the command prints a startup warning. For any network-exposed deployment, set a token and terminate TLS at a reverse proxy so the token isn't sent in plaintext.
--max-body-bytescaps request size (default 10 MiB).
# Authenticated, container-friendly:
FASTAIAGENT_SERVE_TOKEN=$(openssl rand -hex 32) \
fastaiagent agent serve mypkg.agents:research_bot --port 9000
# Local-only, no auth needed:
fastaiagent agent serve examples/01_simple_agent.py:agent --host 127.0.0.1
If you need custom routes / auth / middleware, copy examples/33_deploy_fastapi.py and extend it directly instead.
Requires: pip install fastapi 'uvicorn[standard]' (or fastaiagent[all]).
fastaiagent mcp serve¶
Expose an Agent or Chain as an MCP server over stdio — registers with Claude Desktop, Cursor, Continue, Zed, and any other MCP client:
fastaiagent mcp serve path/to/my_agent.py:agent
fastaiagent mcp serve path/to/my_agent.py:agent --expose-tools --name research_bot
fastaiagent mcp serve path/to/my_chain.py:chain
--expose-tools applies to an Agent only; a Chain is served as its one primary tool. (Before
1.92.0 serving any Chain failed with TypeError.)
See docs/tools/mcp-server.md for Claude Desktop / Cursor config snippets.
Requires: pip install 'fastaiagent[mcp]'.
fastaiagent skills¶
Install the Agent Skills that teach a coding assistant this SDK — see Use fastaiagent with a coding assistant.
fastaiagent skills install # this project: .claude/skills and .agents/skills
fastaiagent skills install --user # every project: ~/.claude/skills and ~/.agents/skills
fastaiagent skills install --tool agents # only .agents/skills (Copilot, Cursor, Antigravity, Codex...)
fastaiagent skills install --force # replace a copy left by an older SDK
fastaiagent skills list # packaged skills + installed copies, with a stale flag
fastaiagent skills path # the folder the skills ship in
install copies each skill into .claude/skills/<name>/ (Claude Code) and
.agents/skills/<name>/ (GitHub Copilot, Cursor, Google Antigravity, Codex, Gemini CLI and
others), and stamps the SDK version in each copy. It prints a JSON summary on stdout, notes on
stderr, and exits 1 when a copy already exists from another version and --force was not given,
or the destination is a symbolic link; 2 for an unknown --tool.
| Option | Does |
|---|---|
--tool claude\|agents\|all |
Which folder to install into (default all) |
--user |
Install into your home folder instead of the project |
--force |
Replace an existing copy |
--agents-md / --no-agents-md |
Add a three-line pointer to AGENTS.md — created if missing, appended to otherwise, never rewritten. Asked about only when there is a terminal; skipped when there is none. |
--claude-md |
Also add the pointer to CLAUDE.md, which is never edited otherwise |
fastaiagent studio¶
Build an agent through Agent Studio from a terminal or a coding tool. You (or the tool's model) design
the agent and write it as a spec; Studio checks it, renders the code, runs trials and evals in its
sandbox, keeps every version and exports a project. It never calls Studio's own model. It needs a
platform at 0.20.0 or later and a key with studio:read and studio:write. The whole story is in
Agent Studio from the command line and from code.
fastaiagent studio context --json
fastaiagent studio new --name "Order desk" --brief "Answer order-status questions." --data orders.csv
fastaiagent studio spec validate "Order desk" spec.json
fastaiagent studio spec push "Order desk" spec.json --note "first design" --wait
fastaiagent studio try "Order desk" "What is the status of order 1003?"
fastaiagent studio eval "Order desk"
fastaiagent studio export "Order desk" --out .
<draft> is a draft's id or its name. Credentials are resolved as fastaiagent push does (--api-key
and --target, else FASTAIAGENT_API_KEY and FASTAIAGENT_TARGET, else what fastaiagent connect
saved). Every command takes --json (the answer as one JSON document on stdout), --api-key,
--target and --project-id (only for a key that is not tied to one project). Notes and errors go to
stderr. Exit 0 means it happened, 1 that it did not (a refusal, a spec with problems, an eval case
that failed), 2 a usage error. With --json a failure is also printed on stdout as
{"error": {"code", "message", "hint", "status", "details"}}.
| Command | Does |
|---|---|
studio context |
The project's LLM endpoints, knowledge bases, guardrail names, tool types, limits and SDK contract. Read it first |
studio list [--status S] [--query Q] [--limit N] |
The project's drafts, each with its step |
studio new --name N --brief B [--data FILE]... [--data-text NAME=FILE]... [--harness] [--endpoint ID] |
Make a draft and add sample data. --data-text is for text you read yourself (a scan or image). --endpoint is needed when the project has more than one LLM endpoint |
studio status <draft> |
The step state and the next action. Says so when someone changed the draft in the console (stale) |
studio spec schema [--full] |
Print the spec's JSON Schema |
studio spec validate <draft> <file> |
Check a spec; makes nothing. Exit 0 only with no problems; warnings do not change it |
studio spec push <draft> <file> [--note T] [--wait] |
Make the next version from a whole spec |
studio spec get <draft> [--version N] [--out FILE] |
The spec of a version, to edit and push again |
studio show <draft> [--version N] [--files] [--file PATH] |
The design (blueprint), or the generated code |
studio diff <draft> A B |
What changed between versions A and B |
studio try <draft> QUESTION [--worker W] [--version N] [--wait\|--no-wait] |
One question in the sandbox (started if needed): the answer, the tool calls, the trace link. A team needs --worker. Waits by default; exit 1 if the trial failed |
studio eval <draft> [--worker W] [--case C] [--wait\|--no-wait] |
Run the eval cases. Exit 0 only when no case failed. A case that "needs review" is not a failure |
studio export <draft> [--out DIR] [--version N] [--force] |
Unpack the project into a folder. Refuses to overwrite without --force, and then writes nothing |
studio promote <draft> --agent ID |
Turn the eval cases into an eval suite on an agent the exported code registered |
studio open <draft> |
Print the draft's console address (it does not open a browser) |
studio delete <draft> [--yes] |
Delete a draft. It asks only at a terminal |
There is no studio plan, build, refine or reset: those need Studio's own model and stay in the
console. A trial applies no guardrails and answers tools from sample data; guardrails apply in the
exported code. A coding assistant is taught the loop by the fastaiagent-studio skill, which
fastaiagent skills install installs.
Durability commands¶
The four commands below cover the v1.0 durability workflow: pause an execution with interrupt(), list what's waiting, then resume from any process.
fastaiagent list-pending¶
Rich-rendered table of every pending interrupt in the local store:
fastaiagent list-pending
fastaiagent list-pending --db-path /var/lib/fastaiagent/local.db
fastaiagent list-pending --limit 50
fastaiagent inspect <execution_id>¶
Checkpoint history for one execution — node-by-node statuses, timestamps, and agent_path for multi-agent topologies:
Exits 1 when the execution has no checkpoints.
fastaiagent resume <execution_id>¶
Loads the runner via a Python entrypoint and calls aresume(...):
# Approve
fastaiagent resume refund-abc --runner myapp.flows:build_chain
# Reject with a reason
fastaiagent resume refund-abc \
--runner myapp.flows:build_chain \
--value '{"approved": false, "metadata": {"reason": "amount above threshold"}}'
Exits 2 on AlreadyResumed (another resumer claimed the pending row first — a deterministic outcome, not a bug).
fastaiagent setup-checkpointer¶
Provisions the durability backend's schema. Idempotent for both backends.
# Local SQLite (default)
fastaiagent setup-checkpointer
# Postgres
fastaiagent setup-checkpointer \
--backend postgres \
--connection-string "$DATABASE_URL"
# Custom Postgres schema (so two installs share one DB)
fastaiagent setup-checkpointer \
--backend postgres \
--connection-string "$DATABASE_URL" \
--schema fa_prod
See docs/durability/checkpointers.md for the full backend reference.
Environment variables¶
| Variable | Used by |
|---|---|
FASTAIAGENT_API_KEY |
fastaiagent auth status / auth env (CLI only; Python connect() does not read it, pass api_key=) |
FASTAIAGENT_TARGET |
Platform URL override |
FASTAIAGENT_PROJECT |
fastaiagent auth status / auth env (CLI only; Python connect() takes project=) |
FASTAIAGENT_LOCAL_DB |
Local SQLite store (traces, checkpoints, idempotency, prompts) |
FASTAIAGENT_CHECKPOINT_DB_PATH |
Override checkpoint store path (legacy; prefer FASTAIAGENT_LOCAL_DB) |
FASTAIAGENT_LIVE_OPENAI_MODEL |
Override OpenAI model in live tests |
FASTAIAGENT_LIVE_ANTHROPIC_MODEL |
Override Anthropic model in live tests |
OPENAI_API_KEY |
LLM calls (OpenAI) |
ANTHROPIC_API_KEY |
LLM calls (Anthropic) |
fastaiagent export-trace¶
Export a single trace as a self-contained JSON file. Reads the local SQLite directly — no UI server required.
fastaiagent export-trace --trace-id <id> --output trace.json
fastaiagent export-trace --trace-id <id> --output trace-full.json \
--include-attachments --include-checkpoint-state
Flags:
--trace-id <id>(required) — the trace to export.--output <path>(defaulttrace.json) — destination file.--include-attachments— embed image / PDF bytes (base64) in the JSON. Off by default; files can balloon to many MB.--include-checkpoint-state— embed fullstate_snapshotblocks for each checkpoint. Off by default.--db <path>— override the local DB; defaults to whateverSDKConfig.local_db_pathresolves to (typically.fastaiagent/local.db).
Same JSON shape comes out of the Local UI's Export dialog. See Export trace as JSON for the schema.