Skip to content

fix: reset agentName on session_start so /new generates a fresh name - #21

Merged
elecnix merged 1 commit into
mainfrom
fix/new-session-agent-name
Jul 6, 2026
Merged

fix: reset agentName on session_start so /new generates a fresh name#21
elecnix merged 1 commit into
mainfrom
fix/new-session-agent-name

Conversation

@elecnix

@elecnix elecnix commented Jul 6, 2026

Copy link
Copy Markdown
Owner

Problem

After /new, the agent keeps the same name from the previous session.

Root cause

agentName is a module-level variable that persists when /new reuses the same pi process and extension module. After the restore loop finds nothing in the new (empty) session file, if (!agentName) is false because the old name is still set — so generateName() is never called.

Fix

Reset agentName = "" at the top of session_start, alongside the shuttingDown reset added in #20. Both are needed so /new produces a fully fresh session identity.

Tested

  • ✅ All 10 existing tests pass
  • ✅ Manual tmux test: after /new, agent name changes (e.g. shadow-raven-24silver-quail-9)
  • ✅ Daemon log confirms clean reconnect with new name

— gentle-newt-20

Without this reset, the module-level agentName variable retained the
previous session's name across /new because the extension module is
not reloaded. The 'if (!agentName)' guard after the restore loop
never triggered, so generateName() was never called.

Co-authored-by: gentle-newt-20 <gentle-newt-20@pi-agent.local>
@elecnix
elecnix marked this pull request as ready for review July 6, 2026 23:31
@elecnix
elecnix merged commit 8b8dd52 into main Jul 6, 2026
1 check passed
@elecnix
elecnix deleted the fix/new-session-agent-name branch July 6, 2026 23:32
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.

1 participant