Skip to content

The agent that grows with you

fix(sessions): show a steer as the user's own words in REST history

Brooklyn Nicholson4546cd40ecb7
diff --git a/hermes_cli/web_routers/sessions.py b/hermes_cli/web_routers/sessions.py
index 614355d95b2..9e63e40dd0f 100644
--- a/hermes_cli/web_routers/sessions.py
+++ b/hermes_cli/web_routers/sessions.py
@@ -589,7 +589,9 @@ def _session_files_dir(profile) -> Path:
def _project_for_display(messages: list, *, home=None, inline_images: bool = True) -> list:
from agent.compaction_display import project_compaction_message_for_display
from agent.context_compressor import is_compaction_summary_message
+ from agent.conversation_compression import _extract_steer_text_from_message
from agent.history_commentary import project_history_commentary
+ from agent.prompt_builder import STEER_DISPLAY_KIND
from agent.turn_failure_copy import untyped_failed_turn_display_kind
# inline_images=False (#116511): render content through the gateway's ``_coerce_message_text``
@@ -614,6 +616,10 @@ def _project_for_display(messages: list, *, home=None, inline_images: bool = Tru
message.get("role"), message.get("content"))
if failed_turn:
message = {**message, "display_kind": failed_turn}
+ # Mid-turn steer: the user's own words, not the model-facing marker (same as session.resume).
+ if message.get("role") == "user" and message.get("display_kind") == STEER_DISPLAY_KIND and (
+ steer_text := _extract_steer_text_from_message(message)):
+ message = {**message, "display_content": steer_text}
if not is_compaction_summary_message(message):
projected_messages.append(message)
continue
diff --git a/tests/hermes_cli/test_history_commentary_display.py b/tests/hermes_cli/test_history_commentary_display.py
index 7bccd70440d..e64a5be8f92 100644
--- a/tests/hermes_cli/test_history_commentary_display.py
+++ b/tests/hermes_cli/test_history_commentary_display.py
@@ -61,6 +61,18 @@ def test_gateway_history_uses_same_display_projection():
assert row["reasoning"].endswith("I will inspect the files.")
+def test_rest_history_shows_a_steer_as_the_users_own_words():
+ from agent.prompt_builder import steer_user_row
+
+ row = steer_user_row("fix the header too")
+ projected = _project_for_display([row])[0]
+
+ # Same words session.resume shows; the model-facing marker stays in the source.
+ assert projected["display_content"] == "fix the header too"
+ assert _history_to_messages([row])[0]["text"] == "fix the header too"
+ assert row["content"].startswith("[OUT-OF-BAND USER MESSAGE")
+
+
def test_history_applies_live_stripping_and_redaction_without_changing_raw_items(
monkeypatch,
):