# Model / provider / fallback wiring Recipes and pitfalls for repairing a Hermes model line (primary + fallback chain) across profiles. ## Config edit path - `~/.hermes/config.yaml` is refused by file-editing tools (security-sensitive). Change it only with `hermes config set/unset ` or `hermes -p config set/unset`. - Install a multi-entry fallback chain in one command with a JSON array instead of the interactive picker: ``` hermes config set fallback_providers '[{"provider":"anthropic","model":"claude-sonnet-5","api_mode":"anthropic_messages","base_url":"https://api.anthropic.com"},{"provider":"custom","model":"","base_url":"http://127.0.0.1:11434/v1","api_mode":"chat_completions"}]' ``` Verify with `hermes fallback list` — it prints Primary + the ordered chain. - Setting `model.provider` to a new provider auto-clears the `base_url`/`api_mode` that belonged to the previous provider (Hermes tells you it did). Re-set `base_url`/`api_mode` for the new provider afterwards. - Removing a dead provider fully: `hermes config unset providers.`, `hermes config unset model.key_env`, and `hermes auth remove ` (the id/index is REQUIRED — `hermes auth remove ` alone errors). `auth remove` also clears the key from `.env` and suppresses re-seeding. ## Fleet-wide chain edit Use the official `hermes -p config set ...` command for every profile, with the user's approval for each multi-profile change. If a tool refuses to edit `config.yaml` or a command guard blocks a command, treat that as a stop sign: do not work around it with a text-editing script, ask the user. - Skip out-of-scope profiles. Back up each `config.yaml` first. - Afterwards compare every profile's `fallback_providers` with the reference profile in code (`hermes -p

config get ...`) and print the profiles that differ (expect none). - Probe each new chain entry live (`hermes chat --provider

-m --oneshot -Q -q 'Sadece tamam yaz.'`) before adding it. ## Provider api_mode / base_url map | Provider | api_mode | base_url | |---|---|---| | anthropic | anthropic_messages | https://api.anthropic.com | | custom (Ollama) | chat_completions | http://127.0.0.1:11434/v1 | ## Ollama context sizing is per role — keep two models - The Hermes **main agent** (Desktop/TUI chat) enforces a minimum context window of ~64000 tokens and refuses a model whose num_ctx is smaller. Build that model with `PARAMETER num_ctx 65536` in its Modelfile. - A **fallback / last-resort** local model should stay light: `PARAMETER num_ctx 4096`, `temperature 0.2`, and no thinking parameter (a thinking-enabled small model returns HTTP 400 "does not support thinking" on the OpenAI-compat endpoint). Do not point the fallback at the 64k model — the large context wastes RAM for a role that only handles short prompts. - Smoke-test the local endpoint directly before trusting it: `curl --max-time 100 http://127.0.0.1:11434/v1/chat/completions -d '{"model":"","messages":[{"role":"user","content":"..."}],"max_tokens":20,"stream":false}'`. First call after create is a cold load; give it a long timeout. ## Model identity, ranking, and reasoning - Probe each requested model through the exact worker/provider that will run it; record both the requested model and the returned identity. A successful call to a model id does not prove its long-context variant is supported, and a config/cache entry does not prove either is callable. - Use a minimal non-mutating Codex probe such as: ``` codex exec --ephemeral --skip-git-repo-check --sandbox read-only --model "Reply exactly with MODEL_OK and your actual model identity. Do not use tools." ``` Run the normal and large-context variants separately and preserve non-zero status plus the provider's error text. - Build fallback order from live verified candidates, not labels or assumed equivalence. Keep a failed or entitlement-unknown model out of automatic fallback; stop and report when the verified chain is exhausted instead of silently dropping to a weak local model. - Reasoning is a per-task control: use `low`/`medium` for light work, `high` for normal work, and `xhigh`/`max` when the provider supports it for heavy work. Keep analyze/test/build/QA gates unchanged when lowering reasoning. Configure per-model defaults with `agent.reasoning_overrides` and use the session `/reasoning` control for temporary changes. - **Separate observed native runtime success from the chosen Claude route.** A running Hermes process may retain credentials while a new CLI reports logged out, but a `provider=anthropic` turn-start log is NOT proof of successful inference; require a completed API response. Neither previous success nor a working quota probe proves continuing native OAuth entitlement. If the user has chosen to run Claude only through the official `claude -p` CLI, do not restore an Anthropic fallback or native delegation pin; treat the Anthropic mapping above as generic documentation, not as the desired configuration. - **Native Gemini 403 means billing, not a bad key.** The Gemini native provider (and the OpenAI-compat endpoint `https://generativelanguage.googleapis.com/v1beta/openai/`) returns `403 PERMISSION_DENIED ... requires billing to be enabled` even on a Free-tier AI Studio key, because Hermes' calls route through a billed project/endpoint. A working `agy`/Antigravity subscription session does NOT share that auth path — keep Gemini as an `agy` CLI worker rather than a native model line unless billing is deliberately enabled. Diagnose from agent.log (`Gemini HTTP 403`), report the endpoint/model/error without printing the key value. ## macOS note - There is no `timeout` binary on stock macOS; use `curl --max-time N` or a language-level timeout for smoke tests instead of `timeout N ...`.