Skill Tracer
Skills › Scientific Agent Skills › pi-agent › environment-variables.md

environment-variables.md

62 lines · skills/pi-agent/references/environment-variables.md at 5f2bc03

Open on GitHub
1# Environment Variables
2
3Source: https://pi.dev/docs/latest/environment-variables
4
5Reviewed against Pi 0.99.2 and the package versions listed in `../SKILL.md` on 2026-09-30.
6
7Pi uses environment variables three ways: variables that configure the Pi process, markers Pi sets so child processes know they run inside Pi, and session metadata injected into commands run by the LLM-callable bash and native Windows PowerShell tools. Provider API-key variables live in `references/providers.md`.
8

Environment Variables

Source: https://pi.dev/docs/latest/environment-variables

Reviewed against Pi 0.99.2 and the package versions listed in ../SKILL.md on 2026-09-30.

Pi uses environment variables three ways: variables that configure the Pi process, markers Pi sets so child processes know they run inside Pi, and session metadata injected into commands run by the LLM-callable bash and native Windows PowerShell tools. Provider API-key variables live in references/providers.md.

Raw lines 1 to 8
9## Process Markers
11The CLI and RPC entry points set two markers:
13- `AI_AGENT=pi` — generic marker letting tooling identify Pi as the launching agent.
14- `PI_CODING_AGENT=true` — Pi-specific marker for detecting that a process runs inside Pi.
16Child processes inherit both. Neither is session-specific, and neither is set automatically when Pi is embedded through the SDK.

Process Markers

The CLI and RPC entry points set two markers:

  • AI_AGENT=pi — generic marker letting tooling identify Pi as the launching agent.
  • PI_CODING_AGENT=true — Pi-specific marker for detecting that a process runs inside Pi.

Child processes inherit both. Neither is session-specific, and neither is set automatically when Pi is embedded through the SDK.

Raw lines 9 to 17
18## Bash Tool Session Environment
20Commands run by the LLM-callable bash and native Windows PowerShell tools receive:
22| Variable | Description |
23|---|---|
24| `PI_SESSION_ID` | Current session ID |
25| `PI_SESSION_FILE` | Absolute path to the session JSONL file; unset for ephemeral sessions |
26| `PI_PROVIDER` | Currently selected model provider |
27| `PI_MODEL` | Currently selected model ID |
28| `PI_REASONING_LEVEL` | Effective reasoning level: `off`, `minimal`, `low`, `medium`, `high`, `xhigh`, `max` |
30Values resolve when each command starts, so switching models affects the next bash command without restarting. `PI_PROVIDER`/`PI_MODEL` identify the selected Pi model, not an upstream model a router picks internally. When asked which model is running, inspect these variables instead of inferring from the system prompt:
32```bash
33printf '%s/%s\n' "$PI_PROVIDER" "$PI_MODEL"
34```
36These are injected into the LLM-callable bash and native Windows PowerShell tools only — not into user-entered `!` or `!!` commands.
38Custom shell tools built with `createBashTool()` or `createPowerShellTool()` expose the same variables by default, injected **before** `spawnHook` so hooks see them in `ctx.env`. Disable with `exposeSessionEnvironment: false`; Pi then also clears inherited values so nested Pi processes do not leak stale parent-session metadata.

Bash Tool Session Environment

Commands run by the LLM-callable bash and native Windows PowerShell tools receive:

VariableDescription
PI_SESSION_IDCurrent session ID
PI_SESSION_FILEAbsolute path to the session JSONL file; unset for ephemeral sessions
PI_PROVIDERCurrently selected model provider
PI_MODELCurrently selected model ID
PI_REASONING_LEVELEffective reasoning level: off, minimal, low, medium, high, xhigh, max

Values resolve when each command starts, so switching models affects the next bash command without restarting. PI_PROVIDER/PI_MODEL identify the selected Pi model, not an upstream model a router picks internally. When asked which model is running, inspect these variables instead of inferring from the system prompt:

printf '%s/%s\n' "$PI_PROVIDER" "$PI_MODEL"

These are injected into the LLM-callable bash and native Windows PowerShell tools only — not into user-entered ! or !! commands.

Custom shell tools built with createBashTool() or createPowerShellTool() expose the same variables by default, injected before spawnHook so hooks see them in ctx.env. Disable with exposeSessionEnvironment: false; Pi then also clears inherited values so nested Pi processes do not leak stale parent-session metadata.

