Skip to Content
Axe OS
How it works

Runtimes

A runtime is a harness plus its logins on the node: one per provider. Claude, Codex, OpenCode and Pi.

Paths in crates/axe-core/src/, crates/axe-telegram/src/, crates/axe-node/src/, crates/axe-server/src/ or crates/axe/src/ (a file is in one) unless noted.

Runtimes. A runtime is a harness plus its logins on the node (runtime.rs): one login per provider, and a login is never shared between runtimes. Claude and Codex hold exactly one login. With [runtimes] dir, each <dir>/<name>/runtime.toml names its harness, optionally the agent template that drives it (default: the harness's built-in agent, claude or codex; see Configuration), a login_dir (the CLI's own default, ~/.claude or ~/.codex, is adopted in place: the node only sets the harness row's login_env variables, CLAUDE_CONFIG_DIR or CODEX_HOME, for any other directory and never touches the login; harness.rs), plan and disabled. Rules pick a harness; the node takes its least-used healthy runtime, skips to the next use entry when none is healthy, and otherwise returns the task to pending until one may be (run refunded). When the listed harnesses have runtimes but none will recover on its own (each needs a login or is disabled), the task runs on the least-used healthy runtime of another harness with that harness's defaults, and the run's rule reads rule:N (...) failover (...) (Dispatcher::failover in dispatch.rs); a task pin (--agent) never fails over. A stored session resumes on its own runtime while it is healthy; sessions recorded before runtimes resolve to the runtime on the default login. Quota, credit, login and provider failures (failure.rs) mark the runtime limited, needs_login or degraded (<name>/state.json); out of credit (HTTP 402) is limited with no end time and lasts until a login check passes (Check on its card), and on a runtime that holds several provider keys it marks only that provider's login (Registry::mark_run); a needs_login runtime is probed with claude auth status / codex login status until it passes; a runtime on a provider key is probed with that provider's free key check instead (see Providers). A runtime with no state.json yet (never checked) needs its login probe to pass before it takes a run (no card); one that never passed a login and never failed a run shows as "not logged in". The node reports each runtime's state, last failure, quota and meter with its admission report, never a login directory or credential: the meter (harness::Meter) is the week's share for a subscription login, the last 7 days' spend (spend_7d, added by the server from its cost records) for an API key or provider key, or none (Codex); axe runtimes list, GET /api/runtimes and the Telegram owner command /runtimes show them, and a runtime turning limited or needs_login, or its weekly quota reaching 80%, sends the owner one card ([telegram] ops_bot, default the first bot; see runtimes from Telegram). Without [runtimes], every agent the config sets, plus claude, is a runtime on the default login and always healthy.

Providers. A provider is who serves and bills the model; the provider table holds one row each (provider.rs: deepseek, openrouter, openai, anthropic, google, and other), with the variable the key is read from, the key's format, a free key check (GET with the key as a bearer, or in a header such as Gemini's x-goog-api-key: 200 is a working key, 401 or 403 a wrong one, and 400 for Gemini), its default model (run when a rule names none), and the harnesses that can use it. other (Other…) is any OpenAI-compatible server the owner names by its base URL, kept beside the key (<name>/login/OTHER_BASE_URL); its key check is <base>/models (<base>/v1/models on Claude Code's Anthropic-compatible URL), and it has no default model, so a rule names its model. openai, anthropic and google are for OpenCode and Pi; Claude takes an Anthropic key as its own API key login; axe runtimes add --help, axe runtimes login --help and axe rule add --help list the harnesses and providers from these rows. A harness row says which providers it takes (Harness::providers): Claude takes Anthropic by its own logins, or the key of one row with an Anthropic-Messages endpoint (anthropic_url) or of other; Codex takes OpenAI only. axe runtimes login <runtime> --method api_key --provider <id> --bot <b> sends the owner a sealed form for that provider's key (sealed::Target::Runtime carries the provider; a harness that does not take it is refused before the form is sent, and again by the node). The key is kept as <name>/login/<VAR> (DEEPSEEK_API_KEY) and checked at once with the key check, which is also the runtime's probe. On Claude a provider login replaces the last login like any other, and the run gets ANTHROPIC_BASE_URL, the key as ANTHROPIC_AUTH_TOKEN (a bearer), the row's model per tier (ANTHROPIC_DEFAULT_*_MODEL, CLAUDE_CODE_SUBAGENT_MODEL) and an empty ANTHROPIC_API_KEY, never an Anthropic credential (Runtime::env). A rule's model that is none of the row's tier models (claude-code:openrouter/deepseek/deepseek-v4-flash) takes every tier, so Claude Code's background and subagent calls stay on it (runtime::tier_env). From Telegram this login is Other provider… under Claude's login methods (see runtimes from Telegram). A harness that takes the provider table keeps one key per provider: a new key replaces only its own provider's. Each key's last check is kept per provider in state.json (providers) and reported with the runtime (ids and states only).

OpenCode. The opencode row runs OpenCode 2 (npm @opencode/cli, verified on 2.4.3: Harness::package) as opencode run --standalone --format json --auto --title axe -s ses_<session> <prompt>: a private server per run, and -s creates the session on the first run and resumes it after. It takes the provider table (deepseek, openrouter, openai, anthropic, google, other): one key per provider, each checked by its key check, which is also the probe. A runtime keeps everything OpenCode writes under its own login directory through the four XDG variables (config, data, state, cache under <dir>/<name>/home), shares nothing with ~/.config/opencode, and axe writes its config/opencode/opencode.json (harness::ConfigFile): the first held provider's row default (deepseek/deepseek-flash), each held row's default declared under its provider, other as an @ai-sdk/openai-compatible provider on its base URL, and "update": "disable", never a key; it is rewritten when a key is added or dropped and when the node loads the registry. Before a run whose rule names a model, that model is declared under its provider too (Runtime::write_config_for): OpenCode refuses a model its catalog does not list yet, and an other model is known only from the rule. Keys reach OpenCode as environment variables (DEEPSEEK_API_KEY), where its built-in providers read them. A bot's system prompt goes in OPENCODE_CONFIG_CONTENT as an instructions file (Harness::bot_env), and a rule's effort as a model variant (-m deepseek/deepseek-flash#high). Failures come from its error line: 401 is a login failure, 402 out of credit, 429 and 5xx an unavailable provider (failure::opencode). OpenCode keeps sessions in its own database, so retention prunes no transcripts for it.

Pi. The pi row runs Pi (npm @earendil-works/pi-coding-agent, verified on 1.7.0: Harness::package) as pi --mode json -p --no-approve --offline --session-id <session> <prompt>: --session-id creates the session on the first run and resumes it after, --no-approve ignores Pi files in the run folder, and --offline skips Pi's startup update check and catalog refresh. It takes the same provider table as OpenCode (every row), one key per provider, with the same setup. A runtime points PI_CODING_AGENT_DIR at <dir>/<name>/home/agent, shares nothing with ~/.pi, and axe writes its agent/settings.json (harness::ConfigFile): the first held provider as defaultProvider and its row default as defaultModel, and agent/models.json with other as an openai-completions provider on its base URL and the rule's model, never a key. Keys reach Pi as environment variables (DEEPSEEK_API_KEY, OPENROUTER_API_KEY, GEMINI_API_KEY, ...). A bot's system prompt goes in as --append-system-prompt <file> on every run (Harness::bot_args), a rule's model as --model provider/model and its effort as --thinking <level>. Pi exits 0 even when the provider fails, so the node reads a Pi run's failure on any exit (LogFormat::exit_failure): its last failed model call (errorMessage, which starts with the HTTP status) gives 401 as a login failure, 402 out of credit, and 429 or 5xx an unavailable provider (failure::pi). Its session transcripts (agent/sessions/<cwd>/<time>_<session>.jsonl) are pruned by retention like Claude's (retention::scan_pi).

Picking by provider. A rule's model may name its provider: axe rule add --default --use claude-code:deepseek/deepseek-flash:high (a provider-table id, then the model; rule.rs, Use::fits). Such an entry runs only on a runtime of that harness holding a login for that provider whose last key check did not fail (Runtime::runs); otherwise the node goes to the next use entry, and failover too needs a working login for that provider, so a DeepSeek rule never runs on a runtime without a DeepSeek key. Claude Code gets the model without the provider (--model deepseek-flash); a harness that takes the provider table gets provider/model, and a row's model_effort_args passes model and effort as one argument when a rule sets both (harness.rs). An entry naming no provider (claude-code, claude-code:opus) runs on a Claude runtime on an Anthropic login only, and a claude pin (--agent claude, a bot with no primary) prefers one too, so Claude and Codex picks are as before. A runtime picked by a pin, a bot's primary or backup, a resumed session or failover gets the rule's first entry for its harness that it serves, else its own default model, never a model it has no login for (RuntimeConfig::with). A runtime stores no model of its own: models come only from rules, and a provider login runs its row's default_model when a rule names none. The owner sets a model by asking a bot for a rule (axe rule add --use opencode:openrouter/openai/gpt-6.2-sol).