Skip to content
AGH RuntimeConfiguration

Environment Variables

Environment variables AGH reads, injects, propagates, and explicitly does not support.

Audience
Operators running durable agent work
Focus
Configuration guidance shaped for scanability, day-two clarity, and operator context.

AGH reads a small core set of environment variables, injects session identity into managed agent subprocesses, and lets some extension providers use process-level overrides.

Precedence

SourceApplies toPrecedence
Process environmentAll AGH commands and daemon startup.Base environment.
<workspace>/.envConfig loads that include a workspace root.Loaded before $AGH_HOME is resolved. Does not override variables already set by the process loader.
config.tomlRuntime config values.Used for AGH config. There is no AGH_CONFIG or AGH_LOG_LEVEL override today.
Managed session env injectionAgent subprocesses.Starts from daemon environment, sets AGH session variables, sets AGH_BIN, and prepends the daemon binary directory to PATH.
Hook subprocess envHook subprocesses.Starts from an allowlist of parent env vars, then applies hook env overrides.

Core Variables AGH Reads

VariableTypeDefaultValid valuesDescription
AGH_HOMEpath~/.aghNon-empty path.Overrides the global AGH home directory. If a workspace .env sets it, that value can affect config loading for that workspace before home paths are resolved.
AGH_DEV_VERIFY_BOUNDARIESboolean stringunset1, true, or yes enable boundary verification.Development-only daemon boundary import verification toggle.
GITHUB_TOKENtoken stringunsetNon-empty token.Used by the GitHub registry client for private repositories and higher rate limits.

Provider credential variables

Provider config binds launch-time credentials only when a provider uses auth_mode = "bound_secret". Each credential_slots entry names a target environment variable and resolves its value from either env:NAME or an encrypted AGH secret ref such as vault:providers/openrouter/api-key. AGH injects only the bound value into the provider subprocess.

Direct ACP providers such as Claude Code, OpenClaw, Hermes, Codex, Gemini CLI, OpenCode, Kimi CLI, Qoder, and similar CLIs use auth_mode = "native_cli" by default. The direct pi provider also uses Pi's /login and auth file by default. Wrapped API-key providers such as OpenRouter, z.ai, Moonshot/Kimi, Vercel AI Gateway, xAI, MiniMax, Mistral, and Groq default to auth_mode = "bound_secret": AGH exposes them directly, launches Pi under the hood, and injects the configured provider key.

VariableDefault providerDefaultValid valuesDescription
ANTHROPIC_API_KEYpiunsetProvider-specific token.Optional Pi-owned env credential for direct pi, or an explicit bound-secret target.
OPENROUTER_API_KEYopenrouterunsetProvider-specific token.Default AGH-managed credential target for the OpenRouter wrapper.
ZAI_API_KEYzaiunsetProvider-specific token.Default AGH-managed credential target for the z.ai wrapper.
KIMI_API_KEYmoonshotunsetProvider-specific token.Default AGH-managed credential target for the Moonshot/Kimi wrapper.
AI_GATEWAY_API_KEYvercel-ai-gatewayunsetProvider-specific token.Default AGH-managed credential target for the Vercel AI Gateway wrapper.
XAI_API_KEYxaiunsetProvider-specific token.Default AGH-managed credential target for the xAI wrapper.
MINIMAX_API_KEYminimaxunsetProvider-specific token.Default AGH-managed credential target for the MiniMax wrapper.
MISTRAL_API_KEYmistralunsetProvider-specific token.Default AGH-managed credential target for the Mistral wrapper.
GROQ_API_KEYgroqunsetProvider-specific token.Default AGH-managed credential target for the Groq wrapper.

AGH_VAULT_KEY can override the daemon-local Vault encryption key. When it is unset, AGH creates $AGH_HOME/vault.key with 0600 permissions the first time it needs to encrypt or decrypt a vault-backed secret.

Use Vault for AGH-managed encrypted values that should be written through CLI, HTTP, UDS, or web surfaces. Use env:NAME when the service manager or shell that starts the daemon should remain the source of truth for the secret value.

Automation Webhook Secrets

Config-defined webhook triggers require [[automation.triggers]].webhook_secret_ref. Use env:NAME for operator-managed environment variables or vault:automation/... for AGH-managed encrypted secrets.

Variable named by env: refTypeDefaultValid valuesDescription
AGH_DEPLOY_WEBHOOK_SECRET examplestringnoneMust exist and be non-empty when the ref is resolved.Secret used to validate config-defined automation webhooks.

Example:

