Skip to content

feat(cli,gateway): /new accepts optional session name argument#19555

Closed
exxmen wants to merge 1 commit into
NousResearch:mainfrom
exxmen:feat/new-session-title-argument
Closed

feat(cli,gateway): /new accepts optional session name argument#19555
exxmen wants to merge 1 commit into
NousResearch:mainfrom
exxmen:feat/new-session-title-argument

Conversation

@exxmen

@exxmen exxmen commented May 4, 2026

Copy link
Copy Markdown

What

Allow /new <name> and /reset <name> to start a fresh session and immediately set its title, collapsing a two-step dance into one command.

/new Refactor auth module

Why

Right now users who start a session with a specific purpose must run /new followed by /title <name>. This is friction that other tools (e.g., Claude Code's /rename) already eliminate. Hermes already has robust title handling \u2014 we just need to expose it at session creation time.

Changes

File Change
hermes_cli/commands.py Add args_hint="[name]" to /new
cli.py process_command() parses title, passes to new_session(title=...); new_session() sanitizes and sets via SessionDB.set_session_title()
gateway/run.py _handle_reset_command() parses title and sets on new session
gateway/session.py reset_session() accepts optional display_name
tests/cli/test_cli_new_session.py test_new_session_with_title
tests/gateway/test_title_command.py test_reset_command_with_title, test_new_command_in_help_output

Edge cases handled

  • No title \u2192 behaves exactly as before
  • Empty/whitespace title \u2192 silently ignored
  • Invalid characters \u2192 sanitized via existing SessionDB.sanitize_title()
  • Title conflicts \u2192 caught by existing uniqueness check
  • No _session_db \u2192 skips gracefully
  • Gateway auto-reset (compression exhaustion) \u2192 unaffected
  • Backward compatible \u2014 /reset alias works, all existing tests pass

Testing

venv/bin/python -m pytest   tests/cli/test_cli_new_session.py   tests/gateway/test_title_command.py   tests/gateway/test_fresh_reset_skill_injection.py   tests/gateway/test_session_model_reset.py   tests/gateway/test_session_boundary_hooks.py   -v -o '\''addopts='\''

Result: 36 passed, 0 failed

Checklist

  • Branch named per guidelines (feat/description)
  • Commits follow Conventional Commits
  • Tests added and passing
  • No unrelated changes mixed in
  • Rebased on latest origin/main

Allow users to start a fresh session and immediately set its title by
passing a name to /new (or /reset):

    /new Refactor auth module

Changes:
- hermes_cli/commands.py: add args_hint='[name]' to /new command
- cli.py: parse title argument in process_command(), pass to new_session()
- cli.py: new_session() accepts title=None, sets title via SessionDB
- gateway/run.py: _handle_reset_command() parses title, sets on new entry
- gateway/session.py: reset_session() accepts optional display_name
- tests: add test_new_session_with_title, test_reset_command_with_title,
  test_new_command_in_help_output

All 36 affected tests pass.
Copilot AI review requested due to automatic review settings May 4, 2026 06:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds optional naming to fresh-session commands so users can start/reset a session and set its title in a single step (/new <name> / /reset <name>), aligning CLI + gateway behavior with existing session title infrastructure.

Changes:

  • Expose an optional [name] arg hint for /new in the shared slash-command registry.
  • Parse /new <name> in CLI and gateway reset handler, sanitize, and attempt to persist via SessionDB.set_session_title(...).
  • Add regression tests covering CLI /new title setting and gateway /new help output + title setting.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
hermes_cli/commands.py Advertises optional [name] argument for /new in help/autocomplete outputs.
cli.py Parses /new <name> and threads an optional title into new_session(...), attempting to sanitize + persist it.
gateway/run.py Parses /new <title> args in _handle_reset_command and attempts to sanitize + persist the title for the new session.
gateway/session.py Extends SessionStore.reset_session() to accept an optional display_name for the new SessionEntry.
tests/cli/test_cli_new_session.py Adds a test asserting new_session(title=...) calls set_session_title and prints the title.
tests/gateway/test_title_command.py Adds tests for /new <title> behavior and /new [name] help output.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cli.py
Comment on lines +4986 to +4994
if title and self._session_db:
try:
from hermes_state import SessionDB
sanitized = SessionDB.sanitize_title(title)
if sanitized:
self._session_db.set_session_title(self.session_id, sanitized)
self._pending_title = None
except Exception:
pass
Comment thread cli.py
Comment on lines +5014 to +5017
if title:
print(f"(^_^)v New session started: {title}")
else:
print("(^_^)v New session started!")
Comment thread gateway/run.py
Comment on lines +6879 to +6886
if _title_arg and self._session_db and new_entry:
try:
from hermes_state import SessionDB
sanitized = SessionDB.sanitize_title(_title_arg)
if sanitized:
self._session_db.set_session_title(new_entry.session_id, sanitized)
except Exception:
pass
@alt-glitch alt-glitch added type/feature New feature or request P3 Low — cosmetic, nice to have comp/cli CLI entry point, hermes_cli/, setup wizard comp/gateway Gateway runner, session dispatch, delivery labels May 4, 2026
@teknium1

teknium1 commented May 4, 2026

Copy link
Copy Markdown
Contributor

Merged via #19637 — your commit (f720751) was cherry-picked onto current main with your authorship preserved. Added a small follow-up (5b6d413) to surface the ValueError from duplicate titles instead of swallowing it. Thanks for the contribution!

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

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard comp/gateway Gateway runner, session dispatch, delivery P3 Low — cosmetic, nice to have type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants