Add: Hermes config loader explanation — from 2026-10-08 config.yaml investigation

This commit is contained in:
Nikki (wiki profile)
2026-10-08 22:36:00 +01:00
parent 548cc60761
commit 4e6b7ce5b7
+90
View File
@@ -0,0 +1,90 @@
# Hermes Config Loader
> A config loader in the personal-wiki
**Source:** 2026-10-08 investigation of `/opt/data/config.yaml` and `hermes-agent` skill references.
Hermes Agent is a multi-layered config system. The loader reads, validates, and applies configuration at different scopes — the main settings file plus a separate secrets file.
## 1. Configuration File Hierarchy
```
/opt/data/config.yaml ← Main config (this is $HERMES_HOME/config.yaml)
/opt/data/.env ← Secrets only (API keys, tokens)
/opt/data/profiles/<name>/ ← Per-profile isolated config
```
When `hermes` runs, the loader resolves `$HERMES_HOME` (here `/opt/data`) and reads the config from there. Profiles override this with their own home directory.
## 2. Loading Sequence
```
Resolve $HERMES_HOME
↓
config.yaml
↓
Merge profile override if active
↓
YAML parse → Python dict
↓
Schema validation
↓
Apply to runtime init
↓
Load .env for secrets
↓
Final config object
```
## 3. How Each Section Is Consumed
| Section | Key values (from this config) | How it's used |
|---------|------------------------------|---------------|
| `model` | `default: openai/gpt-5.6-sol`, `provider: openrouter`, `base_url` | Default LLM routing; provider selects the API client, model is the OpenRouter path |
| `model_aliases` | `free`, `sol`, `terra` | Switch models via `hermes config set model.default free`; alias resolved at selection time |
| `delegation` | `max_iterations: 250` | Controls `delegate_task` subagent loop |
| `fallback_providers` | `provider: openrouter, model: openai/gpt-5.6-terra` | On 429/503/connection failures, retries against this fallback |
| `runtime` | `nofile_soft_limit: 4096` | Raised at startup via `resource.setrlimit()` |
| `terminal` | `backend: local`, `timeout: 180`, `container_cpu: 1` | Shell execution strategy (local / docker / ssh / modal); container specs for sandboxed code execution |
| `compression` | `enabled: true`, `threshold: 0.5` | Context compression triggers when token budget exceeds threshold |
| `memory` | `memory_char_limit: 2200` | Enforced on memory read/write |
| `mcp_servers` | `gitea`, `proxmox`, `homelab` | MCP client init — `command`/`args`/`env` for stdio, `url`/`type` for streamable-http |
| `platforms.telegram` | `enabled: true`, `home_channel` | Gateway routing; Telegram plugin enabled with channel ID `8898381145` |
| `_config_version` | `45` | Schema version — `hermes config check` compares against the expected version to detect stale configs needing migration |
## 4. Two Key Behaviors
**Alias resolution (`model_aliases`).** `model.default` may be a full model string (`openai/gpt-5.6-sol`) or an alias name (`free`, `sol`, `terra`). The loader resolves the alias at startup to the underlying `model` + `provider` + `base_url`. Aliases are the recommended way to switch providers/models — `hermes config set model.default sol` is less error-prone than typing a full model path.
**Fallback providers (`fallback_providers`).** Ordered list of fallback configs, triggered on HTTP 429, 529, 503, or connection failures. Each fallback can use a different `provider` + `model`, enabling true failover (e.g. openrouter → openai-codex → zai).
## 5. Secrets Handling
- `config.yaml` is the **settings** file — no secrets go in it.
- `.env` is loaded into the environment; Hermes blocks direct reads — tools consume credentials via internal channels.
- Variable substitution: `mcp_servers.gitea.env.GITEA_TOKEN: ${GITEA_TOKEN}` is interpolated from the loaded `.env` values.
## 6. Runtime Application
After loading, the config is consumed by:
- `hermes_cli/main.py` — CLI entry point initializes from config
- `toolsets.py` — toolsets enabled/disabled per config entries
- Platform plugins (Telegram, Discord, …) — `platforms.*` sections
- Shell manager — `terminal.*` settings
- MCP client manager — `mcp_servers.*` entries
Consumption is **lazy**: the file is parsed entirely, but subsystems initialize only on demand (e.g. `terminal.*` matters only when a terminal tool is invoked).
## Sources
- `/opt/data/config.yaml` — current main config (`_config_version: 45`)
- `hermes-agent` skill, `references/configuration.md`
- https://hermes-agent.nousresearch.com/docs/user-guide/configuration
## Verification
```bash
hermes config check # schema version + missing sections
hermes config get model # read current value
hermes doctor # overall health
```