Environment Variables Reference

May 26, 2026 · View on GitHub

{% include lang_switcher.html %}

Environment Variables Reference

Compiled by scanning every os.environ.get / os.getenv call in sagents/, app/, common/, and mcp_servers/. Treat the source as the source of truth for default values; "—" means there is no static default (required, or derived dynamically).

0. Deployment Example Policy

deploy/dev|test|prod/.env.example uses a minimal-required policy: it keeps only Compose/application values that are normally changed per environment, secrets, accounts, and external URLs. Kubernetes-only settings live in deploy/k8s/env/*.env.example instead of the shared environment templates. Stable defaults live in code, Compose, or the K8s deploy script.

Variables intentionally kept in the examples:

TypeVariables
Environment and entrypointSAGE_ENV, SAGE_ROOT
Secrets and accountsSAGE_JWT_KEY, SAGE_REFRESH_TOKEN_SECRET, SAGE_SESSION_SECRET, MySQL/S3/Grafana passwords, LLM/Embedding API keys, email AK/SK
External URLsSAGE_TRACE_JAEGER_PUBLIC_URL, SAGE_GRAFANA_PUBLIC_URL, SAGE_S3_PUBLIC_BASE_URL, SAGE_ELASTICSEARCH_URL

Kubernetes templates separately keep NAMESPACE, SAGE_HOST, SAGE_PUBLIC_URL, IMAGE_REGISTRY, IMAGE_PULL_POLICY, K8S_IMAGE_TARGET, CTR_BIN, CTR_NAMESPACE, STORAGE_CLASS, INGRESS_CLASS_NAME, TLS_SECRET_NAME, ENABLE_INGRESS, SAGE_WEB_SERVICE_TYPE, SAGE_WIKI_SERVICE_TYPE, SAGE_WEB_NODE_PORT, and SAGE_WIKI_NODE_PORT.

Advanced overrides are not listed in .env.example unless a deployment needs to change them. Common examples include Compose project/port overrides, SAGE_WEB_BASE_PATH, SAGE_TRACE_JAEGER_URL, SAGE_LOKI_PUSH_URL, SAGE_MCP_*, OPENSANDBOX_IMAGE, OPENSANDBOX_TIMEOUT, SAGE_OPENSANDBOX_APPEND_MAX_BYTES, default LLM/Embedding model parameters, and fixed email defaults.

1. LLM defaults

VariableDefaultPurpose
SAGE_DEFAULT_LLM_API_KEYDefault OpenAI-compatible API key
SAGE_DEFAULT_LLM_API_BASE_URLhttps://dashscope.aliyuncs.com/compatible-mode/v1/Default model base URL
SAGE_DEFAULT_LLM_MODEL_NAMEdeepseek-v3Default model name
SAGE_DEFAULT_LLM_MAX_TOKENS4096Default max output tokens
SAGE_DEFAULT_LLM_TEMPERATURE0.2Default sampling temperature
SAGE_DEFAULT_LLM_MAX_MODEL_LEN52000Default context length

2. Service ports & directories

VariableDefaultPurpose
SAGE_HOSTPublic deployment hostname/IP, mainly used by K8s URL derivation; not the server bind address
SAGE_PORT8001 (server) / dynamic (desktop)Service port
SAGE_ROOT~/.sageRoot for sessions/agents/logs
SAGE_SESSIONS_PATH$SAGE_ROOT/sessionsSession persistence directory
SAGE_AGENTS_PATH$SAGE_ROOT/agentsAgent config directory
SAGE_MCP_CONFIG_PATH$SAGE_ROOT/mcp.jsonMCP server config file

3. User identity

VariableDefaultPurpose
SAGE_DESKTOP_USER_IDdesktop_default_userDefault desktop user id
SAGE_DESKTOP_USER_ROLEuserDefault desktop user role
SAGE_CLI_USER_IDcli_default_userDefault CLI user id
SAGE_TASK_SCHEDULER_USER_IDIdentity used by the task scheduler

4. Sandbox & execution

VariableDefaultPurpose
SAGE_SANDBOX_MODEpassthroughOne of passthrough / local / remote
SAGE_REMOTE_PROVIDERProvider name when remote sandbox is used
SAGE_SANDBOX_MOUNT_PATHSExtra mount paths (;/newline separated)
SAGE_SANDBOX_RUNTIME_DIRSandbox runtime directory
SAGE_SHARED_SANDBOX_RUNTIME_DIRShared sandbox runtime root
SAGE_SHARED_PYTHON_ENVfalseShare a single Python env across sessions
SAGE_SHARED_PYTHON_ENV_DIRShared venv directory
SAGE_LOCAL_CPU_TIME_LIMITLocal sandbox CPU time limit (s)
SAGE_LOCAL_MEMORY_LIMIT_MBLocal sandbox memory limit (MB)
SAGE_LOCAL_LINUX_ISOLATIONfalseLinux namespace isolation
SAGE_LOCAL_MACOS_ISOLATIONfalsemacOS sandbox-exec isolation
SAGE_USE_CLAW_MODEtrueInject IDENTITY/AGENT/SOUL/USER/MEMORY md into the system prompt
SAGE_BUNDLED_NODE_BINBundled Node binary (desktop installs)
SAGE_NODE_HOSTBundled Node service host
SAGE_NODE_MODULES_DIRShared node_modules directory

4.1 OpenSandbox (remote)

VariableDefaultPurpose
OPENSANDBOX_URLOpenSandbox endpoint
OPENSANDBOX_API_KEYAPI key
OPENSANDBOX_IMAGEopensandbox/code-interpreter:v1.0.2Default image
OPENSANDBOX_TIMEOUT1800Request timeout (s)
SAGE_OPENSANDBOX_APPEND_MAX_BYTES262144Max bytes per append call
SAGE_APPEND_PATH / SAGE_APPEND_B64Internal append-tool plumbing

4.2 Embedding defaults

VariableDefaultPurpose
SAGE_EMBEDDING_API_KEYEmbedding API key
SAGE_EMBEDDING_BASE_URLhttps://dashscope.aliyuncs.com/compatible-mode/v1/Embedding base URL
SAGE_EMBEDDING_MODELtext-embedding-v4Embedding model
SAGE_EMBEDDING_DIMS1024Embedding dimensions

5. Agent loop & prompt cache

VariableDefaultPurpose
SAGE_AGENT_STATUS_PROTOCOL_ENABLEDtrueEnable the agent turn-status protocol. When enabled, Sage injects turn_status and task completion is decided by the model calling that tool (task_done, need_user_input, blocked, or continue_work). When set to false, SimpleAgent falls back to the legacy rule-first + LLM task_complete_judge completion check.
SAGE_CLI_MAX_LOOP_COUNTMax loops per CLI turn
SAGE_SPLIT_SYSTEMtrueSplit the system message into stable / semi_stable / volatile segments to maximise prompt-cache hit rate
SAGE_STABLE_TOOLS_ORDERtrueSort the tools field by function name to stabilise the cache key
SAGE_AUTO_LINTtrueAuto-run ruff/eslint/tsc after file_write / file_update and inline diagnostics
SAGE_EMIT_TOOL_CALL_ON_COMPLETEtrueRe-emit tool_call chunks once the LLM stream completes
SAGE_ECHO_SHELL_OUTPUTfalseEcho background-shell stdout/stderr into the main stream
SAGE_FORCE_TOOL_CHOICE_REQUIREDfalseForce tool_choice=required on every LLM call that carries tools. Off by default to avoid unsupported_parameter errors on models such as OpenAI o1/o3; enable explicitly with 1/true/yes/on
SAGE_TOOL_PROGRESS_ENABLEDtrueEnable the tool live-progress channel (NDJSON type=tool_progress events for the UI only; never sent to MessageManager or the LLM)
SAGE_TOOL_PROGRESS_FLUSH_INTERVAL_MS50Coalesce window (ms). Multiple emit_tool_progress calls within the window for the same (tool_call, stream) are merged into one event. Set to 0 to disable coalescing and emit immediately
SAGE_TOOL_PROGRESS_FLUSH_BYTES16384Per-stream byte threshold; once accumulated text reaches it, flush immediately (prevents fast-producing commands from saturating the channel)

6. Memory

VariableDefaultPurpose
SAGE_DB_TYPEDatabase backend
SAGE_SESSION_MEMORY_BACKENDSession memory backend implementation
SAGE_SESSION_MEMORY_STRATEGYSession memory compress / recall strategy
SAGE_FILE_MEMORY_BACKENDFile memory backend implementation
MEMORY_ROOT_PATHRoot directory for file memory
ENABLE_REDIS_LOCKfalseEnable Redis distributed lock
MEMORY_LOCK_EXPIRE_SECONDSRedis lock TTL
REDIS_URLRedis connection string

7. MCP / AnyTool

VariableDefaultPurpose
SAGE_DEFAULT_ANYTOOL_TIMEOUTAnyTool call timeout
SAGE_LS_PATHDefault root for the MCP list_dir tool
SAGE_LS_HIDDENfalseWhether list_dir shows hidden files

8. Desktop & install

VariableDefaultPurpose
SAGE_HOST_PIDParent process PID (desktop shell watcher)
SAGE_UPDATE_URLDesktop auto-updater URL
HOST_WEBDAV_SERVER_ROOTWebDAV server root
ENABLE_DEBUG_WEBDAVfalseEnable WebDAV debug output

9. Dev & debug

VariableDefaultPurpose
TESTINGfalseTest mode; some background tasks are skipped
SAGENTS_PROFILING_TOOL_DECORATORfalseProfile every @tool call
PYTHON_BIN / CONDA_PYTHON_EXE / CONDA_PREFIX / CONDA_ROOTPython interpreter discovery (install-time)

10. Standard system variables (consumed but not set by Sage)

HOME, USERPROFILE, PATH, NODE_PATH, SSL_CERT_FILE are read for cross-platform path / certificate discovery.


Before changing any behaviour above, grep the codebase for os.environ.get('VARIABLE_NAME') to confirm the actual default and branching logic — this table is a summary, not a contract.