Skip to content

Configuration ​

Lucy is configured entirely through environment variables. This page lists every variable in the four example env files, plus the optional LUCY_* and AM_* flags the code reads.

How configuration is loaded ​

ecosystem.config.cjs reads four files, merges them in this order, and passes the result to every PM2 process:

OrderFileTypical contentsTemplate
1.env.llmLLM provider keys, Jina, MCP credentials.env.llm.example
2agent-machine/.envCoordinator/worker token, budgets, concurrencyagent-machine/.env.example
3bridge/.envTelegram token, allowed user, persona, Claude CLI pathbridge/.env.example
4.env.runtimeHub password, vault and state paths, feature flags.env.runtime.example

Rules worth knowing:

  • A later file wins, even with an empty value. AM_TOKEN= in bridge/.env blanks the token set in agent-machine/.env. Set shared variables (AM_TOKEN, LUCY_SESSION_SUMMARY) to the same value everywhere, or delete the empty line.
  • Shell variables are ignored. Processes run with filter_env: true, so export FOO=1 before pm2 start has no effect.
  • Some processes have fixed overrides in ecosystem.config.cjs: the worker gets AM_RUNNER=claude, the autopilot AM_AUTOPILOT_MAX=50, pxpipe HOST, PORT and PXPIPE_MODELS, the bridge PYTHONUNBUFFERED=1.
  • A few components also read files directly. The agent machine re-reads ~/lucy/.env.llm (or LLM_ENV_FILE) and lets it override existing values. The bridge reads bridge/.env and the hub reads hub/server/.env, but those only fill in variables that are not already set.
  • PM2 only reads env at start. After editing a file, recreate the process: pm2 delete <name> && pm2 start ecosystem.config.cjs --only <name>. See Operations.

Boolean flags accept 1/true/on and 0/false/off. Note the defaults: some flags are on unless you turn them off, others are off unless you turn them on.

Required variables are marked ✅.

.env.llm — providers, memory, MCP ​

Cheap model lanes ​

Keys for OpenAI-compatible providers used by the cheap lanes, persona lanes and the router. All optional: a lane is only offered when its key is present.

VariableDefaultWhat it does
OPENROUTER_API_KEY—OpenRouter key.
GROQ_API_KEY—Groq key.
GEMINI_API_KEY—Google Gemini key (OpenAI-compatible endpoint).
GEMINI_API_KEY_2—Extra key for the same provider. Any provider key can have _2 … _8 variants, and each may hold comma-separated keys; they form a rotation pool.
CEREBRAS_API_KEY—Cerebras key.
MISTRAL_API_KEY—Mistral key.
ZAI_API_KEY—Z.ai key.
NOUS_API_KEY—Nous Portal key.
OPENCODE_ZEN_API_KEY—OpenCode Zen key.

Vector memory (Jina) ​

VariableDefaultWhat it does
JINA_API_KEY—Enables vector search over the vault (hybrid with full-text search) and, with LUCY_RERANK=1, reranking. Without it recall is full-text only.
JINA_EMBED_MODELjina-embeddings-v5-omni-nanoEmbedding model.
JINA_EMBED_DIM768Embedding dimension. Changing it requires a full reindex.
JINA_RERANK_MODELjina-reranker-v2-base-multilingualReranker model (not in the example file).

MCP servers for agents ​

These control the MCP servers mounted for agent runs (the worker). Chat uses Claude Code's native tools instead; see LUCY_CHAT_MCP below.

VariableDefaultWhat it does
LUCY_MCPoffMaster switch. Nothing is mounted unless this is on.
LUCY_MCP_<ID>dependsPer-server switch. Servers marked live default to on: FS, WEB, GIT, MEMORY, GOOGLE, BINANCE, COINGECKO. Servers marked scaffold default to off: GITHUB, NOTION, TWELVEDATA, REGISTRY. A server that needs credentials stays off until they are present.
LUCY_MCP_GITHUBoffGitHub MCP server (via npx @modelcontextprotocol/server-github), code personas only. Needs GITHUB_TOKEN.
GITHUB_TOKEN—GitHub personal access token for the GitHub MCP server.
LUCY_MCP_TWELVEDATAoffTwelve Data MCP (stocks, forex, gold), finance personas only. Needs TWELVEDATA_API_KEY.
TWELVEDATA_API_KEY—Twelve Data API key.
LUCY_MCP_GOOGLEonRead-only Google tools (Gmail search/read, Calendar, Drive search, YouTube). Needs GOOGLE_REFRESH_TOKEN and an OAuth client file.
GOOGLE_REFRESH_TOKEN—OAuth refresh token for the Google tools.
GOOGLE_ACCESS_TOKEN—Optional initial access token; it is refreshed automatically.

