Environment variables

Every environment variable agentty reads — what it does, what it defaults to, and when you'd actually reach for it.

Every environment variable agentty reads, grouped by what it affects. Nothing here is required: agentty runs with none of them set. Reach for one when you need to override a default, debug a problem, or script a headless run.

Persistent preferences belong in settings (the config overlay, Ctrl+S) — environment variables are for per-invocation overrides and diagnostics.

✦Debugging something right now?Start with AGENTTY_LOG. In a non-release build everything is already logged to ~/.agentty/logs/agentty.log with no variable set at all.

Diagnostics

One log, one switch. See Logging & diagnostics for the channel list and line format.

VariableEffect
AGENTTY_LOGThe diagnostic filter. trace · debug · info · warn · error · off, plus channel=level overrides (warn,wire=trace). Release builds default to warn (~2 lines per healthy session) so agentty diagnostics works with no setup; non-release builds default to everything.
AGENTTY_LOG_BODIESInclude payloads (wire bodies, tool args) in the log. Off by default — these carry user data.
AGENTTY_TRACE_TOOLSOlder spelling of --events jsonl; =1 selects the same stream. Prefer the flag — it shows up in --help.
AGENTTY_RAG_TRACEFold rag-cpp's per-stage trace into the retrieval mode string shown on the tool card. On by default; =0 disables.
AGENTTY_NO_STDERR_REDIRECTKeep subsystem stderr (MCP servers, sandbox) on the terminal instead of capturing it. Debug-only — it will scribble over the TUI.

Providers & models

