Environment Variables
Environment variables override stored configuration values.
Authentication & API
| Variable | Description | Default |
|---|---|---|
PRETORIN_API_KEY | API key for platform access. It is bound to the effective platform URL; set it together with PRETORIN_PLATFORM_API_BASE_URL when switching deployments. | — |
PRETORIN_PLATFORM_API_BASE_URL | Platform REST API base URL | https://platform.pretorin.com/api/v1/public |
PRETORIN_API_BASE_URL | Backward-compatible alias for PRETORIN_PLATFORM_API_BASE_URL | — |
PRETORIN_MODEL_API_BASE_URL | Model API URL for agent runtime | https://platform.pretorin.com/api/v1/public/model |
Context
| Variable | Description | Default |
|---|---|---|
PRETORIN_SYSTEM_ID | Active system ID. Overrides the system set via pretorin context set. | — |
PRETORIN_FRAMEWORK_ID | Active framework ID. Overrides the framework set via pretorin context set. | — |
Agent Runtime
| Variable | Description | Default |
|---|---|---|
PRETORIN_AGENT_HARNESS | Select the shared built-in harness (codex or opencode) for pretorin agent and newly prepared Campaigns. An explicit --agent wins; the saved agent_harness setting is used next when this variable is absent. | codex |
OPENAI_API_KEY | Direct model-provider key. Codex uses it for a custom model URL selected by flag, environment, or saved generalized configuration, or for a non-pretorin provider; it is never substituted for a known Pretorin model proxy. | — |
OPENAI_BASE_URL | OpenCode OpenAI-provider URL (and a legacy-agent URL). New OpenCode Campaigns freeze the effective value, or OpenAI’s canonical default when unset. For the shared Codex route, use --base-url or PRETORIN_MODEL_API_BASE_URL. | https://api.openai.com/v1 for OpenCode |
ANTHROPIC_BASE_URL | OpenCode Anthropic-provider URL. New OpenCode Campaigns freeze the effective value, or Anthropic’s canonical default when unset. | https://api.anthropic.com/v1 for OpenCode |
OPENAI_MODEL | Model name for the agent runtime. | gpt-4o |
CODEX_HOME | Set by Pretorin, not read from your shell. Each pretorin agent run receives a unique owner-only child of ~/.pretorin/codex/sessions/, with an ephemeral generated config.toml and scratch directory. It never reads ~/.codex/config.toml, concurrent runs cannot replace each other’s route, and the child is removed when the session ends. Exporting your own value has no effect. | Per-session directory |
Environment isolation for pretorin agent run
The Codex subprocess does not inherit your full shell environment. Pretorin
builds a bounded environment with its isolated CODEX_HOME, the resolved model
key and URL, PATH, HOME, and the separately resolved endpoint-bound Pretorin
platform key/URL pair.
Those credentials then have separate destinations:
- Codex itself receives the model pair. The configured Pretorin MCP child
receives only the authorized
PRETORIN_API_KEYandPRETORIN_PLATFORM_API_BASE_URLpair by variable name; it never receivesOPENAI_API_KEY. - Model-generated shell commands use a safe name allowlist containing ordinary
runtime variables such as
HOME,PATH, locale, temporary-directory, and certificate paths. Neither model nor platform bearer keys reach shell tools. - Codex native tools run under the generated
pretorin_interactiveprofile: the selected workspace is readable/writable, native networking is disabled, and owner files outside that workspace are not part of the native tool surface. Minimal operating-system runtime paths and scratch remain available. PRETORIN_SYSTEM_ID,PRETORIN_FRAMEWORK_ID, and unrelated exported secrets are not forwarded. The MCP server can still read saved context through the passed-throughHOME.- Environment-only CI authentication is supported. When targeting a deployment
other than the saved one, export both
PRETORIN_API_KEYandPRETORIN_PLATFORM_API_BASE_URL; a URL-only override fails closed instead of combining the new URL with a saved key. HOMEis passed through, so~/.pretorin/config.json, the recipe folders, and~/.pretorin/mcp.jsonall resolve normally.- Extra MCP servers that need their own secrets (for example
GITHUB_TOKEN) must declare them in theenvblock of their owner-only~/.pretorin/mcp.jsonentry; exporting them in your shell is not enough. Never put secrets in the shareable project.pretorin-mcp.json. See Agent Runtime.
The native Codex permission profile does not sandbox Codex startup or MCP server processes. The trusted Pretorin MCP child uses the passed-through home and endpoint-bound platform pair to load the user’s compliance configuration. Additional MCP servers run with their own authority and can broaden access; configure only servers you trust.
OpenCode also receives an isolated home/XDG configuration, an endpoint-bound
Pretorin platform pair, and a model-provider credential allowlist. Interactive
OpenCode denies shell, file-edit, write, web, and delegated-task tools. Its
built-in Pretorin MCP is launched through an environment-clearing helper with
only the endpoint-bound platform pair and the original user home needed to read
saved Pretorin context and user recipes. A configured non-Pretorin local MCP
uses the same helper and receives only ordinary isolated runtime variables plus
the exact env names declared for that server, never OpenCode’s model,
platform, or OAuth credentials implicitly. Campaign children apply the
stricter Campaign worker profile for either harness. Every other pretorin
command runs in your shell and honors the variables below normally.
Source Attestation
| Variable | Description | Default |
|---|---|---|
PRETORIN_SOURCE_PROVIDERS | JSON array of source provider configurations. Overrides source_providers in config file. | — |
PRETORIN_SOURCE_MANIFEST | JSON string or file path to a source manifest. Falls back to .pretorin/source-manifest.json in the git repo root, then ~/.pretorin/source-manifest-{system_id}.json, then the source_manifest config key. | — |
Behavior
| Variable | Description | Default |
|---|---|---|
PRETORIN_DISABLE_UPDATE_CHECK | Set to a truthy value (1, true, yes, on) to disable passive update notifications. Any value set — including a falsy one such as 0 or an empty string — overrides the disable_update_check config key, so exporting 0 re-enables checks that config disabled. | — |
PRETORIN_LOG_LEVEL | Logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL). An unrecognized value falls back to WARNING. | WARNING |
PRETORIN_MCP_TELEMETRY_DISABLED | Set to any non-empty value to suppress the PRETORIN_TELEMETRY_EVENT JSON lines that pretorin mcp-serve emits on stderr for tool-routing observability. | — |
PRETORIN_MCP_MAX_RESULT_BYTES | Byte budget for a single serialized MCP tool result before the response guard compacts it. Raise it for hosts that tolerate larger tool payloads. A malformed or non-positive value falls back to the default. | 40000 |
PRETORIN_MCP_ALLOWED_PROJECT_ROOTS | Optional additional canonical roots accepted by preview_campaign.project_dir and list_campaigns.project_dir. Separate paths with : on POSIX or ; on Windows. Filesystem roots, missing paths, traversal, symlink escape, and out-of-root Git workspaces are rejected. | MCP server startup project root only |
Campaign Runner
These variables apply to local Plan-backed Campaign execution. Native components
are installed and verified with pretorin campaign install; the standard
package and standalone distribution include the supported Python dependencies.
The former campaign-runner extra is a compatibility-only alias.
| Variable | Description | Default |
|---|---|---|
PRETORIN_HATCHET_LOG_LEVEL | Embedded engine and Python SDK logging level. Diagnostics are kept on stderr so --json remains parseable. | warning |
PRETORIN_HATCHET_DATA_DIR | Explicit embedded-Hatchet data root for development and tests; Plan-backed runs append the Campaign Plan ID. Do not set it for normal execution. | <campaigns-dir>/.hatchet/ |
HATCHET_CLIENT_TOKEN | Standard Hatchet SDK token. Pretorin does not set it, but a value exported in your shell switches the Campaign runner off the embedded engine and connects to the external Hatchet deployment that token addresses, which then also reads the rest of the standard HATCHET_* SDK variables. Unset it if you want embedded execution. | — (embedded engine) |
PRETORIN_OPENCODE_COMMAND | Compatibility override for an explicit OpenCode-compatible development/test command. It is resolved before the normal `auto | system |
OPENCODE_MODEL | Provider/model selection for OpenCode. It is optional for an interactive agent run, which can use OpenCode’s configured default, but Campaign preparation requires a concrete model from this variable, saved harness settings, or campaign start --model. | — |
PRETORIN_MOCK_FAILURE_MODE | Mock runner injection mode: none, transient, or permanent. Transient mode fails every seventh item on its first attempt. | transient |
PRETORIN_MOCK_AGENT_MIN_SECONDS | Lower mock item delay bound. | 0.5 |
PRETORIN_MOCK_AGENT_MAX_SECONDS | Upper mock item delay bound. | 1.5 |
There is no global reasoning-effort environment override. Save a per-harness
low, medium, or high value with pretorin agent configure --reasoning-effort, or pass the same option to agent run or campaign start.
If unset, the provider/harness default is retained.
Pretorin sets PRETORIN_PLANS_DIR, PRETORIN_CAMPAIGNS_DIR, and
PRETORIN_PREFLIGHT_DIR internally for the assigned MCP child. It also sets
PRETORIN_PREFLIGHT_READ_ONLY=1 for prepared work. The first two
identify the canonical local stores selected by the supervisor. The third
points at a session-local copy of the one pre-work artifact containing only the
assigned system/framework’s verified bindings and exact recipe activation pins.
The read-only flag prevents MCP tools and direct CLI commands in that child from
refreshing or replacing it. These are runtime plumbing, not operator
configuration; do not set them manually.
Normal local state lives under ~/.pretorin/: Plans in plans/, Campaign
records in campaigns/, canonical preflight state in preflight/, managed
Codex in bin/, managed OpenCode in runtimes/opencode/, and managed Hatchet
in runtimes/hatchet/.
Embedded Hatchet’s per-Campaign database defaults to
campaigns/.hatchet/<campaign-plan-id>/. Detached supervisors discard raw
stdout and stderr, while Codex/OpenCode attempt directories under
runtimes/<harness>/attempts/ are removed when each attempt exits. These paths
contain operational state and bounded receipts, not canonical platform artifact
bodies.
PRETORIN_MCP_PROFILE=campaign-worker is set internally for an agent item’s
MCP child process. It is a least-privilege tool-surface profile, not an operator
configuration or a process sandbox.
Pretorin also sets the internal assignment and per-attempt harness home/config variables. Do not set them yourself. They are named here so you can recognize them when inspecting a child process, not so you can configure them:
PRETORIN_CAMPAIGN_ASSIGNMENTcarries the serialized item assignment to the harness process and its MCP child.PRETORIN_MCP_SOURCE_ENV_KEYSnames, by variable name only, which evidence-source variables the MCP child is authorized to keep; anything not listed is dropped at that boundary.CODEX_HOME(Codex) andOPENCODE_CONFIG_CONTENTplusXDG_CONFIG_HOME/XDG_DATA_HOME/XDG_CACHE_HOME(OpenCode) point each attempt at its own ephemeral configuration tree instead of your real~/.codexor~/.config/opencode.
Each attempt receives a distinct ephemeral
configuration tree and only an explicit environment allowlist. When OpenCode
OAuth is configured, Pretorin uses OpenCode’s environment-only
OPENCODE_AUTH_CONTENT mechanism; it never copies the token file into the
attempt directory or serializes credentials into config, Plans, Campaign state,
or observer events.
Campaign evidence-source credentials
Model-provider credentials, the Pretorin platform API key, and evidence-source credentials are separate trust domains. A Campaign resolves source values fresh for each exact system/framework attempt. Its trusted harness process temporarily carries the allowlisted values so the assigned Pretorin MCP child can inherit them; the worker tool profile has no shell or general environment-inspection surface. The MCP child retains source variables only when the authoritative preflight artifact authorizes that source. Values are never frozen into an assignment or persisted in harness configuration, Plans, Campaign records, or observer events.
For AWS, the current source allowlist is:
- direct/session credentials:
AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY, andAWS_SESSION_TOKEN; - profiles and regions:
AWS_PROFILE,AWS_DEFAULT_PROFILE,AWS_REGION, andAWS_DEFAULT_REGION; - role/web identity:
AWS_ROLE_ARN,AWS_ROLE_SESSION_NAME, andAWS_WEB_IDENTITY_TOKEN_FILE; and - credential files:
AWS_CONFIG_FILEandAWS_SHARED_CREDENTIALS_FILE.
AWS values are admitted only for a legacy aws_account preflight source or a
normalized cloud_control_plane resolver whose provider is AWS. If the two
explicit file variables are absent but the invoking HOME contains
~/.aws/config or ~/.aws/credentials, Pretorin converts the existing files to
explicit absolute paths before replacing HOME with the attempt’s isolated
directory. An AWS credential used by a model provider remains independently
subject to the model-provider allowlist; source authorization does not broaden
model access, or vice versa.
Campaign execution uses embedded Hatchet v0.105.16 with Hatchet SDK 1.39.0.
Remote and multi-host execution are intentionally unsupported until Plans have a
shared persistence contract. The embedded engine and Campaign state live under
Pretorin-owned local state and can resume on the same host.
Self-Update
pretorin update runs its installer and verification steps in a subprocess whose
environment is derived from your shell, with these adjustments. Except for
PRETORIN_UPDATE_BASE_URL, you do not set any of these yourself — the rest
document what the command does to the environment it passes down.
| Variable | Description | Default |
|---|---|---|
PRETORIN_UPDATE_BASE_URL | Maintainer-only; unsupported for normal use. Redirects the signed self-updater (standalone Linux x86_64 binaries) at a different release host, so the release pipeline and its acceptance runs can be tested against a local fixture instead of the public tap. It relaxes exactly one rule — http is allowed — and tightens another: redirects may not leave the override’s host and port. It does not and cannot defeat verification: the release-signing key is embedded in the binary at build time, so a release served from any base URL is still rejected unless it carries a valid signature from that key. | the public tap |
UV_TOOL_DIR / UV_TOOL_BIN_DIR | Set by Pretorin. When the running CLI is a uv tool install (the venv contains uv-receipt.toml), both are pinned to the directories of that install so the upgrade cannot retarget a different uv tool root. | — |
PIPX_HOME / PIPX_BIN_DIR | Set by Pretorin. Same scoping for a pipx install (the venv contains pipx_metadata.json). | — |
PYTHONPATH / PYTHONHOME | Removed by Pretorin from the update subprocess. Any value you export is dropped so local files such as pip.py or pretorin.py cannot shadow the real packages during self-update. | — |
If neither installer layout is detected, the subprocess inherits your environment
unchanged apart from the PYTHONPATH / PYTHONHOME removal.
Cloud Scanner Recipes
These are standard cloud-provider SDK environment variables. Pretorin’s bundled asset-inventory and cloud-baseline recipes honor them when scanning AWS/Azure.
| Variable | Description | Default |
|---|---|---|
AWS_REGION | Single AWS region to scan for the asset-inventory-aws-baseline recipe. When unset, the recipe enumerates all regions the account has opted into and scans them concurrently. AWS_DEFAULT_REGION is honored as a fallback. Also declared by the cloud-aws-baseline recipe, where it supplies the region the aws CLI uses unless the recipe’s region parameter is passed. | — |
AWS_DEFAULT_REGION | Fallback region used by the asset-inventory-aws-baseline recipe when AWS_REGION is unset. Standard boto3 variable. | — |
AZURE_SUBSCRIPTION_ID | Subscription ID used by the asset-inventory-azure-baseline recipe. When unset, the recipe falls back to the default subscription from az account show. | — |
Recipe Authoring
| Variable | Description | Default |
|---|---|---|
USER | Fallback author name written into the frontmatter of recipes scaffolded with pretorin recipe new. Used only when git config user.name is unavailable. | unknown |
Precedence
For the platform API credential:
- A nonblank
PRETORIN_API_KEYis paired with the effective platform URL. - Otherwise,
api_keyin~/.pretorin/config.jsonremains paired with its saved platform URL.
If an environment platform URL differs from the saved URL but no environment key is supplied, Pretorin does not reuse the saved key for that deployment.
For the platform API URL:
PRETORIN_PLATFORM_API_BASE_URLenvironment variable (highest)PRETORIN_API_BASE_URLenvironment variable (legacy alias)platform_api_base_urlin~/.pretorin/config.jsonapi_base_urlin~/.pretorin/config.json(legacy)https://platform.pretorin.com/api/v1/publicdefault
For the model API URL used by Codex:
PRETORIN_MODEL_API_BASE_URLenvironment variable (highest)model_api_base_urlin~/.pretorin/config.json- The saved legacy
harness_base_urlorcodex_base_url, in that order - The
/modelendpoint derived from the effective platform API URL above
For the Codex model key, eligibility is endpoint-bound rather than global:
- A platform key paired with the platform URL whose derived
/modelendpoint exactly matches the selected model URL. - For a custom model URL selected by
--base-url,PRETORIN_MODEL_API_BASE_URL, or savedmodel_api_base_urlconfiguration, or a non-pretorinprovider,OPENAI_API_KEY, then savedopenai_api_key.
A direct model key is rejected for every URL on a known Pretorin platform origin, and a platform key is never sent to an unrelated model URL.
For the model name:
OPENAI_MODELenvironment variable (highest)openai_modelin~/.pretorin/config.json- Org AI settings from the platform (cached)
gpt-4odefault
OpenCode uses its own provider configuration rather than Pretorin’s Codex model
route. Select a concrete OpenCode-native provider/model for Campaigns. The
isolated OpenCode configuration does not define a provider named pretorin, so
that coordinate fails with configuration guidance instead of being mistaken
for a platform-key-backed model.
For the source manifest:
PRETORIN_SOURCE_MANIFESTenvironment variable (highest) — JSON string or file path.pretorin/source-manifest.jsonin the git repo root~/.pretorin/source-manifest-{system_id}.jsonsource_manifestkey in~/.pretorin/config.json
CI/CD Example
export PRETORIN_API_KEY=pretorin_your_key_here
export PRETORIN_DISABLE_UPDATE_CHECK=1
export PRETORIN_SYSTEM_ID=your_system_id
pretorin frameworks list
pretorin evidence push
These variables cover the CLI and pretorin mcp-serve. They do not carry into
pretorin agent run, which runs its subprocess in an isolated environment — see
Environment isolation for pretorin agent run.