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
- Start CLI session:
hermes chat
- Have a conversation (creates session DB entry with system prompt)
- Execute
/personality surfer
- System shows "Personality set to 'surfer' (saved to config)"
- Agent continues responding in old style
- Check
config.yaml — agent.system_prompt is updated to surfer
- 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)
Bug Description
/personality surferin CLI shows "Personality set to 'surfer' (saved to config)" and writes toconfig.yaml, but the agent continues using the old personality because_restore_or_build_system_prompt()inconversation_loop.pyprioritizes the session DB stored prompt overephemeral_system_prompt.Steps to Reproduce
hermes chat/personality surferconfig.yaml—agent.system_promptis updated to surferRoot Cause Analysis
_restore_or_build_system_prompt()(conversation_loop.py:218) restores the old system prompt from session DB, completely ignoring the newly setephemeral_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_promptnever used.Evidence
system_prompt.py:285-286comments: "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/personalitycommand), but agent behavior unchangedSuggested Fix
In
conversation_loop.py, before line 267, add:This ensures
ephemeral_system_prompttakes priority over session DB stored prompt, which is the intended behavior for a personality override.Environment
hermes chat)