Environment Variables

Environment variables injected by agentd at agent spawn time and used by the libagent SDK.

Injected by agentd

These variables are always set when agentd spawns an agent process.

VariableAlways setDescription
SCARAB_AGENT_IDYesUUID of the running agent instance
SCARAB_SOCKETYesAbsolute path to the agentd Unix domain socket
SCARAB_TASKIf spec.task is setThe agent's declared goal or task string
SCARAB_MODELIf spec.model is setPreferred LLM model identifier

SCARAB_AGENT_ID

A UUID (version 4) uniquely identifying this agent instance. A new UUID is assigned on every spawn, including restarts.

SCARAB_AGENT_ID=550e8400-e29b-41d4-a716-446655440000

Used by Agent::from_env() in libagent to establish the agent's identity on the IPC socket.

SCARAB_SOCKET

Absolute path to the Unix domain socket over which the agent communicates with agentd.

SCARAB_SOCKET=/run/agentd/agentd.sock

Default socket path: /run/agentd/agentd.sock. Override via ash --socket <path> when starting ash, or configure in agentd.toml.

SCARAB_TASK

The agent's task string from spec.task in the manifest, or the --task override from ash agent run.

SCARAB_TASK=Summarize the latest news about renewable energy in 3 bullet points.

Not set if spec.task is absent and no --task override was provided. Read with:

#![allow(unused)]
fn main() {
let task = std::env::var("SCARAB_TASK").unwrap_or_default();
}

SCARAB_MODEL

The preferred LLM model identifier from spec.model in the manifest.

SCARAB_MODEL=anthropic/claude-opus-4-6

Not set if spec.model is absent. The agent passes this to lm.complete:

#![allow(unused)]
fn main() {
let model = std::env::var("SCARAB_MODEL").ok();
}

Reading variables in Rust

The Agent::from_env() constructor reads SCARAB_AGENT_ID and SCARAB_SOCKET automatically:

use libagent::agent::Agent;

#[tokio::main]
async fn main() {
    let mut agent = Agent::from_env().await.expect("failed to connect to agentd");

    let task = std::env::var("SCARAB_TASK").unwrap_or_else(|_| "default task".to_string());
    let model = std::env::var("SCARAB_MODEL").unwrap_or_else(|_| "default-model".to_string());

    // agent is ready to use
}

agentd configuration variables

These control agentd's own behavior and are set in the operator's shell before starting agentd, or in agentd.toml.

VariableDescription
AGENTD_SOCKETOverride the default socket path
AGENTD_LOGLog level: error, warn, info, debug, trace
AGENTD_DB_PATHSQLite database directory for persistent stores
AGENTD_API_ADDRHTTP bind address for the API gateway (default: 127.0.0.1:8080)
AGENTD_API_CORS_ORIGINSComma-separated allowed CORS origins; empty or * allows all
AGENTD_API_TOKEN_DBSQLite path for the API token store (default: /tmp/agentd_api_tokens.db)

AGENTD_API_ADDR

Overrides the HTTP bind address for the embedded API gateway.

AGENTD_API_ADDR=0.0.0.0:9090

Default: 127.0.0.1:8080. Set to 0.0.0.0:<port> to accept connections from remote hosts.

AGENTD_API_CORS_ORIGINS

Controls which browser origins are permitted to make cross-origin requests to the API gateway.

AGENTD_API_CORS_ORIGINS=https://dashboard.example.com,https://ci.example.com

When empty or set to *, all origins are allowed. Allowed methods and headers are always unrestricted.

AGENTD_API_TOKEN_DB

Path to the SQLite database used to store API token hashes.

AGENTD_API_TOKEN_DB=/var/lib/agentd/api_tokens.db

Default: /tmp/agentd_api_tokens.db. In production, set this to a persistent path.

Agent LLM variables

These are read by agent binaries (not by agentd) to control model behaviour.

VariableSet byDescription
SCARAB_CLASSIFIER_MODELOperatorOpenRouter model used as the secondary injection classifier when injection_policy: dual_validate (Phase 9.1). Default: anthropic/claude-haiku-4-5.
SCARAB_DEFAULT_MODELOperatorFallback model when spec.model_policy: explicit and no explicit model is provided (Phase 9.3). Default: anthropic/claude-haiku-4-5.

SCARAB_CLASSIFIER_MODEL

Overrides the classifier model used for dual-model prompt injection detection. The classifier receives the untrusted content and responds with SAFE or UNSAFE. Lighter/cheaper models are typically sufficient.

export SCARAB_CLASSIFIER_MODEL=openai/gpt-4o-mini

SCARAB_DEFAULT_MODEL

Fallback model for lm.complete and lm.chat when policy is explicit and neither the tool call input nor SCARAB_MODEL provides a model.

export SCARAB_DEFAULT_MODEL=anthropic/claude-sonnet-4-6

ash configuration variables

VariableDescription
ASH_SOCKETDefault socket path for ash (overridden by --socket flag)