Raw lines 18 to 39
40## Pi Process Configuration
42| Variable | Description |
43|---|---|
44| `PI_CODING_AGENT_DIR` | Override the config directory; default `~/.pi/agent` |
45| `PI_CODING_AGENT_SESSION_DIR` | Override session storage; overridden by `--session-dir` |
46| `PI_PACKAGE_DIR` | Override the package directory (useful for Nix/Guix store paths) |
47| `PI_OFFLINE` | Disable startup network operations: update checks, package updates, install/update telemetry |
48| `PI_SKIP_VERSION_CHECK` | Disable the `pi.dev` latest-version request |
49| `PI_TELEMETRY` | Override install/update telemetry and provider attribution headers: `1`/`true`/`yes` or `0`/`false`/`no` |
50| `PI_CACHE_RETENTION` | Set to `long` for extended provider prompt caching where supported |
51| `PI_SHARE_VIEWER_URL` | Override the base URL used by `/share` |
52| `PI_RADIUS_GATEWAY` | Override Radius relay and bug-report gateway origin |
53| `PI_HYPERLINKS`, `PI_TRUE_COLOR` | Capability override: `1`, `0`, or `auto` |
54| `PI_IMAGE_PROTOCOL` | `kitty`, `iterm2`, `none`, or `auto` |
55| `PI_HARDWARE_CURSOR` | Set to `1` to show the hardware cursor (IME positioning) |
56| `PI_TUI_ESC_TIMEOUT` | Milliseconds to wait after a lone ESC before treating it as Escape; defaults to `100` over SSH and `10` otherwise. Increase when Alt-key input is misread as Escape |
57| `VISUAL`, `EDITOR` | External editor fallback when the `externalEditor` setting is unset |
58| `HTTP_PROXY`, `HTTPS_PROXY` | Proxy outbound HTTP requests |
60Names are derived from the rebrandable app name (`package.json` `piConfig.name`), so a fork uses a different prefix — see `references/development.md`.
62Other variables documented elsewhere: `PI_EXPERIMENTAL` (experimental first-time setup, `references/settings.md`), `PI_TUI_WRITE_LOG` (raw ANSI capture, `references/tui.md`), `AWS_BEDROCK_FORCE_CACHE` and other cloud variables (`references/providers.md`), `LLAMA_BASE_URL`/`LLAMA_API_KEY` (`references/llama-cpp.md`).

Pi Process Configuration

VariableDescription
PI_CODING_AGENT_DIROverride the config directory; default ~/.pi/agent
PI_CODING_AGENT_SESSION_DIROverride session storage; overridden by --session-dir
PI_PACKAGE_DIROverride the package directory (useful for Nix/Guix store paths)
PI_OFFLINEDisable startup network operations: update checks, package updates, install/update telemetry
PI_SKIP_VERSION_CHECKDisable the pi.dev latest-version request
PI_TELEMETRYOverride install/update telemetry and provider attribution headers: 1/true/yes or 0/false/no
PI_CACHE_RETENTIONSet to long for extended provider prompt caching where supported
PI_SHARE_VIEWER_URLOverride the base URL used by /share
PI_RADIUS_GATEWAYOverride Radius relay and bug-report gateway origin
PI_HYPERLINKS, PI_TRUE_COLORCapability override: 1, 0, or auto
PI_IMAGE_PROTOCOLkitty, iterm2, none, or auto
PI_HARDWARE_CURSORSet to 1 to show the hardware cursor (IME positioning)
PI_TUI_ESC_TIMEOUTMilliseconds to wait after a lone ESC before treating it as Escape; defaults to 100 over SSH and 10 otherwise. Increase when Alt-key input is misread as Escape
VISUAL, EDITORExternal editor fallback when the externalEditor setting is unset
HTTP_PROXY, HTTPS_PROXYProxy outbound HTTP requests

Names are derived from the rebrandable app name (package.json piConfig.name), so a fork uses a different prefix — see references/development.md.

Other variables documented elsewhere: PI_EXPERIMENTAL (experimental first-time setup, references/settings.md), PI_TUI_WRITE_LOG (raw ANSI capture, references/tui.md), AWS_BEDROCK_FORCE_CACHE and other cloud variables (references/providers.md), LLAMA_BASE_URL/LLAMA_API_KEY (references/llama-cpp.md).

Raw lines 40 to 62