The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(web): unwrap stored steer rows in the REST transcript projection (#121978)
Brooklyn Nicholsonab341e771cd0
diff --git a/tests/hermes_cli/test_sessions_rest_scaffold_notices.py b/tests/hermes_cli/test_sessions_rest_scaffold_notices.pyindex 122b7d6ffc6..68ac0f659f8 100644--- a/tests/hermes_cli/test_sessions_rest_scaffold_notices.py+++ b/tests/hermes_cli/test_sessions_rest_scaffold_notices.py@@ -8,6 +8,11 @@ addresses VISIBLE user rows by durable row id — and a scaffold row can never rrewind/regenerate target (the gateway truncation resolver refuses it fail-closed), soshipping it as a user row dead-ends every retry. Typed notices (``model_switch``, …) mustkeep flowing: the Desktop renders them as timeline rows.++A stored ``role=user`` ``display_kind=steer`` row must ship the user's own words as+``display_content`` (the same unwrap ``session.resume`` applies) — marker-wrapped content+never pairs with the optimistic plain-text copy, so Desktop renders the correction twice+and reorders it (#121978)."""from hermes_cli.web_routers.sessions import _project_for_display@@ -68,3 +73,49 @@ def test_rest_projection_still_projects_compaction_summaries():assert len(projected) == 1# A pure handoff compacts to `hidden` — the pre-existing behavior this edit sits in.assert projected[0]["display_kind"] == "hidden"+++def test_rest_projection_unwraps_steer_rows_for_display():+ """A stored steer row displays the user's words, not the marker wrapper (#121978).++ The gateway's session.resume projection unwraps the model-facing steer markers; the+ REST projection must agree, or the persisted row ships marker-wrapped and never pairs+ with the optimistic plain-text copy Desktop already holds.+ """+ from agent.prompt_builder import STEER_MARKER_CLOSE, STEER_MARKER_OPEN++ steer_row = {+ "role": "user",+ "id": 21,+ "content": f"{STEER_MARKER_OPEN}\nfocus on the parser bug\n{STEER_MARKER_CLOSE}",+ "display_kind": "steer",+ "timestamp": 6.0,+ }+ plain_row = {"role": "user", "id": 22, "content": "unrelated text", "timestamp": 7.0}++ projected = _project_for_display([steer_row, plain_row])++ assert len(projected) == 2 # no row dropped: pagination offsets stay stable+ by_id = {message["id"]: message for message in projected}+ # The steer row ships its own words as display_content; the marker wrapper stays in+ # `content` for export/inspection consumers.+ assert by_id[21]["display_content"] == "focus on the parser bug"+ assert by_id[21]["content"] == steer_row["content"]+ assert by_id[21]["display_kind"] == "steer"+ # A plain user row is untouched — no display_content sidecar.+ assert "display_content" not in by_id[22]+ # Input rows are not mutated in place.+ assert "display_content" not in steer_row+++def test_rest_projection_keeps_steer_row_without_marker_as_is():+ """A steer row whose content lost the marker wrapper (legacy persistence) falls through+ to the normal path instead of emitting an empty display_content."""+ steer_row = {"role": "user", "id": 31, "content": "plain legacy text", "display_kind": "steer",+ "timestamp": 8.0}++ projected = _project_for_display([steer_row])++ assert len(projected) == 1+ assert "display_content" not in projected[0]+ assert projected[0]["content"] == "plain legacy text"