mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-08-31 00:03:01 +03:00
refactor(memory): guard empty summaries only on write
This commit is contained in:
@@ -431,11 +431,7 @@ class MemoryStore:
|
||||
unified_session: bool = False,
|
||||
) -> list[dict[str, Any]]:
|
||||
"""Return unprocessed history entries safe to inject into a turn prompt."""
|
||||
entries = [
|
||||
entry
|
||||
for entry in self.read_unprocessed_history(since_cursor=since_cursor)
|
||||
if str(entry.get("content", "")).strip() != "(nothing)"
|
||||
]
|
||||
entries = self.read_unprocessed_history(since_cursor=since_cursor)
|
||||
if session_key is None:
|
||||
return entries
|
||||
if not unified_session:
|
||||
|
||||
@@ -96,17 +96,6 @@ def test_unprocessed_history_injected_into_system_prompt(tmp_path) -> None:
|
||||
assert re.search(r"\[\d{4}-\d{2}-\d{2} \d{2}:\d{2}\]", prompt)
|
||||
|
||||
|
||||
def test_nothing_history_entry_is_not_injected(tmp_path) -> None:
|
||||
workspace = _make_workspace(tmp_path)
|
||||
builder = ContextBuilder(workspace)
|
||||
builder.memory.append_history("(nothing)")
|
||||
|
||||
prompt = builder.build_system_prompt()
|
||||
|
||||
assert "# Recent History" not in prompt
|
||||
assert "(nothing)" not in prompt
|
||||
|
||||
|
||||
def test_recent_history_injection_is_session_scoped(tmp_path) -> None:
|
||||
workspace = _make_workspace(tmp_path)
|
||||
builder = ContextBuilder(workspace)
|
||||
|
||||
Reference in New Issue
Block a user