Not in the example file but read by the code:

VariableDefaultWhat it does
GCP_OAUTH_FILE~/lucy/.gcp-oauth.jsonGoogle OAuth client file (desktop client JSON).
NOTION_TOKEN—Notion internal integration token; enable with LUCY_MCP_NOTION=on.
TWELVEDATA_MCP_URLhttps://mcp.twelvedata.com/mcpTwelve Data MCP endpoint.
COINGECKO_MCP_URLhttps://mcp.api.coingecko.com/sseCoinGecko MCP endpoint (keyless).
BINANCE_REST_URLhttps://api.binance.comBinance public REST host (keyless).
LLM_ENV_FILE~/lucy/.env.llmWhere the agent machine looks for this file.

agent-machine/.env — coordinator, worker, budgets ​

VariableDefault (code)ExampleWhat it does
AM_TOKEN ✅——Shared secret. Every coordinator endpoint except /health requires it in the x-worker-token header; the worker, autopilot, hub and bridge send it. If empty, the coordinator runs without auth.
AM_PORT87808780Coordinator port.
AM_DATAagent-machine/.data/root/.agent-machineBoard state and token ledger.
AM_CAP_USD209999Spend cap per budget window.
AM_WEEKLY_CAP_USD1209999Weekly spend cap.
AM_PER_CARD_USD29999Spend limit per card (tripled for cards marked thorough).
AM_CARD_HARD_USD89999Per-card ceiling the autopilot respects when deciding whether a card may continue.
AM_MAX_LANES31Maximum cards in progress at the same time.
AM_WORKER_CONCURRENCY11Jobs run in parallel by one worker.
AM_LEASE_MS1200000 (20 min)3000000How long a worker holds a job before it is considered abandoned and requeued.
LUCY_SESSION_SUMMARYoff1Session summaries: when a chat session closes (/new or rotation), the bridge writes a compact summary note to Brain/episodes/. Must be on in both the bridge and the coordinator.

The example disables the budgets

The example sets the dollar caps to 9999, effectively turning them off and relying on the daily token guard instead. Lower them if you pay per token.

Other agent-machine variables:

VariableDefaultWhat it does
AM_HOST127.0.0.1Coordinator bind address. Keep it local.
AM_CONFIGagent-machine/configPersonas, pipelines and model catalog.
AM_WINDOW_MS5 hLength of the budget window for AM_CAP_USD.
AM_SOFT_USD14Soft spend warning within a window.
AM_MAX_STAGE_VISITS3How many times a card may revisit a stage (rework loops) before asking you.
AM_TICK_MS800Coordinator scheduling tick.
AM_DAY_TOKEN_SOFT800000000Daily token soft limit: executors drop to the cheapest lane and you are notified.
AM_DAY_TOKEN_HARD1500000000Daily token hard limit: no new cards; the bridge falls back to cheap lanes.
AM_RUNNERmockWorker mode. claude = Claude plus cheap lanes per persona (set by the ecosystem), lane = cheap lanes only, mock = no tokens, plumbing test.
AM_POLL_MS800Worker poll interval.
AM_AUTOPILOT_MAX100 (ecosystem: 50)Maximum autopilot decisions per process run.
AM_AUTOPILOT_POLL_MS6000Autopilot poll interval.
AM_DIRECTOR_MODELopusModel the autopilot and triage use to decide.
AM_SALVAGE_MODELsonnetModel that infers the outcome of a stage whose agent forgot to return the expected JSON result.
AM_RATELIMIT_PARK_MS5 minHow long a rate-limited lane is parked when the provider gives no Retry-After.
AM_TURNS_LOG—Directory for per-turn JSONL logs. Unset = no turn log. Also feeds npm run stats:errors.
AM_SERVE_HOST, AM_SERVE_PORT, AM_SERVE_DIR127.0.0.1, 8090, .Settings for the noteflow-view static server.

