The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(memory): key the journey card lookups to the fingerprinted node id
rodricksz4h5c633cd87c548
diff --git a/agent/learning_graph_render.py b/agent/learning_graph_render.pyindex cc735abfc95..4ee7120016f 100644--- a/agent/learning_graph_render.py+++ b/agent/learning_graph_render.py@@ -11,6 +11,7 @@ from collections import Counterfrom datetime import datetime, timezonefrom typing import Any, Iterable, Optional+from agent.learning_graph import memory_node_idfrom hermes_time import safe_strftimeLEAD_IN = 0.06 # time-axis.ts LEAD_IN: the oldest node sits just off recency 0.@@ -260,7 +261,15 @@ def _build_chart_buckets(nodes: list[dict[str, Any]], rec: dict[str, Any], max_rdef _bucket_rows(buckets: list[_ChartBucket], payload: dict[str, Any]) -> list[dict[str, Any]]:cmap = category_color_map(payload)- memory_lookup = {f"memory:{card.get('source')}:{idx}": card for idx, card in enumerate(payload.get("memory", []) or []) if isinstance(card, dict)}+ # Keyed by BOTH id shapes: a node id carries the card's fingerprint (agent.learning_graph),+ # while a payload from an older graph — or one rendered from a cached response — has none.+ memory_lookup: dict[str, dict[str, Any]] = {}+ for idx, card in enumerate(payload.get("memory", []) or []):+ if not isinstance(card, dict):+ continue+ memory_lookup[f"memory:{card.get('source')}:{idx}"] = card+ if card.get("fingerprint"):+ memory_lookup[memory_node_id(card, idx)] = carddef node_row(node: dict[str, Any]) -> dict[str, Any]:card, memory = _node_card(node), memory_lookup.get(_node_id(node))diff --git a/apps/desktop/src/app/starmap/star-map.tsx b/apps/desktop/src/app/starmap/star-map.tsxindex 56af21912e4..20998fce06a 100644--- a/apps/desktop/src/app/starmap/star-map.tsx+++ b/apps/desktop/src/app/starmap/star-map.tsx@@ -229,7 +229,16 @@ export function StarMap({const memById = useMemo(() => {const m = new Map<string, MemoryCard>()- graph.memory.forEach((card, i) => m.set(`memory:${card.source}:${i}`, card))+ // A node id carries the card's fingerprint (agent.learning_graph.memory_node_id) so an edit+ // still names the card the user clicked after the list shifts. An imported or older graph+ // has no fingerprint, so key both shapes or the tooltip/body lookup misses every card.+ graph.memory.forEach((card, i) => {+ m.set(`memory:${card.source}:${i}`, card)++ if (card.fingerprint) {+ m.set(`memory:${card.source}:${i}:${card.fingerprint}`, card)+ }+ })return m}, [graph.memory])diff --git a/apps/desktop/src/types/hermes.ts b/apps/desktop/src/types/hermes.tsindex dba2785867c..df1122d9d88 100644--- a/apps/desktop/src/types/hermes.ts+++ b/apps/desktop/src/types/hermes.ts@@ -839,6 +839,9 @@ export interface StarmapMemoryCard {timestamp?: null | numbertitle: stringbody: string+ /** Digest of the card's text, carried in its node id so an edit names this card and not+ * whatever now sits at its index. Absent on an imported or pre-fingerprint graph. */+ fingerprint?: string}export interface StarmapGraph {diff --git a/hermes_cli/journey.py b/hermes_cli/journey.pyindex 0fba1c1efd1..685bb224e99 100644--- a/hermes_cli/journey.py+++ b/hermes_cli/journey.py@@ -364,12 +364,12 @@ def register_cli(parent: argparse.ArgumentParser) -> None:p_list.set_defaults(func=_cmd_list)p_del = sub.add_parser("delete", help="Delete a learned skill (archived) or memory by node id.")- p_del.add_argument("node", help="Node id (skill name or memory:<source>:<index>; see `journey list`).")+ p_del.add_argument("node", help="Node id (skill name, or a memory id exactly as `journey list` prints it).")p_del.add_argument("-y", "--yes", action="store_true", help="Skip the confirmation prompt.")p_del.set_defaults(func=_cmd_delete)p_edit = sub.add_parser("edit", help="Edit a learned skill or memory by node id in $EDITOR.")- p_edit.add_argument("node", help="Node id (skill name or memory:<source>:<index>; see `journey list`).")+ p_edit.add_argument("node", help="Node id (skill name, or a memory id exactly as `journey list` prints it).")p_edit.set_defaults(func=_cmd_edit)diff --git a/tests/agent/test_learning_graph_render.py b/tests/agent/test_learning_graph_render.pyindex e3ebaa928f5..1e2acfe6903 100644--- a/tests/agent/test_learning_graph_render.py+++ b/tests/agent/test_learning_graph_render.py@@ -125,9 +125,22 @@ def test_frames_play_through_grows_visibility():assert fr["grid"]+def test_memory_rows_carry_their_card_body_for_fingerprinted_ids(tmp_path, monkeypatch):+ """The chart looks a memory card up by node id. Node ids carry the card's fingerprint, so a+ lookup keyed on the bare `memory:<source>:<index>` shape would render every body empty."""+ monkeypatch.setenv("HERMES_HOME", str(tmp_path))+ import hermes_constants+ monkeypatch.setattr(hermes_constants, "_cached_default_hermes_root", None, raising=False)+ memories = tmp_path / "memories"+ memories.mkdir(parents=True)+ (memories / "MEMORY.md").write_text("alpha note\n§\nbeta note", encoding="utf-8")+ from agent.learning_graph import build_learning_graph+ from agent.learning_graph_render import render_frames+ payload = build_learning_graph()+ rows = [n for bucket in render_frames(payload, cols=80, rows=24, frames=1)["buckets"] for n in bucket["nodes"]]--+ assert [n["id"].count(":") for n in rows] == [3, 3]+ assert sorted(n["body"] for n in rows) == ["alpha note", "beta note"]diff --git a/tests/agent/test_learning_mutations.py b/tests/agent/test_learning_mutations.pyindex e257cecc701..86af8b7b4d6 100644--- a/tests/agent/test_learning_mutations.py+++ b/tests/agent/test_learning_mutations.py@@ -258,3 +258,28 @@ def test_an_id_from_an_older_graph_still_resolves_by_position(home):assert lm.edit_node("memory:memory:1", "beta rewritten")["ok"]assert _memory_entries(home) == ["alpha note\nline two", "beta rewritten"]+++def test_a_profile_card_resolves_through_its_fingerprinted_id(home):+ """USER.md cards sit after the MEMORY.md ones in the id's global index."""+ from agent.learning_graph import build_learning_graph++ profile = next(n for n in build_learning_graph()["nodes"] if n.get("memorySource") == "profile")++ assert lm.edit_node(profile["id"], "rewritten profile")["ok"]++ assert (home / "memories" / "USER.md").read_text(encoding="utf-8").strip() == "rewritten profile"+++def test_a_memory_longer_than_the_rendered_card_still_matches(home):+ """The card renders a truncated body; the fingerprint must digest the WHOLE entry or a long+ memory never matches itself."""+ from agent.learning_graph import build_learning_graph++ long_entry = "long memory " + ("x" * 2000)+ _write_memory_file(home, long_entry, "beta note")+ node = [n for n in build_learning_graph()["nodes"] if n["kind"] == "memory"][0]++ assert lm.node_detail(node["id"])["content"] == long_entry+ assert lm.edit_node(node["id"], "trimmed")["ok"]+ assert _memory_entries(home) == ["trimmed", "beta note"]diff --git a/website/docs/user-guide/features/memory.md b/website/docs/user-guide/features/memory.mdindex a07cca5f49c..dba1d42ae9a 100644--- a/website/docs/user-guide/features/memory.md+++ b/website/docs/user-guide/features/memory.md@@ -257,7 +257,7 @@ Beyond viewing, the journey is also where you **prune and correct** what Hermes| Command | What it does ||---------|--------------|-| `hermes journey list` | List node ids — skill names and `memory:<source>:<index>` ids for memory chunks. |+| `hermes journey list` | List node ids — skill names and `memory:<source>:<index>:<fingerprint>` ids for memory chunks (pass one back exactly as printed). || `hermes journey delete <node> [-y]` | Delete a node. Skills are **archived** (restorable), memory chunks are removed. `-y` skips the confirmation. || `hermes journey edit <node>` | Open the node's content (a skill's `SKILL.md` or the memory chunk) in `$EDITOR`. |