fix(memory): ignore malformed history entries (#4315)

This commit is contained in:
Stellar鱼
2026-06-15 15:13:07 +08:00
committed by GitHub
parent a54e56c69e
commit f85101f017
3 changed files with 54 additions and 1 deletions
+15
View File
@@ -87,6 +87,21 @@ class TestBuildDreamPrompt:
assert "entry-21" in next_prompt
assert "entry-25" in next_prompt
def test_skips_malformed_history_entries(self, store):
"""Dream prompt building should tolerate externally corrupted JSONL rows."""
store.history_file.write_text(
'{"cursor": 1, "timestamp": "2026-04-01 10:00"}\n'
'{"cursor": 2, "timestamp": "2026-04-01 10:01", "content": "usable memory"}\n',
encoding="utf-8",
)
result = store.build_dream_prompt()
assert result is not None
prompt, cursor = result
assert cursor == 2
assert "usable memory" in prompt
def test_dream_prompt_consumes_consolidator_attribute_tags(self):
prompt = render_template(
"agent/dream.md",