mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-09-04 02:01:48 +03:00
fix(memory): ignore empty consolidation summaries
This commit is contained in:
@@ -873,7 +873,7 @@ class TestCompactIdleSession:
|
||||
async def test_nothing_summary_not_stored(
|
||||
self, real_consolidator, mock_provider, runtime
|
||||
):
|
||||
"""LLM returns '(nothing)' → _last_summary NOT in metadata."""
|
||||
"""LLM returns '(nothing)' → neither history nor metadata stores it."""
|
||||
mock_provider.chat_with_retry.return_value = MagicMock(
|
||||
content="(nothing)", finish_reason="stop"
|
||||
)
|
||||
@@ -891,6 +891,7 @@ class TestCompactIdleSession:
|
||||
|
||||
reloaded = sessions.get_or_create("cli:nothing")
|
||||
assert "_last_summary" not in reloaded.metadata
|
||||
assert real_consolidator.store.read_unprocessed_history(0) == []
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_llm_failure_preserves_history_but_advances_replay_boundary(
|
||||
|
||||
@@ -96,6 +96,17 @@ 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