feat: include session ID in system prompt via --pass-session-id flag

Adds --pass-session-id CLI flag. When set, the agent's system prompt
includes the session ID:

  Conversation started: Sunday, March 08, 2026 06:32 PM
  Session ID: 20260308_183200_abc123

Usage:
  hermes --pass-session-id
  hermes chat --pass-session-id

Implementation threads the flag as a proper parameter through the full
chain (main.py → cli.py → run_agent.py) rather than using an env var,
avoiding collisions in multi-agent/multitenant setups.

Based on PR #726 by dmahan93, reworked to use instance parameter
instead of HERMES_PASS_SESSION_ID environment variable.

Co-authored-by: dmahan93 <dmahan93@users.noreply.github.com>
This commit is contained in:
dmahan93
2026-03-12 05:51:31 -07:00
committed by teknium1
parent 92e9809c86
commit c7fc39bde0
3 changed files with 49 additions and 15 deletions

View File

@@ -51,7 +51,7 @@ os.environ.setdefault("MSWEA_SILENT_STARTUP", "1")
import logging
from hermes_cli import __version__
from hermes_cli import __version__, __release_date__
from hermes_constants import OPENROUTER_BASE_URL
logger = logging.getLogger(__name__)
@@ -495,6 +495,7 @@ def cmd_chat(args):
"resume": getattr(args, "resume", None),
"worktree": getattr(args, "worktree", False),
"checkpoints": getattr(args, "checkpoints", False),
"pass_session_id": getattr(args, "pass_session_id", False),
}
# Filter out None values
kwargs = {k: v for k, v in kwargs.items() if v is not None}
@@ -1484,7 +1485,7 @@ def cmd_config(args):
def cmd_version(args):
"""Show version."""
print(f"Hermes Agent v{__version__}")
print(f"Hermes Agent v{__version__} ({__release_date__})")
print(f"Project: {PROJECT_ROOT}")
# Show Python version
@@ -1895,6 +1896,12 @@ For more help on a command:
default=False,
help="Bypass all dangerous command approval prompts (use at your own risk)"
)
parser.add_argument(
"--pass-session-id",
action="store_true",
default=False,
help="Include the session ID in the agent's system prompt"
)
subparsers = parser.add_subparsers(dest="command", help="Command to run")
@@ -1966,6 +1973,12 @@ For more help on a command:
default=False,
help="Bypass all dangerous command approval prompts (use at your own risk)"
)
chat_parser.add_argument(
"--pass-session-id",
action="store_true",
default=False,
help="Include the session ID in the agent's system prompt"
)
chat_parser.set_defaults(func=cmd_chat)
# =========================================================================