hermes - 💡(How to fix) Fix HERMES_INFERENCE_PROVIDER env var silently overrides session model switches [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
NousResearch/hermes-agent#14616Fetched 2026-04-24 06:15:56
View on GitHub
Comments
0
Participants
1
Timeline
5
Reactions
0
Participants
Timeline (top)
labeled ×5

When HERMES_INFERENCE_PROVIDER is set in ~/.hermes/.env, it takes priority over the model.provider field in config.yaml AND over session-level model overrides set via /model. This means /model <name> --provider <slug> appears to succeed but the actual provider used for inference reverts to the .env value.

Root Cause

resolve_runtime_provider() in hermes_cli/runtime_provider.py reads HERMES_INFERENCE_PROVIDER from the environment as a high-priority override. When _resolve_session_agent_runtime() in gateway/run.py calls resolve_runtime_provider(requested=target_provider) with the override's target provider, the env var can interfere in certain code paths, especially when the override doesn't contain all required fields and the resolver falls back to env-based resolution.

Additionally, _resolve_session_agent_runtime() first calls resolve_runtime_provider() then overlays the override's values. If any overlay field is None, the (possibly wrong) resolved value survives.

Fix Action

Fix / Workaround

Medium — causes confusion when users have HERMES_INFERENCE_PROVIDER in .env (which some setup guides may recommend). The /model command appears to work but doesn't actually change the provider. Removing the env var is a workaround but this behavior is undocumented.

RAW_BUFFERClick to expand / collapse

Summary

When HERMES_INFERENCE_PROVIDER is set in ~/.hermes/.env, it takes priority over the model.provider field in config.yaml AND over session-level model overrides set via /model. This means /model <name> --provider <slug> appears to succeed but the actual provider used for inference reverts to the .env value.

Reproduction

  1. In ~/.hermes/.env, set: HERMES_INFERENCE_PROVIDER=custom:provider-a
  2. In config.yaml, set: model.provider: custom:provider-b
  3. Via chat, run /model some-model --provider custom:provider-c
  4. Observe: model switch confirmation appears
  5. Send a message — the inference uses provider-a (from .env), not provider-c

Root Cause

resolve_runtime_provider() in hermes_cli/runtime_provider.py reads HERMES_INFERENCE_PROVIDER from the environment as a high-priority override. When _resolve_session_agent_runtime() in gateway/run.py calls resolve_runtime_provider(requested=target_provider) with the override's target provider, the env var can interfere in certain code paths, especially when the override doesn't contain all required fields and the resolver falls back to env-based resolution.

Additionally, _resolve_session_agent_runtime() first calls resolve_runtime_provider() then overlays the override's values. If any overlay field is None, the (possibly wrong) resolved value survives.

Suggested Fix

When a session model override is active, _resolve_session_agent_runtime() should not consult HERMES_INFERENCE_PROVIDER — the override's explicit provider should take absolute precedence. Options:

  • Pass a flag like ignore_env_override=True to resolve_runtime_provider()
  • Or in _resolve_session_agent_runtime(), after overlaying override values, verify that the final provider and base_url match what the override specified

Impact

Medium — causes confusion when users have HERMES_INFERENCE_PROVIDER in .env (which some setup guides may recommend). The /model command appears to work but doesn't actually change the provider. Removing the env var is a workaround but this behavior is undocumented.

Environment

  • Hermes agent version: 1acf81fd (Apr 13, 2026)
  • Affects all platforms when HERMES_INFERENCE_PROVIDER env var is set

extent analysis

TL;DR

To fix the issue, modify _resolve_session_agent_runtime() to ignore the HERMES_INFERENCE_PROVIDER environment variable when a session model override is active.

Guidance

  • Modify the resolve_runtime_provider() function to accept an ignore_env_override flag, which, when set to True, prevents it from reading the HERMES_INFERENCE_PROVIDER environment variable.
  • Update _resolve_session_agent_runtime() to pass ignore_env_override=True to resolve_runtime_provider() when a session model override is active.
  • After overlaying override values in _resolve_session_agent_runtime(), verify that the final provider and base_url match the override's specifications to ensure the correct provider is used.
  • Consider documenting the current behavior and the workaround of removing the HERMES_INFERENCE_PROVIDER environment variable to avoid confusion.

Example

def resolve_runtime_provider(requested, ignore_env_override=False):
    # existing code...
    if ignore_env_override:
        # do not read HERMES_INFERENCE_PROVIDER from environment
        pass
    # existing code...

def _resolve_session_agent_runtime(override):
    # existing code...
    if override:
        # pass ignore_env_override=True to prevent env var interference
        resolve_runtime_provider(requested=override.target_provider, ignore_env_override=True)
    # existing code...

Notes

The suggested fix assumes that the HERMES_INFERENCE_PROVIDER environment variable is the sole cause of the issue. However, the root cause analysis mentions that the resolver falls back to env-based resolution when the override doesn't contain all required fields, which might introduce additional complexity.

Recommendation

Apply the workaround by modifying the _resolve_session_agent_runtime() function to ignore the HERMES_INFERENCE_PROVIDER environment variable when a session model override is active, as this approach directly addresses the identified issue without requiring a version upgrade.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

hermes - 💡(How to fix) Fix HERMES_INFERENCE_PROVIDER env var silently overrides session model switches [1 participants]