Skip to content

fix(agent): respect ephemeral_system_prompt over stored DB prompt (#58774) - #59360

Closed
isheng-eqi wants to merge 3 commits into
NousResearch:mainfrom
isheng-eqi:fix/personality-ephemeral-override
Closed

fix(agent): respect ephemeral_system_prompt over stored DB prompt (#58774)#59360
isheng-eqi wants to merge 3 commits into
NousResearch:mainfrom
isheng-eqi:fix/personality-ephemeral-override

Conversation

@isheng-eqi

Copy link
Copy Markdown
Contributor

Problem

/personality saves to config but doesn't affect the current CLI session because _restore_or_build_system_prompt() unconditionally restores the session-DB stored prompt when it matches the current runtime identity — even when the caller explicitly set ephemeral_system_prompt.

Root Cause

In agent/conversation_loop.py, _restore_or_build_system_prompt at L326-330:

if stored_prompt and _stored_prompt_matches_runtime(agent, stored_prompt):
    agent._cached_system_prompt = stored_prompt
    return

No check for ephemeral_system_prompt — stored prompt always wins.

Fix

Check ephemeral_system_prompt before the stored-prompt fast path. When set (truthy), it takes precedence. The prefix cache will miss for that turn, but that is the expected trade-off for a deliberate personality switch.

Test plan

  • 3 new tests in tests/agent/test_system_prompt_restore.py:
    • ephemeral overrides stored prompt
    • ephemeral=None falls through to stored (default behavior preserved)
    • ephemeral="" falls through to stored (empty string is falsy, not an override)
  • All 11 existing tests continue to pass (14/14 total)

Related

Closes #58774

…esearch#56918)

read_file already blocks /proc/*/maps, /proc/*/mem, /proc/*/auxv,
/proc/*/pagemap, and related sensitive pseudo-files via
_is_blocked_device_path (NousResearch#56219).  search_files applied a separate
filter chain through _search_result_read_block_error that only
guarded credential-env paths (get_read_block_error) — missing the
proc-sensitive patterns.  This meant content matches, file listings,
and count results could all leak ASLR layout, raw memory, and secrets.

Add _is_blocked_device_path to the _search_result_read_block_error
guard so all three search_files output modes inherit the same
/proc-sensitive blocking that read_file already enforces.
…ch#42961)

The local backend unconditionally overwrote terminal.cwd with
os.getcwd(), ignoring any explicit terminal.cwd set in config.yaml.
Only fall back to os.getcwd() when terminal.cwd is unset or a
placeholder (".", "auto", "cwd"); preserve an explicit path.

Before: "cd /dir && hermes" was the only way to control cwd
After:  terminal.cwd: /desired/path in config.yaml works for local too
…usResearch#58774)

_restore_or_build_system_prompt unconditionally restored the session-DB
stored prompt when it matched the current runtime identity, even when
the caller set an explicit ephemeral_system_prompt (e.g. /personality).

Check ephemeral_system_prompt before the stored-prompt fast path so a
deliberate personality switch takes effect immediately instead of being
silently ignored until the next fresh session.
@isheng-eqi

Copy link
Copy Markdown
Contributor Author

Recreating from clean main branch

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant