6f3e630b47
The Desktop settings UI persists a registry provider's API key as a credential pointer -- model.key_env in config.yaml pointing at an env var in $HERMES_HOME/.env (e.g. HERMES_CUSTOM_LMSTUDIO_API_KEY) -- while keeping model.provider on the registry id. _resolve_api_key_provider_secret resolved registry providers exclusively from PROVIDER_REGISTRY[...].api_key_env_vars, so the UI-saved key was silently ignored; for lmstudio the runtime then substituted the no-auth placeholder (dummy-lm-api-key) and auth-enabled LM Studio servers rejected every request with an opaque, retryable-flagged 401. Fix: consult model.key_env (only when config.yaml's main model targets the provider being resolved, so the pointer never leaks across providers) before the registry env vars, running the value through the same _usable_declared_secret prefix validation. Precedence for the canonical env vars and the credential pool is unchanged; a valid canonical key still wins when no pointer is set. Complements #75373, which covers providers.<id>.key_env at the provider level; the Desktop save path writes the pointer at the model level, which that PR does not consult. Fixes #106336