Spaces:
Sleeping
Sleeping
Commit ·
2c52edf
1
Parent(s): 8c5bc54
feat: recall claims the richest memory, not the oldest
Browse filesshould_recall now returns the longest unclaimed memory (ties -> oldest)
so Hollow reclaims a vivid, detailed memory instead of a thin one like
'had a grandmother'. Detail is what lands the recall 'wow'. 33 tests.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- memory.py +7 -2
- tests/test_memory.py +16 -1
memory.py
CHANGED
|
@@ -39,11 +39,16 @@ def should_recall(state: dict) -> tuple[bool, str | None]:
|
|
| 39 |
if not unclaimed:
|
| 40 |
return False, None
|
| 41 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
last = state.get("last_recall_turn")
|
| 43 |
if last is None:
|
| 44 |
-
return True,
|
| 45 |
|
| 46 |
if state["turn"] - last >= 3:
|
| 47 |
-
return True,
|
| 48 |
|
| 49 |
return False, None
|
|
|
|
| 39 |
if not unclaimed:
|
| 40 |
return False, None
|
| 41 |
|
| 42 |
+
# Claim the richest (longest, most evocative) memory, not the oldest —
|
| 43 |
+
# a thin "had a grandmother" makes a weak recall; detail lands the "wow".
|
| 44 |
+
# Ties resolve to the oldest (max keeps the first of equal-length items).
|
| 45 |
+
richest = max(unclaimed, key=len)
|
| 46 |
+
|
| 47 |
last = state.get("last_recall_turn")
|
| 48 |
if last is None:
|
| 49 |
+
return True, richest
|
| 50 |
|
| 51 |
if state["turn"] - last >= 3:
|
| 52 |
+
return True, richest
|
| 53 |
|
| 54 |
return False, None
|
tests/test_memory.py
CHANGED
|
@@ -112,7 +112,22 @@ class TestShouldRecall:
|
|
| 112 |
assert fired is True
|
| 113 |
assert mem == "has a dog named Nala"
|
| 114 |
|
| 115 |
-
def
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 116 |
state = self._state(
|
| 117 |
affinity=55,
|
| 118 |
treasure=["memory A", "memory B"],
|
|
|
|
| 112 |
assert fired is True
|
| 113 |
assert mem == "has a dog named Nala"
|
| 114 |
|
| 115 |
+
def test_recall_returns_richest_unclaimed(self):
|
| 116 |
+
state = self._state(
|
| 117 |
+
affinity=55,
|
| 118 |
+
treasure=[
|
| 119 |
+
"had a grandmother",
|
| 120 |
+
"had a red bicycle I loved more than anything, stolen, cried for days",
|
| 121 |
+
"kept bees",
|
| 122 |
+
],
|
| 123 |
+
claimed=[],
|
| 124 |
+
last_recall_turn=None,
|
| 125 |
+
)
|
| 126 |
+
fired, mem = should_recall(state)
|
| 127 |
+
assert fired is True
|
| 128 |
+
assert mem == "had a red bicycle I loved more than anything, stolen, cried for days"
|
| 129 |
+
|
| 130 |
+
def test_recall_tie_breaks_to_oldest_when_equal_length(self):
|
| 131 |
state = self._state(
|
| 132 |
affinity=55,
|
| 133 |
treasure=["memory A", "memory B"],
|