From d52d6c96220aeb5c249f9fc587d6b8451fdc9ea0 Mon Sep 17 00:00:00 2001 From: shafdev <96260000+shafdev@users.noreply.github.com> Date: Mon, 13 Apr 2026 02:53:52 +0530 Subject: [PATCH] fix: store full AI response in convo_miner exchange chunking (#695) --- mempalace/convo_miner.py | 2 +- tests/test_convo_miner_unit.py | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/mempalace/convo_miner.py b/mempalace/convo_miner.py index 3bb4a89..ce25d1e 100644 --- a/mempalace/convo_miner.py +++ b/mempalace/convo_miner.py @@ -70,7 +70,7 @@ def _chunk_by_exchange(lines: list) -> list: ai_lines.append(next_line.strip()) i += 1 - ai_response = " ".join(ai_lines[:8]) + ai_response = " ".join(ai_lines) content = f"{user_turn}\n{ai_response}" if ai_response else user_turn if len(content.strip()) > MIN_CHUNK_SIZE: diff --git a/tests/test_convo_miner_unit.py b/tests/test_convo_miner_unit.py index 3c7e8f2..0811152 100644 --- a/tests/test_convo_miner_unit.py +++ b/tests/test_convo_miner_unit.py @@ -47,6 +47,17 @@ class TestChunkExchanges: # Too short to produce chunks (below MIN_CHUNK_SIZE) assert isinstance(chunks, list) + def test_long_ai_response_not_truncated(self): + """AI responses longer than 8 lines must be stored in full (verbatim principle).""" + lines = [f"Step {i}: important detail that must be stored" for i in range(1, 14)] + content = "> How do I implement authentication?\n" + "\n".join(lines) + chunks = chunk_exchanges(content) + assert len(chunks) >= 1 + stored = chunks[0]["content"] + # All 13 lines must be present — none silently dropped + for i in range(1, 14): + assert f"Step {i}:" in stored, f"Step {i} was truncated and not stored" + class TestDetectConvoRoom: def test_technical_room(self):