Skip to content

CLI session displays stale primary model name after fallback activation #6380

@SeeYangZhi

Description

@SeeYangZhi

When the primary model fails and the agent switches to a fallback provider, the CLI session header continues to display the primary model name instead of the fallback model.

Root cause: _build_system_prompt() caches the system prompt in self._cached_system_prompt. When _try_activate_fallback() swaps the model/provider, and when _restore_primary_runtime() restores them at the start of a new turn, neither method invalidates the cache. The stale model name therefore persists in the system prompt until something else triggers a rebuild.

Fix: Call self._invalidate_system_prompt() in both _try_activate_fallback() and _restore_primary_runtime() so the prompt is rebuilt with the correct model/provider. Also harden _invalidate_system_prompt() with getattr to avoid attribute errors in test fixtures.

Verification:

  • python -m pytest tests/run_agent/test_compressor_fallback_update.py tests/run_agent/test_primary_runtime_restore.py -xvs passes (27/27).

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low — cosmetic, nice to havecomp/agentCore agent loop, run_agent.py, prompt buildercomp/cliCLI entry point, hermes_cli/, setup wizardtype/bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions