Skip to content

/personality command saves to config but doesn't affect current CLI session — ephemeral_system_prompt ignored when session DB has stored prompt #58774

Description

@1332078952-cmyk

Bug Description

/personality surfer in CLI shows "Personality set to 'surfer' (saved to config)" and writes to config.yaml, but the agent continues using the old personality because _restore_or_build_system_prompt() in conversation_loop.py prioritizes the session DB stored prompt over ephemeral_system_prompt.

Steps to Reproduce

  1. Start CLI session: hermes chat
  2. Have a conversation (creates session DB entry with system prompt)
  3. Execute /personality surfer
  4. System shows "Personality set to 'surfer' (saved to config)"
  5. Agent continues responding in old style
  6. Check config.yamlagent.system_prompt is updated to surfer
  7. Current session agent still uses old system prompt

Root Cause Analysis

_handle_personality_command()  [cli.py:8337]
  → self.system_prompt = personality_text
  → self.agent = None  (force re-init)
  → save_config_value("agent.system_prompt", ...)

_init_agent()  [cli.py:5050]
  → self.agent = AIAgent(
      ephemeral_system_prompt=self.system_prompt  ← new personality passed in
    )

conversation_loop.py:585-588
  → _restore_or_build_system_prompt(agent, ...)

conversation_loop.py:267-271  ← BUG IS HERE
  → if stored_prompt:
      agent._cached_system_prompt = stored_prompt  ← session DB wins, ephemeral ignored
      return

_restore_or_build_system_prompt() (conversation_loop.py:218) restores the old system prompt from session DB, completely ignoring the newly set ephemeral_system_prompt.

Why it worked initially (catgirl/noir): Fresh session, no stored prompt in session DB → fell through to "build from scratch" path → used ephemeral_system_prompt.

Why it fails now: Session DB has stored prompt from previous conversation → always restores old → ephemeral_system_prompt never used.

Evidence

  • system_prompt.py:285-286 comments: "ephemeral_system_prompt is NOT included here. It's injected at API-call time only"
  • conversation_loop.py:267-271: if stored_prompt: agent._cached_system_prompt = stored_prompt; return — no check for ephemeral
  • Config currently stores pirate personality (last /personality command), but agent behavior unchanged

Suggested Fix

In conversation_loop.py, before line 267, add:

if agent.ephemeral_system_prompt:
    agent._cached_system_prompt = agent.ephemeral_system_prompt
    return

This ensures ephemeral_system_prompt takes priority over session DB stored prompt, which is the intended behavior for a personality override.

Environment

  • Hermes Agent v0.18.0
  • Ubuntu 24.04 (server) + macOS (client)
  • CLI mode (hermes chat)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low — cosmetic, nice to havearea/configConfig system, migrations, profilesarea/sessionsSession lifecycle, resume, persistence, historycomp/agentCore agent runtime: loop, agent_init, prompt builder, context-compression, responses endpointsweeper:risk-session-stateSweeper risk: may lose/corrupt/mis-associate session or context statetype/bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions