# Hermes Config Update — Adding Local Models

When you add a profile to llama-swap, you must also update 3 things in `~/.hermes/config.yaml`:

## 1. custom_providers

```yaml
custom_providers:
- api_key_env: ''
  base_url: http://127.0.0.1:9292/v1
  models:
    - context_length: <N>
      description: '<short description>'
      id: <model-id-matching-llama-swap-profile-name>
      name: '<Human-readable name>'
    # ... keep existing models
  name: Local LLM (llama-swap)
```

## 2. fallback_providers

```yaml
fallback_providers:
  - model: <model-id>
    provider: custom:local-llm-(llama-swap)
```

## 3. environment_hint

```yaml
agent:
  environment_hint: "Debian 13 server, 11GB VRAM RTX 2080 Ti, <N> local models via llama-swap :9292, ..."
```

## CRITICAL: yaml.dump kwargs
When using Python to update the Hermes config, use EXACTLY these kwargs or it will silently write an empty file:
```python
with open(path, 'w') as f:
    yaml.dump(data, f, default_flow_style=False, sort_keys=False, width=1000)
```

A typo like `default_flow_state` instead of `default_flow_style` produces an empty file (zero bytes). Always validate after write:
```bash
python3 -c "import yaml; yaml.safe_load(open('/home/rurouni/.hermes/config.yaml'))" && echo "Valid YAML"
```

## Restoring from Backup
If the config is corrupted:
```bash
ls -la ~/.hermes/config.yaml.bak-*  # find most recent backup
cp ~/.hermes/config.yaml.bak-20260619-223108 ~/.hermes/config.yaml
# Then re-apply lost changes (new models, provider edits)
```

After restoring, check for stale model IDs (e.g., `gemma-26b` vs `gemma-26b-200k`). Fix any drift between llama-swap model keys and Hermes model IDs.
