From e80320069b33439d190fc3b568aa468c170f3e9e Mon Sep 17 00:00:00 2001 From: dmahan93 Date: Sun, 8 Mar 2026 19:02:25 -0500 Subject: [PATCH] feat: --pass-session-id flag to include session ID in system prompt Adds --pass-session-id CLI flag that includes the session ID in the agent's system prompt when set: hermes --pass-session-id hermes chat --pass-session-id Sets HERMES_PASS_SESSION_ID=1 env var, which _build_system_prompt() checks before appending the session ID. --- hermes_cli/main.py | 16 ++++++++++++++++ run_agent.py | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/hermes_cli/main.py b/hermes_cli/main.py index 49f271f793..f8d5e3fde9 100644 --- a/hermes_cli/main.py +++ b/hermes_cli/main.py @@ -203,6 +203,10 @@ def cmd_chat(args): except Exception: pass + # --pass-session-id: include session ID in the agent's system prompt + if getattr(args, "pass_session_id", False): + os.environ["HERMES_PASS_SESSION_ID"] = "1" + # Import and run the CLI from cli import main as cli_main @@ -1303,6 +1307,12 @@ For more help on a command: default=False, help="Run in an isolated git worktree (for parallel agents)" ) + 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") @@ -1357,6 +1367,12 @@ For more help on a command: default=False, help="Run in an isolated git worktree (for parallel agents on the same repo)" ) + 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) # ========================================================================= diff --git a/run_agent.py b/run_agent.py index ec3efe4a0c..2f73f335ac 100644 --- a/run_agent.py +++ b/run_agent.py @@ -1410,7 +1410,7 @@ class AIAgent: from hermes_time import now as _hermes_now now = _hermes_now() timestamp_line = f"Conversation started: {now.strftime('%A, %B %d, %Y %I:%M %p')}" - if self.session_id: + if self.session_id and os.getenv("HERMES_PASS_SESSION_ID"): timestamp_line += f"\nSession ID: {self.session_id}" prompt_parts.append(timestamp_line)