VariableEffect
ANTHROPIC_API_KEY · OPENAI_API_KEY · GROQ_API_KEY · OPENROUTER_API_KEY · TOGETHER_API_KEY · CEREBRAS_API_KEY · DEEPSEEK_API_KEY · XAI_API_KEY · MISTRAL_API_KEY · GEMINI_API_KEY / GOOGLE_API_KEY · FIREWORKS_API_KEYPer-provider API keys. Each provider also falls back to OPENAI_API_KEY where its wire is OpenAI-compatible. Keys saved via agentty login take precedence.
CLAUDE_CODE_OAUTH_TOKENUse an existing Claude Code OAuth token instead of signing in.
AGENTTY_API_HOST / AGENTTY_OAUTH_HOSTPoint the Anthropic wire at a different API / OAuth host (gateways, enterprise proxies).
AGENTTY_OLLAMA_HOSTOllama base URL. Default http://localhost:11434.
AGENTTY_OLLAMA_NUM_CTX · AGENTTY_OLLAMA_NUM_PREDICT · AGENTTY_OLLAMA_TEMPERATUREOverride Ollama's context window, output cap, and sampling temperature. Otherwise agentty picks per model.
AGENTTY_MAX_OUTPUT_TOKENSCap max_tokens on every request (mirrors Claude Code's knob). Useful against a provider that rejects large output budgets.
AGENTTY_MAX_SKILLSOverride the tier-1 skill catalog cap (default 64, clamped to 8–4096). Lower it for small-context models, raise it for large skill libraries.
AGENTTY_FORCE_EFFORTForce a reasoning-effort tier for every turn, overriding what the model's capabilities imply. For A/B-ing effort, not everyday use.
AGENTTY_CHATGPT_DEVICE_AUTHUse the device-code flow for ChatGPT sign-in instead of the loopback browser flow — for headless or remote machines.
AGENTTY_NO_PREWARMSkip the TLS/connection prewarm at startup.
AGENTTY_POOL_IDLE_TTLSeconds an idle HTTP/2 connection may be reused (default 90, or 450 under a SOCKS proxy; 0 disables pooling). Lower this if you see h2 socket hangup (server accepted request; not replayed automatically) mid-answer — that means a proxy/VPN/CDN killed the connection before agentty did. Set it below your network's idle timeout and the pool evicts first, turning a visible failure into an invisible re-dial. grep http.stream_hangup in the log shows each hangup's idle age, so the right value is measurable.
AGENTTY_FORCE_REMOTEForce the remote streaming cadence even on a local endpoint. Takes precedence over autodetection.

Smart Mode

Off by default and a byte-for-byte no-op when off — see Smart Mode.

VariableEffect
AGENTTY_SMART_MODESession pin for the master switch: 1 on, 0 off, for this process only. Never persisted (safe for CI).
AGENTTY_SMART_NO_INTERNALKeep engine-internal calls (compaction summary, thread title) on the main model instead of the Utility slot.
AGENTTY_SMART_NO_SUBAGENTS · AGENTTY_SMART_NO_ORCHESTRATEDisable subagent delegation / orchestration independently. For bisecting a routing problem.
AGENTTY_SMART_COMPLEX_THRESHOLD · AGENTTY_SMART_DEEP_MARGIN · AGENTTY_SMART_BIAS_CLAMPRouter tuning: complexity cut-off, deep-work margin, and the clamp on learned bias. Defaults are measured; change them only with a benchmark.
AGENTTY_SMART_ROUTE_MAIN0 stops the main conversation turn from being routed by complexity — every turn runs on the Strategic model and only its effort varies. On by default. Before this existed that was the only behaviour: the flagship served every turn, including ones the classifier had already scored trivial.
AGENTTY_SMART_MAIN_FLOORThe cheapest role the main turn may be routed to: utility (default — the full ladder), implementation (never cheaper than the mid model), or strategic (never route down; equivalent to AGENTTY_SMART_ROUTE_MAIN=0). Raise it if simple turns are being answered too thinly.

Context window

agentty learns a model's context window from three places, most specific first: your override, then what the provider advertised, then what the model id implies. Nothing known falls back to a conservative 200k.

That middle layer is why most setups need no configuration — the /v1/models listing is read for model_info.max_input_tokens (LiteLLM), context_length and top_provider.context_length (OpenRouter), max_model_len (vLLM), and n_ctx (llama.cpp). Where a row advertises both a catalog window and the serving endpoint's, the serving one wins: it is the one that will reject an over-long prompt.

But a gateway is not obliged to say anything — OpenAI's own /v1/models schema is just {id, object, created, owned_by} — so when every layer comes up empty the picker shows auto and the turn runs on the conservative default. For that case:

| Variable | Effect | |---|---| | AGENTTY_MAX_CONTEXT_TOKENS | The window to assume when nothing else knows one. Spelled to mirror Claude Code's CLAUDE_CODE_MAX_CONTEXT_TOKENS, so it is guessable if you have hit this before. |

It is consulted last, after the catalog, the probe and the model id, so it only speaks when nothing better did — it is global, and a session that reaches several models should not apply one number to all of them.

In practice almost nothing needs it: between the /v1/models listing, the endpoint probes and models.dev, discovery covers nearly every provider agentty ships. What is left is the genuinely unknowable case — a private gateway serving an id no catalog has published.

Retrieval (RAG)

Full detail in Retrieval. Most default sensibly; the common ones are AGENTTY_DOCS_DIR and AGENTTY_EMBED_MODEL.

VariableEffect
AGENTTY_DOCS_DIRDirectory to index as your knowledge base.
AGENTTY_EMBED_MODELEmbedding model (via Ollama).
AGENTTY_RAG_PERSISTCache the built index to .agentty/rag_docs.ragdb so later sessions open warm. On by default; =0 disables.
AGENTTY_RAG_LEARNFold each passage's win-rate back into ranking. On by default; =0 disables.
AGENTTY_RAG_PROACTIVE · AGENTTY_RAG_PROACTIVE_MIN · AGENTTY_RAG_PROACTIVE_BYTESPre-turn auto-retrieval and its thresholds. Off by default.
AGENTTY_RAG_EXPAND · AGENTTY_RAG_HYDE · AGENTTY_RAG_GEN_MODELLLM-assisted recall (multi-query, HyDE) via a small local model. Opt-in.
AGENTTY_RAG_BM25_WEIGHT · AGENTTY_RAG_DENSE_WEIGHT · AGENTTY_RAG_FUSION · AGENTTY_RAG_ADAPTIVEHybrid-search weighting and the fusion strategy. _ADAPTIVE (on) picks weights per query.
AGENTTY_RAG_MMR · AGENTTY_RAG_MMR_LAMBDA · AGENTTY_RAG_DEDUP · AGENTTY_RAG_DEDUP_THRESHOLDDiversity and near-duplicate suppression in results. Both on by default.
AGENTTY_RAG_AUTOCUT · AGENTTY_RAG_AUTOCUT_SENSITIVITY · AGENTTY_RAG_RELEVANCE_FLOORDrop weak tail results automatically. On by default.
AGENTTY_RAG_CONTEXTUAL · AGENTTY_RAG_EXTRACTIVE · AGENTTY_RAG_STITCH · AGENTTY_RAG_CORRECT · AGENTTY_RAG_PRF · AGENTTY_RAG_GRAPHIndividual retrieval stages (contextual headers, extractive compression, chunk stitching, correction, pseudo-relevance feedback, graph expansion).
AGENTTY_RAG_MEMORY · AGENTTY_RAG_SKILLS · AGENTTY_RAG_MCPInclude learned memory / skills / MCP resources in the index.
AGENTTY_RAG_OUTPUT_BYTES · AGENTTY_RAG_BUDGET_GAMMA · AGENTTY_RAG_CONF_BUDGET_FLOOROutput size budget and how it scales with confidence.
AGENTTY_RAG_MEASUREEmit retrieval quality metrics — for benchmarking.

Tools, MCP & ACP

VariableEffect
AGENTTY_MCP_CONFIGPath to the MCP server config. Otherwise ~/.agentty then ./.agentty.
AGENTTY_MCP_ALLOW_PROJECTAllow a project-local .agentty/mcp.json to add servers. Off by default — a repo you clone should not silently gain tool servers.
AGENTTY_MCP_TIMEOUT_MS · AGENTTY_MCP_CONNECT_TIMEOUT_MSPer-call and initial-connect timeouts for MCP servers.
AGENTTY_MCP_TOOL_BUDGETSoft cap on total tools on the wire (native + enabled MCP), default 100. Past it, MCP tools are trimmed and the picker warns. 0 disables the cap; unparsable values keep the default.
AGENTTY_MCP_CLIENT_IDOAuth client id for MCP servers that require one.
AGENTTY_SUBAGENT_MAX_SECONDSWall-clock ceiling for one task subagent run, default 900 (15 min). Bounds the case the turn cap cannot: a backend that keeps a stream technically alive without finishing it, where the per-stream budget alone allowed hours. On expiry the subagent stops and reports what it has, flagged incomplete. Values outside 1–86399 keep the default. For agentty run, --timeout overrides it.
AGENTTY_ACP_AGENTSPath to the ACP agent config (same precedence chain as MCP).
AGENTTY_ACP_ALLOW_PROJECTAllow a project-local ACP agent config. Off by default, same reasoning as MCP.
AGENTTY_NO_HOOKSDisable all lifecycle hooks for this run.
AGENTTY_HOOK_EVENT · AGENTTY_HOOK_TOOL · AGENTTY_HOOK_PAYLOAD_FILESet by agentty for your hook, not by you — the event name, tool name, and a file holding the JSON payload. See Hooks.

Security & storage

VariableEffect
AGENTTY_HOMERoot for all agentty state (credentials, threads, settings, logs). Default ~/.agentty. Point it at a scratch dir to sandbox a session.
AGENTTY_THREADS_DIRConversation history. Default <root>/threads. Kept 0700.
AGENTTY_CREDENTIALS_DIRSign-ins and API keys. Default <root>/credentials. Kept 0700.
AGENTTY_STATE_DIRApproval hashes for project MCP servers, hooks and skills. Default <root>/state.
AGENTTY_CACHE_DIRRefetchable data, the model catalog and update stamps. Default <root>/cache. Safe to delete.
AGENTTY_LOGS_DIRDiagnostic logs. Default <root>/logs.
AGENTTY_PROJECT_DIRThe per-project root. Default <project>/.agentty. Each project gets its own subfolder under it.
AGENTTY_RAG_DIRSearch indexes. Default <project root>/cache. Safe to delete, the next search rebuilds.
AGENTTY_PROJECT_STATE_DIRSearch feedback. Default <project root>/state.
AGENTTY_THREADS_KEEP_DAYSDelete threads idle this many days, once a day. Unset keeps everything.
AGENTTY_ENCRYPT_PASSPHRASE / AGENTTY_PASSPHRASEPassphrase for the encrypted credential store — for headless machines where no prompt is possible.
AGENTTY_USE_KEYSTOREUse the OS keychain for credentials instead of the file store.
AGENTTY_KDFKey-derivation parameters for the credential store. Change only if you know why.
AGENTTY_TLS_PINSPin TLS certificates for provider hosts.
AGENTTY_INSECUREDisable TLS verification. For debugging a proxy with a self-signed cert. Never leave it set.
AGENTTY_SOCKS_PROXYRoute provider traffic through a SOCKS proxy. See Proxies.
SSL_CERT_FILE · SSL_CERT_DIR · CURL_CA_BUNDLEStandard OpenSSL root-store overrides.
AGENTTY_AIRGAP_SSHSSH target for airgap mode. See Airgap.
AGENTTY_NO_SSH_THROTTLESkip render throttling over SSH. A fast LAN hop doesn't need it.
AGENTTY_NO_UPDATE_CHECKDisable the background update check (also implied by airgap mode).

Keeping config local and bulk elsewhere

AGENTTY_HOME moves everything. The per-directory variables move one thing each, usually the parts that grow:

export AGENTTY_THREADS_DIR=/mnt/data/agentty/threads
export AGENTTY_LOGS_DIR=/mnt/data/agentty/logs

Use agentty config move threads /mnt/data/agentty/threads to bring existing data along; it prints the export line to add.

See Storage for every file and how long it stays.

Retrieval indexes are per-project

AGENTTY_RAG_DIR is the odd one out, because the data is. Retrieval indexes are keyed to the tree that produced them — they are meaningless away from it, and sharing one between unrelated checkouts would invalidate it constantly — so they default to <project>/.agentty rather than anywhere under AGENTTY_HOME. Only AGENTTY_RAG_DIR and AGENTTY_PROJECT_DIR move them.

They are also the biggest thing agentty writes per project: on the agentty repo itself, 31 MB of code index and 7 MB of docs index. If your code already lives on a roomy disk they follow it and there is nothing to do. If it does not:

export AGENTTY_RAG_DIR=/mnt/data/agentty/rag

With the override set, each project gets its own readable subdirectory (myrepo-04b42962/) so two checkouts pointed at one location do not fight over the same file.

The "project" is the nearest enclosing directory containing .git, .agentty, .hg or .svn — not the directory you launched from. So cd src/ && agentty reuses the index at the repo root instead of building a second one beside it.

Superseded indexes are reclaimed

The filename carries an identity tag for the embedding backend that built it (rag_code.e45ba1de.ragdb), so changing backends can never serve vectors from an incompatible space. The cost is that the filename set grows every time you switch.

After a successful index write, agentty deletes superseded variants — keeping the live one plus the most recent previous one, so A/B-ing two backends does not force a full rebuild each time you switch back. Untagged indexes from before the tag existed are removed outright: no current build can read them.

Two deliberate limits. Variants newer than an hour are left alone, since another agentty process may be mid-write. And if any file in the directory cannot be examined, nothing is deleted at all — being wrong about what is present should cost disk, not data.

Details worth knowing:

  • A relative value is resolved against the root, not your current directory — AGENTTY_LOGS_DIR=logs2 always means ~/.agentty/logs2.
  • An empty value counts as unset, so an exported-but-blank variable relocates nothing.
  • If a directory can't be created (unmounted drive, a file in the way), agentty prints one warning and falls back to the default rather than losing the data silently.
  • An overridden threads directory is forced to 0700, because conversation history is as sensitive as the credentials it used to sit beside.

Symlinking the subdirectories works too, and predates these variables: ln -s /mnt/data/agentty-logs ~/.agentty/logs.

Interface

VariableEffect
AGENTTY_GRIDGrid-protocol rendering for cooperating hosts. =0 opts out. (AGENTTY_EMACS_GRID is the legacy name.)
AGENTTY_HOSTDeclare the cooperating host explicitly rather than autodetecting.
AGENTTY_CLIPBOARD_CMDCommand to pipe clipboard writes through (e.g. pbcopy, wl-copy) when autodetection fails.
AGENTTY_PAINTED_CARET=1 draws the caret manually — for terminals with broken cursor-visibility handling.
AGENTTY_REVEALMaster switch for the streaming reveal effect. On by default everywhere, tmux included; 0/false/off/no turns it off, anything else forces it on. Set it to 0 if your terminal/multiplexer combination ghosts the live tail.
AGENTTY_REVEAL_TYPEWRITERThe typewriter clip alone — text arriving character-by-character. ANDed with AGENTTY_REVEAL; same default and same truthiness rule.
AGENTTY_REVEAL_DECORATEThe decorative overlay on the revealing tail alone. ANDed with AGENTTY_REVEAL; same default and same truthiness rule.
AGENTTY_NO_REVEAL_GLIDE=1 disables the bounded end-of-turn glide (the visible catch-up when a turn finishes) and restores the immediate finish. Not the reveal animation itself — that's AGENTTY_REVEAL. The glide is otherwise on only where frames are dense: not over SSH, and only with synchronized-output support.
AGENTTY_NO_TAPE=1 replaces the animated activity tape with a quiet static row carrying the same elapsed / tok-s detail.
AGENTTY_FROZEN_COLLAPSE=1 opts in to collapsing frozen turns. Off by default.
AGENTTY_NO_TRANSFORMSDisable output transforms.

Development & testing

Not for normal use. Listed so a reader of the source isn't left guessing.

VariableEffect
AGENTTY_STRICT_TEST_ROOT · AGENTTY_TEST_FAKE_PASSWD_HOMETest-harness isolation: enforce a sandboxed user root and fake the passwd home lookup.
AGENTTY_UNDER_TESTSet by the test mains before anything renders: arms the user-root tripwire so a test can never touch the real ~/.agentty.

Variables agentty reads from your environment

Standard variables consulted for platform behaviour, listed for completeness: HOME / USERPROFILE / HOMEDRIVE + HOMEPATH · XDG_CONFIG_HOME · APPDATA · PATH · USER / USERNAME · SUDO_USER · HOSTNAME · COLUMNS / LINES · DISPLAY / WAYLAND_DISPLAY / XDG_SESSION_TYPE · SSH_CONNECTION / SSH_CLIENT / SSH_TTY / SSH_AUTH_SOCK · MOSH_CONNECTION / MOSH_KEY / MOSH_SERVER_PID · INSIDE_EMACS.