# ERR_INVALID_ARGUMENT Fix & Remote Provider Setup

## ERR_INVALID_ARGUMENT: Model Switching Fails

**Symptom:** `error invoking remote method 'hermes:api': Error: net::ERR_INVALID_ARGUMENT`

Appears in Hermes Desktop (Electron) when the user switches models or saves config. GET requests work, but any JSON-body mutation fails.

**Root cause (PR #40209):** The Desktop's OAuth bridge (`fetchJsonViaOauthSession`) uses Electron `net.request` and manually set a `Content-Length` header. Electron blocks this as a restricted app-set header. Consequently, `PUT /api/config` and `PATCH /api/sessions/:id` fail before reaching the network.

**Fix:** `hermes update` pulls PR #40209 (merged Jun 6, 2026) which removes the manual Content-Length and lets Chromium frame the body.

**If update doesn't help:** The packaged Desktop binary at `~/.hermes/hermes-agent/apps/desktop/release/linux-unpacked/resources/app.asar` may not have been rebuilt. Check timestamps:
```bash
stat ~/.hermes/hermes-agent/apps/desktop/release/linux-unpacked/resources/app.asar | grep Modify
stat ~/.hermes/hermes-agent/apps/desktop/electron/oauth-net-request.cjs | grep Modify
```
If the asar is older, rebuild: `cd ~/.hermes/hermes-agent/apps/desktop && npm run pack`

## Remote Model Access: Default Provider Override

When Hermes Desktop on a remote machine (e.g. CachyOS) connects to models served by llama-swap on a server:

1. **The Desktop's `~/.hermes/config.yaml` is independent from the server's.** By default `providers: {}` — no local models visible.

2. **If `nous` is the default provider** with an expired OAuth token, the Desktop errors at startup. Check token expiry:
   ```bash
   python3 -c "import json; d=json.load(open('~/.hermes/auth.json')); print(d.get('providers',{}).get('nous',{}).get('expires_at','N/A'))"
   ```
3. **Fix: set default directly to local models** to bypass OAuth entirely:
   ```yaml
   providers:
     custom:
       local:
         api_key: not-needed
         base_url: http://<server-ip>:9292/v1
         api_mode: chat_completions
         models:
           qwen36-35b-mtp:
             model: qwen36-35b-mtp
             max_input_tokens: 250000
             max_output_tokens: 16384
           # ... other models
   fallback_providers:
     - custom:local
   model:
     default: qwen36-35b-mtp
     provider: custom:local
   ```

4. **Restart Desktop** after config changes.

5. **Verify connectivity** from the Desktop machine:
   ```bash
   curl -s http://<server-ip>:9292/v1/models
   ```

## Desktop Backend Not Starting

If no Hermes Python process appears (`ps aux | grep python` shows nothing related), the Desktop's local backend failed to start. Common causes:
- Port 9120 in use from a stale process: `fuser -k 9120/tcp`
- The Desktop falls back to `127.0.0.1:9120` if remote connection fails — check `connection.json`
- Restart the Desktop app entirely
