Compare commits

...

3 Commits

Author SHA1 Message Date
dmahan93
e80320069b 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.
2026-03-08 19:02:25 -05:00
dmahan93
f2027b8bff Merge remote-tracking branch 'origin/main' into pass-session-id 2026-03-08 18:59:07 -05:00
dmahan93
a648022137 feat: include session ID in system prompt
The agent now sees its session ID in the system prompt:

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

This lets the LLM reference its own session (e.g., telling the user
how to resume, or for self-awareness in multi-session workflows).
2026-03-08 18:58:43 -05:00
2 changed files with 20 additions and 3 deletions

View File

@@ -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)
# =========================================================================

View File

@@ -1409,9 +1409,10 @@ class AIAgent:
from hermes_time import now as _hermes_now
now = _hermes_now()
prompt_parts.append(
f"Conversation started: {now.strftime('%A, %B %d, %Y %I:%M %p')}"
)
timestamp_line = f"Conversation started: {now.strftime('%A, %B %d, %Y %I:%M %p')}"
if self.session_id and os.getenv("HERMES_PASS_SESSION_ID"):
timestamp_line += f"\nSession ID: {self.session_id}"
prompt_parts.append(timestamp_line)
platform_key = (self.platform or "").lower().strip()
if platform_key in PLATFORM_HINTS: