hermes - 💡(How to fix) Fix [Bug] System prompt injects stale model/provider after /model switch with custom_providers [3 pull requests]

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…

Root Cause

In run_agent.py, _build_system_prompt() (around line 5770) injects self.model and self.provider directly:

if self.model:
    timestamp_line += f"\nModel: {self.model}"
if self.provider:
    timestamp_line += f"\nProvider: {self.provider}"

These attributes are set from config.yaml at init time and are not updated after switch_model() resolves the actual provider/model through the custom_providers routing logic.

switch_model() and resolve_provider_client() correctly resolve the routing at runtime, but the resolved values are not reflected back to self.model / self.provider, so the system prompt continues showing the original config values.

Fix Action

Fixed

Code Example

if self.model:
    timestamp_line += f"\nModel: {self.model}"
if self.provider:
    timestamp_line += f"\nProvider: {self.provider}"
RAW_BUFFERClick to expand / collapse

Bug Description

When using custom_providers and switching models via /model, the system prompt injects the config-level model.provider and model.default values instead of the runtime-resolved provider and model. This causes the LLM to see incorrect metadata about which endpoint and model it is actually using.

Reproduction Steps

  1. Configure a custom_providers entry in config.yaml (e.g., a Volcengine endpoint)
  2. Set model.provider: openai-codex (or any other provider) in config.yaml
  3. Use /model to switch to the custom provider model
  4. Ask the agent what model/provider it is running - it reports the config-level values, not the actual routed ones

Expected Behavior

The system prompt should inject the resolved model ID and provider name that the framework actually routes API calls to.

Actual Behavior

The system prompt injects stale values:

FieldSystem prompt showsActual runtime value
Modelconfig model.default (e.g. custom provider name)routing alias (e.g. ark-code-latest)
Providerconfig model.provider (e.g. openai-codex)resolved from custom_providers (e.g. custom:火山方舟)
Base URL(not injected)actual API endpoint

Root Cause

In run_agent.py, _build_system_prompt() (around line 5770) injects self.model and self.provider directly:

if self.model:
    timestamp_line += f"\nModel: {self.model}"
if self.provider:
    timestamp_line += f"\nProvider: {self.provider}"

These attributes are set from config.yaml at init time and are not updated after switch_model() resolves the actual provider/model through the custom_providers routing logic.

switch_model() and resolve_provider_client() correctly resolve the routing at runtime, but the resolved values are not reflected back to self.model / self.provider, so the system prompt continues showing the original config values.

Suggested Fix Options

Option A: Inject resolved values at prompt-build time (minimal change)

After provider resolution, store the resolved model/provider on the agent instance (e.g., self._resolved_model, self._resolved_provider) and use those in _build_system_prompt().

Option B: Also inject base_url

Adding base_url to the system prompt gives the LLM a reliable signal regardless of provider name accuracy.

I would recommend Option A + B combined for the safest fix.

Environment

  • Hermes Agent: latest (installed via curl install script)
  • OS: Amazon Linux 2023 (x86_64)
  • Custom provider: Volcengine Coding API

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 [Bug] System prompt injects stale model/provider after /model switch with custom_providers [3 pull requests]