bridge/.env — Telegram bridge ​

VariableDefaultWhat it does
TELEGRAM_BOT_TOKEN ✅—Bot token from @BotFather. The bridge will not start without it. The hub and the dream cron also use it to push messages.
LUCY_ALLOWED_USER_ID ✅—Your numeric Telegram user ID. If empty, the bridge refuses to start (unless LUCY_ALLOW_ANYONE=1). Also the default target for notifications.
LUCY_ALLOW_ANYONE—⚠️ Dangerous opt-in. Set to 1 to let the bridge start with an empty LUCY_ALLOWED_USER_ID; the bot then answers everyone, with full shell access. Leave unset.
CLAUDE_BINclaudePath to the Claude Code CLI. Use the absolute path (which claude), because PM2 does not pass your shell PATH.
LUCY_WORKDIR~/lucy-workspaceWorking directory for chat sessions; downloaded photos and documents land here.
LUCY_PERSONA~/lucy/bridge/persona.mdPersona appended to Claude's system prompt.
LUCY_CLAUDE_TIMEOUT900Seconds before a Claude turn is abandoned. Also used by the hub.
RADIANT_BOT_API_URL, RADIANT_BOT_AGENT_SECRET—Optional integration with an external Discord bot service (the hub's "Aki" tab). Leave empty.
LUCY_BRIEF_DISCORD_CHANNEL, LUCY_TECH_DISCORD_CHANNEL, LUCY_TECH_DISCORD_THREAD—Not read by the code in this repository. Leave empty.
LUCY_TG_PROXY—Proxy for Telegram API calls only, for networks that block Telegram (for example socks5h://127.0.0.1:40000). SOCKS needs pip install requests[socks].
LUCY_SESSION_SUMMARYoffSee the agent-machine table.
ANTHROPIC_BASE_URL—Example: http://127.0.0.1:47821 (pxpipe). Because the env is shared, this sends the worker, autopilot and hub through pxpipe. Bridge chat always removes it and goes direct. Delete it if you don't run pxpipe.
AM_TOKEN ✅—Same value as in agent-machine/.env. Without it, recall and token reporting get 401.

Bridge behaviour flags ​

All optional. Change them in bridge/.env (or .env.runtime) and recreate lucy-bridge.

VariableDefaultWhat it does
LUCY_BRIDGE_ENGINEpersistpersist = one live Claude SDK client per chat (fastest). sdk = one-shot SDK call per message with session resume. spawn = run claude -p per message. Use these as rollback steps.
LUCY_CHAT_MCPoffLoad Claude Code's global MCP servers in chat. Off by default, because loading them adds seconds to every reply.
LUCY_SDK_IDLE_S1800Close an idle persistent client after this many seconds to save RAM.
LUCY_ROTATE_CTX_PCT70Rotate to a fresh session when context usage reaches this percentage (0 = off).
LUCY_ROTATE_TURNS120Rotate after this many turns regardless.
LUCY_ROTATE_CHECK_EVERY5Check context usage every N turns.
LUCY_RECENT_MAX6Recent messages kept in RAM to carry the thread across a rotation.
LUCY_STICKY_MAX6Corrections and "remember this" messages that always survive rotation.
LUCY_REPLY_KEEP900Characters of Lucy's last reply carried across a rotation.
LUCY_POLL_WATCHDOG_S240If no successful Telegram poll for this long, the bridge exits so PM2 restarts it (0 = off).
LUCY_TOKEN_REPORTonReport chat token usage to the shared token guard.
LUCY_TOOL_POLICYonAdd a one-line hint per turn about whether tools are expected (stops Lucy running tools when you just want an opinion).
LUCY_WRITE_GATEonWarn Lucy not to store hypotheticals, examples or other people's statements as durable memory.
LUCY_MEM_AUTHORITY, LUCY_GATE_ORDER, LUCY_CARRY_REPLYonRollback switches for context-handling behaviours (memory as evidence not command, gate ordering, carrying the last reply across rotation).
LUCY_BUDGET_PERSONA24000Character cap for persona plus overlay in the system prompt.
LUCY_BUDGET_SEED4000Character cap for the previous-session summary seeded into a new session.
LUCY_AUTO_COMPRESSoffLegacy auto-rollover for the spawn path (summarise and restart after LUCY_COMPRESS_TURN_MAX turns or a token threshold).
LUCY_COMPRESS_TURN_MAX, LUCY_COMPRESS_TOKEN_MAX, LUCY_COMPRESS_HEADROOM40, 0 (auto), 25000Thresholds for LUCY_AUTO_COMPRESS.
LUCY_FLUSH_BEFORE_COMPRESSoffBefore dropping an old session, give Claude one turn to save durable memory.
LUCY_CLAUDE_HIST_MAX, LUCY_LANE_HIST_MAX80, 60Messages kept in the local transcript buffers.
LUCY_PERSONA_DIR~/lucy/agent-machine/config/personasPersona overlays offered by /persona.
LUCY_CATALOG_FILE~/lucy/agent-machine/config/model-catalog.jsonModel catalog used when the coordinator is offline.
LUCY_MODEL_CATALOG~/lucy/.state/model-catalog.jsonOptional note on current model IDs appended to the persona.
LUCY_STATUS_FILE~/.lucy-bridge-status.jsonStatus file read by bridge/tg_diag.py.
LUCY_TG_TOKENS_FILE, LUCY_CLAUDE_HIST_FILE~/.lucy-bridge-tokens.json, ~/.lucy-claude-history.jsonLocal state files.

.env.runtime — shared runtime ​

VariableDefault (code)ExampleWhat it does
LUCY_HUB_PASSWORD ✅——Hub login password. With no password, every login is refused.
LUCY_HUB_HOST0.0.0.0127.0.0.1Hub bind address. Keep 127.0.0.1 behind nginx.
LUCY_HUB_PORT88008800Hub port.
LUCY_VAULT ✅~/lucy/lucy-vault/root/lucy/lucy-vaultThe memory vault. If the coordinator can't find it, all memory features are off.
LUCY_STATE~/.lucy-hub/root/.lucy-hubHub state: 2FA secret, schedules, event log, chat history.
LUCY_PROJECTS_ROOTLUCY_WORKDIR/root/lucyRoot of the hub's file-tree tab; integrations.json is read from here.
AM_COORD_URLhttp://127.0.0.1:8780sameWhere the bridge, worker, autopilot and hub reach the coordinator.
AM_TURNS_LOG—/root/lucy/agent-machine/.turnsSee above.
LUCY_TZ_OFFSET77Your timezone as hours from UTC. Used for hub schedules and the daily counters.
LUCY_PERSONA_CHAToff1Enable multi-turn chat with expert personas over cheap lanes (hub "Experts").
LUCY_PROMPT_ARCHITECToff1Enable the Prompt Architect (/prompt in Telegram, hub tab).
LUCY_SKILL_LEARNoff1Let Lucy propose new skills from repeated work (drafts go to skills/_proposed/).
CLAUDE_EFFORT—highNot read by Lucy's own code; passed through to child processes.
IS_SANDBOX—1Tells Claude Code it runs in a sandbox, so bypassPermissions is allowed when running as root. Lucy also sets it for every Claude child process.

Not in the example but useful here:

VariableDefaultWhat it does
ANTHROPIC_API_KEY—Use an API key instead of a logged-in Claude Code subscription.
LUCY_PUSH_CHAT_IDLUCY_ALLOWED_USER_IDTelegram chat that receives hub schedule results.
LUCY_INTEGRATIONS_FILE<LUCY_PROJECTS_ROOT>/integrations.jsonIntegration nodes shown on the hub dashboard.
LUCY_REPO~/lucyRepository root, used by the hub's build-status panels.
LUCY_STATE_DIR~/.lucyProvider quota and rate-limit state.
LUCY_SKILLS<repo>/skillsSkill library location.

Memory and recall ​

These can go in .env.runtime. They affect the coordinator (indexing, search) and the bridge and hub (what is injected per turn).

VariableDefaultWhat it does
LUCY_INDEX_DIRSsee belowComma-separated vault folders to index. Replaces the default list: Context, Projects, Skills, Daily, Knowledge, Reference, Reports, Brain/decisions, Brain/entities, Brain/claude-memory, Brain/episodes, Brain/proposals.
LUCY_RECALL_PREFETCHonSearch the vault before each chat turn.
LUCY_RECALL_GATE2onSkip recall for corrections and pure follow-ups.
LUCY_RECALL_MAX8 (bridge), 5 (hub)Hits requested from the coordinator.
LUCY_RECALL_HITS5Hits injected into the prompt.
LUCY_RECALL_BUDGET800Character budget for the injected memory block.
LUCY_RECALL_SNIPPET200Characters per hit.
LUCY_RECALL_TIMEOUT4Seconds to wait for recall before answering without it.
LUCY_RECALL_MIN_SCORE0.35Minimum rerank score for a hit to be used. Applies only to reranked hits; others are filtered by keyword overlap.
LUCY_RECALL_PROVENANCEonTag each hit with its file and age.
LUCY_RECALL_FAILLOUDonLog loudly when recall fails.
LUCY_VECTORon if JINA_API_KEYSet 0 to force full-text only.
LUCY_RERANKoffRerank hits with Jina (needs JINA_API_KEY). Required for score-based filtering.
LUCY_VECTOR_MAX_DIST0.9Maximum vector distance for a vector hit.
LUCY_EMBED_TIMEOUT_MS, LUCY_RERANK_TIMEOUT_MS20000, 15000Jina call timeouts.
LUCY_EMBED_THROTTLE_MS1200Pause between embedding batches.
LUCY_EPISODIConLog conversation turns for cross-session recall.
LUCY_EPISODIC_RETENTION_DAYS90Episodic turns older than this are pruned.
LUCY_CONSOLIDATEoffRun fact consolidation (dedupe, supersede) during the dream. Needs vector search. The dream cron turns it on.
LUCY_CONSOLIDATE_APPLYoffActually apply consolidation; otherwise it only writes a report. The dream cron turns it on.
LUCY_CONSOLIDATE_SIM, LUCY_CONSOLIDATE_CLUSTER_SIM, LUCY_CONSOLIDATE_REFLECT_TRUST0.86, 0.78, 5Consolidation thresholds.
LUCY_BRAIN_DREAMonPer-persona "brain" consolidation during the dream (0 = off).
LUCY_DISTILLonDistil signals from agent runs into Brain/inbox (0 = off).
LUCY_DISTILL_MODELhaikuModel for distillation and per-persona dreaming.
LUCY_AUXonAllow distillation to use a cheap auxiliary lane (0 = always use Claude).

Agents, models and tools ​

VariableDefaultWhat it does
LUCY_ROUTER_MODELor-nemotron-superLane model used to route messages in auto mode. Must be a key from the model catalog.
LUCY_PROMPT_ARCHITECT_MODELds-chatLane for the Prompt Architect.
LUCY_PROMPT_ARCHITECT_ESCALATE_MODELopusModel used when you escalate a prompt.
LUCY_TOOL_REGISTRYoffUse the unified tool registry for lane tools (experimental).
LUCY_JINA_READERoffUse Jina Reader/Search for web tools instead of keyless DuckDuckGo.
LUCY_HOOKSoffInstall a pre-tool guard for agent runs that blocks dangerous shell commands and logs tool use. Recommended.
LUCY_HOOKS_LOGAM_TURNS_LOGWhere the hook writes its log.

pxpipe ​

Set in ecosystem.config.cjs for lucy-pxpipe:

VariableValueWhat it does
HOST127.0.0.1Bind address. Keep it local: its dashboard has no auth.
PORT47821Port that ANTHROPIC_BASE_URL points to.
PXPIPE_MODELSlist of model IDsOnly requests for these models are compressed.

Hub-only .env (optional) ​

The hub also loads hub/server/.env via dotenv, for running it outside PM2 (see hub/deploy.sh). Values in the PM2 environment take precedence. With the root ecosystem.config.cjs you don't need this file.

Other files ​

FilePurpose
.env.example (repo root)TAVILY_API_KEY, used only by tools/tavily_search.py.
agent-machine/config/personas/*.jsonAgent personas (role, model, optional laneModel, allowed tools).
agent-machine/config/pipelines/*.jsonBoard pipelines (stages and gates).
agent-machine/config/model-catalog.jsonCheap-lane model catalog (npm run gen:catalog).
bridge/persona.mdChat persona.
~/.claude/settings.jsonClaude Code settings; set autoMemoryDirectory to the vault (see Installation).