## Model Switch Error Analysis

Collection of error patterns observed during local model switching:

### 1. Triple-Quoted String Termination
Wrong:
```python
"""Stop active model, start target, update config.

Writes all config changes atomically FIRST, then swaps services.
This prevents the path watcher race: writing config before touching
services means auto-model-switch.py sees the intent, not an
intermediate state that causes a revert.

When switching to a cloud model, keeps local models warm in VRAM.
VRAM drain delay only applies to local-to-local switching.
"""
```
Right:
```python
"""Stop active model, start target, update config.

Writes all config changes atomically FIRST, then swaps services.
This prevents the path watcher race: writing config before touching
services means auto-model-switch.py sees the intent, not an
intermediate state that causes a revert."""
```

### 2. Service Termination Pattern
Common failure pattern where local models were not kept warm:
```
if active:
    stop_service(active)
# Give GPU VRAM time to drain before starting next model
_time.sleep(3)  # Bad: missing 'import time'
```
Fixed pattern:
```python
if active and active["provider"] == "local" and target["provider"] == "local":
    stop_service(active)
    time.sleep(3)  # Proper VRAM drain for local transitions
```

### 3. Atomic Config Updates
Old broken pattern (triggers path watcher 3x):
```python
hermes config set 3 times
```
New working pattern:
```python
def write_config_atomic(provider, model, base_url):
    # Single write = single path watcher trigger
"""