~/.max/.env at startup. You can edit this file directly or re-run max setup to regenerate it interactively.
Config file location
max setup. If it doesn’t exist, Max falls back to a .env file in the current working directory (for development use only).
Environment variables
The token issued by @BotFather when you create a Telegram bot. Required for Telegram integration. When absent, Max runs without Telegram support.Example:
123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11Your numeric Telegram user ID. Max silently ignores all messages from any other user. Required alongside
TELEGRAM_BOT_TOKEN for Telegram to be enabled.Must be a positive integer (e.g. 123456789). Obtain yours by messaging @userinfobot on Telegram.The port the local HTTP API server listens on. The TUI connects to this port via Server-Sent Events. Must be in the range 1–65535.Change this if port 7777 conflicts with another service on your machine.
The AI model used by the orchestrator session. Must be a model ID available in your authenticated Copilot CLI.You can switch models at runtime with
/model in the TUI — changes are persisted back to this file automatically via persistModel().How long (in milliseconds) a worker session may run before it is considered timed out. Defaults to 600,000 ms (10 minutes).Must be a positive integer. Increase this for long-running coding or build tasks.
When set to
"1", Max is permitted to modify its own source code. This flag is not written to ~/.max/.env by max setup — it must be set manually or passed via the --self-edit CLI flag when starting the daemon.Omit this variable (or set it to anything other than "1") to keep Max from touching its own code.Example .env file
~/.max/.env
How to edit
- Interactive setup
- Direct file edit
Re-run the setup wizard to reconfigure Telegram, Google services, and the default model:The wizard reads your existing values and presents them as defaults, so you only need to change what you want.
COPILOT_MODEL is the one variable that can be changed at runtime without a restart. Sending /model gpt-4.1 in the TUI writes the new value to ~/.max/.env immediately and the daemon picks it up in the same session.Config object
Internally, Max parses and validates~/.max/.env using Zod and exposes a typed singleton:
src/config.ts
copilotModel is the only property with a setter, enabling the /model command to switch models without a daemon restart.
Persistence helpers
Two functions handle writing values back to~/.max/.env:
persistEnvVar(key, value) — Updates an existing KEY=value line in ~/.max/.env, or appends it if the key is not present. Creates the file if it doesn’t exist.
persistModel(model) — A thin wrapper around persistEnvVar that writes COPILOT_MODEL=<model>. Called automatically whenever you switch models via /model or by telling Max to switch.
src/config.ts