Hermes Agent pointed at magpie (provider "custom", base URL on this
machine) probes the server as Ollama: detect_local_server_type GETs
/api/tags, which magpie answers in Ollama's shape for VS Code's Copilot,
and the body has "models", so it is "ollama". agent_init_ollama.py then
asks /api/show for the model's context and the custom profile sends it as
extra_body {"options": {"num_ctx": N}} on every chat request
(plugins/model-providers/custom/__init__.py, NousResearch/hermes-agent
90d6b98f). magpie relayed that top-level options to Mistral as it came,
and Mistral's chat API forbids extra fields: 422 extra_forbidden on
["body","options"] for every request. Mistral's own request model
(mistralai/client-python d3da3bd, ChatCompletionRequest) has no options;
it does take reasoning_effort "medium", the other field Hermes adds.
9a4eaab82 (#3097) left options out for Gemini's OpenAI-compatible API
only and kept it for every other vendor. No Chat API reads it, Ollama's
own /v1 included (openai.ChatCompletionRequest has no Options), so every
relayed Chat body now goes without its top-level options
(withoutOllamaOptions), as the Ollama route's own builder already leaves
the runner settings out (ollamaChatBody). The cut is withoutTopMember's,
every other byte as it came: the old withoutFields re-encoded the whole
body through a map, which would have reordered every tool schema of any
request whose text says "options". A body without the word is not
parsed. Groq, which Hermes' own comment names as strict too, and every
other vendor get the same body. /api/tags and /api/show are left
answering in Ollama's shape: VS Code's and Visual Studio's Copilot need
them, and a client can't be told from Hermes there.
Run (mote, at this commit): go test ./internal/gateway -timeout 45m:
ok (812.7s). go vet ./internal/gateway, GOOS=linux GOARCH=amd64
-tags nogui and GOOS=windows GOARCH=amd64 go vet ./internal/gateway
clean; gofmt -l clean.
Red without the fix: with the withoutOllamaOptions line taken out,
TestHermesOllamaOptionsNeverReachMistral fails with Mistral's fake 422
extra_forbidden on options, and TestChatRelayLeavesOutOllamaOptions with
options reaching both Gemini and Kimi. With withoutFields(body,
"options") in its place, the new test fails on the tools not going
byte for byte.
Not tried: a real Mistral key (none at hand; api.mistral.ai answers 401
before it validates the body) and a real Hermes run (it rewrites the live
~/.hermes launcher under a temp HERMES_HOME); the field and the refusal
are from Hermes' and Mistral's own source, the 422 shape from #494/#393.