[[automation.triggers]]
scope = "global"
name = "deploy-webhook"
agent = "release"
prompt = "Handle deploy webhook {{ .Kind }}."
event = "webhook"
endpoint_slug = "deploy"
webhook_secret_ref = "env:AGH_DEPLOY_WEBHOOK_SECRET"
export AGH_DEPLOY_WEBHOOK_SECRET="replace-with-secret"

Variables AGH Injects Into Agent Sessions

Managed ACP agent subprocesses start from the provider's env_policy. filtered inherits the daemon environment after removing secret-shaped variables; isolated keeps only a fixed operational allowlist. AGH then applies these changes:

VariableTypeDefaultValid valuesDescription
AGH_SESSION_IDstringset for every managed sessionSession ID.Injected into the agent process and read by agh whoami.
AGH_AGENTstringresolved agent nameAgent name.Injected for agent identity metadata.
AGH_AGENT_NAMEstringresolved agent nameAgent name.Injected for agent identity metadata.
AGH_PROVIDERstringresolved provider idProvider id.Injected for provider-aware tools and diagnostics.
AGH_PROVIDER_HARNESSstringresolved provider harnessacp, pi_acp.Injected for provider-aware tools and diagnostics.
AGH_PROVIDER_AUTH_MODEstringresolved provider auth modenative_cli, bound_secret, none.Identifies whether auth is native CLI, AGH-bound secret, or none.
AGH_PROVIDER_ENV_POLICYstringresolved provider env policyfiltered, isolated.Identifies which daemon environment policy was used.
AGH_PROVIDER_HOME_POLICYstringresolved provider home policyoperator, isolated.Identifies whether the provider uses operator or isolated home state.
AGH_MODELstringresolved modelProvider model string.Injected for provider-aware tools and diagnostics.
PROVIDER_HOMEpathset only when home_policy = "isolated"AGH-owned provider home.Points generic provider CLIs at $AGH_HOME/providers/<provider>.
HOMEpathprovider home when isolated, otherwise parent.Existing path.Redirected to provider home only for isolated provider-home launches.
XDG_CONFIG_HOMEpathset only when provider home is isolatedProvider config directory.Generic config location under the isolated provider home.
XDG_DATA_HOMEpathset only when provider home is isolatedProvider data directory.Generic data location under the isolated provider home.
XDG_CACHE_HOMEpathset only when provider home is isolatedProvider cache directory.Generic cache location under the isolated provider home.
CLAUDE_CONFIG_DIRpathset only for isolated claude providersProvider Claude config directory.Points Claude Code at isolated AGH-owned auth/config state.
CODEX_HOMEpathset only for isolated codex providersProvider Codex home directory.Points Codex at isolated AGH-owned auth/config state.
PROVIDER_CODEX_HOMEpathset only for isolated codex providersProvider Codex home directory.Mirrors CODEX_HOME for QA and provider-launch diagnostics.
OPENCODE_CONFIG_DIRpathset only for isolated opencode providersProvider OpenCode config directory.Points OpenCode at isolated AGH-owned auth/config state.
PI_CODING_AGENT_DIRpathset for native Pi isolated home or Pi-backed bound_secret sessionsPi auth/config directory.Points Pi at the isolated native auth store or bound-secret runtime config.
AGH_SESSION_CHANNELstringunset unless the session has a network channelNetwork channel name.Injected for channel sessions. Stale values are removed for non-channel sessions.
AGH_PEER_IDstringunset unless the session has a network channel<agent-name>.<session-id>Injected for channel sessions. Stale values are removed for non-channel sessions.
AGH_BINabsolute pathcurrent AGH executableExisting executable path.Injected into ACP provider subprocesses so agents can call the same AGH binary.
PATHpath listinherited or allowlistedPath list for the operating system.The directory containing AGH_BIN is prepended and duplicate entries are removed.

Hook Subprocess Environment

Hook subprocesses do not inherit the full daemon environment. They inherit an allowlist and then apply explicit hook env values from config, AGENT.md, or SKILL.md.

VariableTypeDefaultValid valuesDescription
COMSPECstringinherited if setAny string.Windows command processor environment.
HOMEpathinherited if setPath.User home.
LANGstringinherited if setLocale string.Locale.
LC_ALLstringinherited if setLocale string.Locale override.
LC_CTYPEstringinherited if setLocale string.Character classification locale.
LOGNAMEstringinherited if setUser name.Login name.
PATHpath listinherited if setPath list.Executable lookup path for hook commands.
PATHEXTstringinherited if setWindows extension list.Windows executable extension lookup.
SHELLpathinherited if setShell path.User shell.
SYSTEMROOTpathinherited if setWindows system root.Windows system root.
TEMPpathinherited if setPath.Temporary directory.
TERMstringinherited if setTerminal type.Terminal metadata.
TMPpathinherited if setPath.Temporary directory.
TMPDIRpathinherited if setPath.Temporary directory.
USERstringinherited if setUser name.User account.
USERPROFILEpathinherited if setWindows profile path.Windows user profile.

