Package: internal/config
Last updated: 2026-03-26
Configuration is loaded from a JSON file and environment variables. Environment variables override file values. The config file uses a nested schema. File path is $UA_CONFIG or ~/.micro-agent/config.json. Missing or unreadable file is ignored (defaults are used).
| Top-level key | Description |
|---|---|
default |
Provider, model, base_url, max_tokens, max_messages, workdir, log_file, compaction, shell_exec, top_p, top_k, min_p, presence_penalty, repetition_penalty |
llamacpp |
host, port — used to build base URL when default.base_url is absent |
memory |
path (MEMORY_DB, cron SQLite), embed, milvus_addr, milvus_username, milvus_password, milvus_db, milvus_collection — see below |
channels |
telegram (token, chat_id), cron (enabled, interval, heartbeat_file), http (enabled, listen, token) |
tools |
browserless_url |
Long-term memory: Implemented with Milvus. The memory.path value is the SQLite database path used only by the cron channel for tick persistence (MEMORY_DB). Milvus connection settings come from memory.milvus_* and env vars (MILVUS_ADDR, etc.). The memory.backend JSON field is not read by config.Load(); it may appear in examples for documentation only.
Base URL: default.base_url wins if set. Otherwise llamacpp.host + llamacpp.port are used (default host 127.0.0.1, port 8080). The env var LLAMA_URL overrides any file value.
Path expansion: Paths in the file support ~ (home) and $VAR; they are expanded by internal/config before use.
See examples/config.json for a full valid example. Minimal:
{
"default": {
"base_url": "http://localhost:8080",
"model": "default",
"max_tokens": 8192,
"workdir": "~/.micro-agent/workdir",
"log_file": "~/.micro-agent/ua.log"
},
"llamacpp": { "host": "127.0.0.1", "port": 8080 },
"memory": {
"path": "~/.micro-agent/mem.db",
"embed": true,
"milvus_addr": "localhost:19530",
"milvus_collection": "memories"
},
"channels": {
"telegram": { "token": "", "chat_id": 0 },
"cron": { "enabled": false, "interval": "1m", "heartbeat_file": "HEARTBEAT.md" },
"http": { "enabled": false, "listen": "127.0.0.1:8765", "token": "" }
},
"tools": { "browserless_url": "http://localhost:3000" }
}Env always overrides the config file. Common variables:
| Variable | Description | Default (if unset in file) |
|---|---|---|
UA_CONFIG |
Config file path | ~/.micro-agent/config.json |
LLAMA_URL |
llama-server base URL | http://localhost:8080 |
AGENT_MODEL |
Model name | default |
AGENT_MAX_TOKENS |
Max tokens per call | 8192 |
AGENT_MAX_MESSAGES |
Max messages per session (0 = unlimited) | 0 |
AGENT_TOP_P |
Nucleus sampling threshold (0 = provider default) | 0 |
AGENT_TOP_K |
Top-K sampling (0 = provider default) | 0 |
AGENT_MIN_P |
Minimum token probability (0 = provider default) | 0 |
AGENT_PRESENCE_PENALTY |
Presence penalty (0 = provider default) | 0 |
AGENT_REPETITION_PENALTY |
Repetition penalty (0 = provider default) | 0 |
WORKDIR |
Working directory | ~/.micro-agent/workdir |
MEMORY_DB |
SQLite DB path for cron tick persistence only | ~/.micro-agent/mem.db |
MEMORY_EMBED |
Enable embeddings + Milvus long-term memory | true |
MILVUS_ADDR |
Milvus endpoint (host:port) | — (required for long-term memory when embed is on) |
MILVUS_USERNAME |
Optional Milvus username | — |
MILVUS_PASSWORD |
Optional Milvus password | — |
MILVUS_DB |
Optional Milvus logical database name | — |
MILVUS_COLLECTION |
Milvus collection name for memories | memories |
LOG_FILE |
Log file path | ~/.micro-agent/ua.log |
COMPACTION_STRATEGY |
truncate or summarize |
truncate |
COMPACTION_THRESHOLD |
Token threshold for summarization | 0.75 * AGENT_MAX_TOKENS |
SHELL_EXEC |
Enable shell_exec tool | false |
BROWSERLESS_URL |
Browserless Chromium base URL for browser_search, browser_content, browser_screenshot | — |
TELEGRAM_BOT_TOKEN |
Telegram bot token (enables Telegram channel) | — |
TELEGRAM_CHAT_ID |
Default chat ID for telegram_send | 0 |
CRON_ENABLED |
Enable cron/heartbeat channel | false |
HEARTBEAT_FILE |
Heartbeat content file path | HEARTBEAT.md |
CRON_INTERVAL |
Cron tick interval (e.g. 1m) |
1m |
HTTP_CHANNEL_ENABLED |
Enable HTTP channel | false |
HTTP_CHANNEL_LISTEN |
HTTP listen address | 127.0.0.1:8765 |
HTTP_CHANNEL_TOKEN |
Optional shared secret for /api/chat (X-UA-Token) |
— |
Parsed from os.Args (not the JSON file):
| Flag | Effect |
|---|---|
--interactive / -interactive |
Force CLI channel even when stdin is not a TTY |
--daemon / -daemon |
Force daemon mode (no CLI) |
-v / -vv / -vvv |
Log verbosity (info / debug / trace); see docs/multiagent.md |
--no-fs |
Disable write_file, append_file, edit_file, shell_exec for supervisor and sub-agents |
--no-web |
Disable browser_search, browser_content, web_fetch |
--no-spawn |
Omit spawn_agent (no sub-agent delegation) |
--safe |
Equivalent to --no-fs + --no-web + --no-spawn |
--agent=<id> / -agent=<id> |
Run with the sub-agent id from ~/.micro-agent/agents as the sole agent (instructions, model, tools from that config) |
config.Load() returns a single Config struct used by internal/app and cmd/ua. All paths are expanded; durations are parsed. No consumer code needs to know about the nested file shape. Milvus fields (MilvusAddr, MilvusUsername, MilvusPassword, MilvusDBName, MilvusCollection) are resolved from the memory section and corresponding env vars. HTTP channel fields (HTTPChannelEnabled, HTTPListen, HTTPToken) are resolved from channels.http and HTTP_CHANNEL_* env vars.
The agent can run in Docker; llama-server is not managed in compose and must run elsewhere (e.g. on the host). From repo root:
docker compose up --buildThe compose file is docker-compose.yml at the repository root; the ua service uses dockerfile: deploy/Dockerfile. Set LLAMA_URL so the agent reaches llama-server (e.g. http://host.docker.internal:8080 when llama-server runs on the host). The stack includes Milvus (etcd, minio, standalone), optional Browserless, and optional Attu; services use network_mode: host as defined in the file. See docker-compose.yml and deploy/Dockerfile.