Skip to content

The agent that grows with you

fix(cli): the banner shows main's 8-character session label for a canonical id

Teknium7e93de19bd7f
diff --git a/hermes_cli/cli_info_mixin.py b/hermes_cli/cli_info_mixin.py
index f30a6e605cc..d8431cc610c 100644
--- a/hermes_cli/cli_info_mixin.py
+++ b/hermes_cli/cli_info_mixin.py
@@ -130,6 +130,7 @@ class CLIInfoMixin:
gateway_inventory = getattr(getattr(self, "_session_db", None), "banner_inventory", lambda: None)()
if gateway_inventory is not None:
+ from hermes_cli.gateway_session_store import session_label
# The gateway session's snapshot (the TUI banner's data): the CLI enumerates nothing.
self._defer_tool_warnings = True
build_welcome_banner(
@@ -137,7 +138,8 @@ class CLIInfoMixin:
availability=gateway_inventory["availability"],
skills_by_category=gateway_inventory["skills_by_category"],
**{**banner_kw, "cwd": gateway_inventory["cwd"] or cwd,
- "context_length": gateway_inventory["context_length"] or ctx_len})
+ "context_length": gateway_inventory["context_length"] or ctx_len,
+ "session_id": session_label(self.session_id)})
elif snapshot is not None:
self._defer_tool_warnings = True
toolset_map = snapshot["toolset_map"]
diff --git a/hermes_cli/gateway_session_store.py b/hermes_cli/gateway_session_store.py
index 085afd450dd..4de4fe8d0ba 100644
--- a/hermes_cli/gateway_session_store.py
+++ b/hermes_cli/gateway_session_store.py
@@ -18,6 +18,7 @@ from __future__ import annotations
import argparse
import logging
import os
+import re
import uuid
from hermes_cli.gateway_client import GatewayClientError
@@ -215,6 +216,16 @@ class GatewaySessionStore:
}
+_CANONICAL_LOCAL_ID = re.compile(r"^local-([0-9a-f]{8})[0-9a-f]{56}$")
+
+
+def session_label(session_id):
+ """Main's 8-character banner label for a canonical durable id (``local-`` + 64 hex); every other
+ id is shown as is. Display only: RPCs, /resume hints and the exit summary keep the full id."""
+ match = _CANONICAL_LOCAL_ID.match(session_id or "")
+ return match.group(1) if match else session_id
+
+
def _creation_policy(launch):
"""The explicit launch flags as ``session.create`` policy (the thin client's own mapping);
unset flags leave the gateway to resolve the profile default, as main's CLI did."""
diff --git a/tests/hermes_cli/test_gateway_session_store.py b/tests/hermes_cli/test_gateway_session_store.py
index 49c1f991404..c1ed5373e01 100644
--- a/tests/hermes_cli/test_gateway_session_store.py
+++ b/tests/hermes_cli/test_gateway_session_store.py
@@ -126,3 +126,11 @@ def test_reader_opens_once_the_gateway_created_state_db(store, tmp_path, monkeyp
from hermes_state import SessionDB
SessionDB(db_path=tmp_path / "state.db").close()
assert db.get_session("x") is None and db._reader is not None
+
+
+def test_banner_session_label_is_mains_eight_characters_for_a_canonical_id():
+ from hermes_cli.gateway_session_store import session_label
+ assert session_label("local-ab12cd34" + "0" * 56) == "ab12cd34"
+ assert session_label("20261012_134501_abcdef") == "20261012_134501_abcdef"
+ assert session_label("local-abc") == "local-abc"
+ assert session_label(None) is None