fix(mem0-agent): non-blocking stdin, clean session_state, lint
Found by running the CLI live against a scratch project: - hook_input() blocked forever on an open stdin pipe with no data. A real hook writes JSON and closes the pipe, but any manual invocation hung; now polled with select() and never blocks. - the open-thread snapshot was filling with progress lines and file-modification lists -- v1's exact failure -- so it now filters turns through the same hard-drop rules the capture gate uses. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
4d5f2e653c
commit
ba1de5f87b
@@ -313,3 +313,26 @@ def test_full_session_produces_few_memories(tmp_path):
|
||||
assert summary["sent"] >= 1
|
||||
for added in ctx.api.added:
|
||||
assert "epoch" not in added["messages"][0]["content"].lower()
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
# session_state quality
|
||||
# --------------------------------------------------------------------------
|
||||
def test_open_thread_excludes_mechanical_noise():
|
||||
"""v1's session summaries were file lists. The snapshot must carry intent instead."""
|
||||
turns = [
|
||||
{"role": "assistant", "content": HEARTBEAT, "tool_only": False},
|
||||
{"role": "user", "content": "Let's get the sandbox e2e suite passing today.", "tool_only": False},
|
||||
{"role": "user", "content": "ok", "tool_only": False},
|
||||
{"role": "assistant", "content": FILE_LIST, "tool_only": False},
|
||||
]
|
||||
thread = transcript.summarize_open_thread(turns)
|
||||
assert "sandbox e2e" in thread
|
||||
assert "VERSION" not in thread and "chat.py" not in thread
|
||||
assert "epoch" not in thread.lower()
|
||||
|
||||
|
||||
def test_open_thread_is_empty_when_there_is_only_noise():
|
||||
turns = [{"role": "assistant", "content": HEARTBEAT, "tool_only": False},
|
||||
{"role": "assistant", "content": FILE_LIST, "tool_only": False}]
|
||||
assert transcript.summarize_open_thread(turns) == ""
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
"""Consolidation must never lose data, and must never touch a pinned memory."""
|
||||
|
||||
import pytest
|
||||
|
||||
from mem0_agent import maintain
|
||||
from mem0_agent.maintain import jaccard, tokens
|
||||
|
||||
Reference in New Issue
Block a user