Explicit hook env values override inherited values with the same key.

Bridge Provider Variables

Bridge providers are extension runtimes, not config.toml sections. These environment variables act as process-level defaults or test hooks for provider binaries.

VariableProviderDefaultValid valuesDescription
AGH_BRIDGE_DISCORD_LISTEN_ADDRDiscordprovider config valueHost and port string.Default Discord webhook listener address.
AGH_BRIDGE_DISCORD_API_BASE_URLDiscordDiscord API defaultURL.Discord API base URL override.
AGH_BRIDGE_GITHUB_LISTEN_ADDRGitHubprovider config valueHost and port string.Default GitHub webhook listener address.
AGH_BRIDGE_GITHUB_API_BASE_URLGitHubGitHub API defaultURL.GitHub API base URL override.
AGH_BRIDGE_GCHAT_LISTEN_ADDRGoogle Chatprovider config valueHost and port string.Default Google Chat webhook listener address.
AGH_BRIDGE_GCHAT_API_BASE_URLGoogle ChatGoogle Chat API defaultURL.Google Chat API base URL override.
AGH_BRIDGE_GCHAT_AUTH_URLGoogle ChatGoogle OAuth token URLURL.Google Chat auth endpoint override.
AGH_BRIDGE_GCHAT_DIRECT_CERTS_URLGoogle ChatGoogle direct-message cert URLURL.Direct-message certificate URL override.
AGH_BRIDGE_GCHAT_PUBSUB_CERTS_URLGoogle ChatGoogle Pub/Sub cert URLURL.Pub/Sub certificate URL override.
AGH_BRIDGE_LINEAR_LISTEN_ADDRLinearprovider config valueHost and port string.Default Linear webhook listener address.
AGH_BRIDGE_LINEAR_API_BASE_URLLinearLinear API defaultURL.Linear API base URL override.
AGH_BRIDGE_LINEAR_TOKEN_URLLinearLinear OAuth token URLURL.Linear OAuth token endpoint override.
AGH_BRIDGE_SLACK_LISTEN_ADDRSlackprovider config valueHost and port string.Default Slack webhook listener address.
AGH_BRIDGE_SLACK_API_BASE_URLSlackSlack API defaultURL.Slack API base URL override.
AGH_BRIDGE_TEAMS_LISTEN_ADDRTeamsprovider config valueHost and port string.Default Teams webhook listener address.
AGH_BRIDGE_TEAMS_OPENID_METADATA_URLTeamsMicrosoft OpenID metadata URLURL.Teams OpenID metadata endpoint override.
AGH_BRIDGE_TEAMS_TOKEN_URLTeamsMicrosoft OAuth token URLURL.Teams OAuth token endpoint override.
AGH_BRIDGE_TELEGRAM_LISTEN_ADDRTelegramprovider config valueHost and port string.Default Telegram webhook listener address.
AGH_BRIDGE_TELEGRAM_API_BASE_URLTelegramTelegram API defaultURL.Telegram API base URL override.
AGH_BRIDGE_WHATSAPP_LISTEN_ADDRWhatsAppprovider config valueHost and port string.Default WhatsApp webhook listener address.
AGH_BRIDGE_WHATSAPP_API_BASE_URLWhatsAppWhatsApp API defaultURL.WhatsApp API base URL override.

Bridge adapter harness variables are read by bridge binaries for integration and lifecycle marker paths:

AGH_BRIDGE_ADAPTER_HANDSHAKE_PATH
AGH_BRIDGE_ADAPTER_OWNERSHIP_PATH
AGH_BRIDGE_ADAPTER_STATE_PATH
AGH_BRIDGE_ADAPTER_DELIVERY_PATH
AGH_BRIDGE_ADAPTER_INGEST_PATH
AGH_BRIDGE_ADAPTER_STARTS_PATH
AGH_BRIDGE_ADAPTER_SHUTDOWN_PATH
AGH_BRIDGE_ADAPTER_CRASH_ONCE_PATH

Not Supported As Environment Overrides

These names are common guesses or appear in older task notes, but current AGH code does not read them as runtime configuration variables.

VariableStatusUse instead
AGH_CONFIGNot read.Put global config at $AGH_HOME/config.toml and workspace config at <workspace>/.agh/config.toml.
AGH_LOG_LEVELNot read.Set [log].level in config.toml.
VITE_AGH_API_URLNot read by AGH runtime code.It is listed as a Turbo build cache input, not a daemon config variable.

On this page