mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-08-01 19:18:35 -04:00
Merge verified Odysseus fixes
This commit is contained in:
@@ -80,7 +80,7 @@ async def test_consolidate_memory_empty_owner_treats_each_owner_separately(monke
|
||||
message, ok = await action_consolidate_memory("")
|
||||
|
||||
assert ok is True
|
||||
assert "removed 1" in message
|
||||
assert "removed 1" in message.lower()
|
||||
assert len(prompts) == 2
|
||||
saved = {m["id"]: m for m in _read_memories(data_dir)}
|
||||
assert set(saved) == {"alice-long", "alice-short", "bob-keep"}
|
||||
@@ -114,3 +114,46 @@ async def test_consolidate_memory_specific_owner_does_not_absorb_ownerless_rows(
|
||||
assert set(saved) == {"alice-1", "legacy", "bob-1"}
|
||||
assert "owner" not in saved["legacy"]
|
||||
assert saved["bob-1"]["owner"] == "bob"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_consolidate_memory_removes_near_duplicates_before_ai(monkeypatch, tmp_path):
|
||||
from src import constants
|
||||
from src import llm_core
|
||||
from src import task_endpoint
|
||||
action_consolidate_memory = _import_consolidate_action()
|
||||
|
||||
data_dir = _write_memories(
|
||||
tmp_path,
|
||||
[
|
||||
{"id": "a", "owner": "alice", "text": "User prefers bullet points when explaining.", "category": "preference"},
|
||||
{"id": "b", "owner": "alice", "text": "User prefers bulletpoints when explaining", "category": "preference", "pinned": True},
|
||||
{"id": "c", "owner": "alice", "text": "User likes local models.", "category": "preference"},
|
||||
],
|
||||
)
|
||||
monkeypatch.setattr(constants, "DATA_DIR", str(data_dir))
|
||||
monkeypatch.setattr(
|
||||
task_endpoint,
|
||||
"resolve_task_candidates",
|
||||
lambda *args, **kwargs: [("http://llm", "model", {})],
|
||||
)
|
||||
|
||||
async def fake_llm_call_async(_candidates, **kwargs):
|
||||
items = json.loads(kwargs["messages"][0]["content"].split("MEMORIES:\n", 1)[1])
|
||||
return json.dumps({
|
||||
"keep": [
|
||||
{"id": item["id"], "text": item["text"], "category": item["category"]}
|
||||
for item in items
|
||||
],
|
||||
"drop": [],
|
||||
})
|
||||
|
||||
monkeypatch.setattr(llm_core, "llm_call_async_with_fallback", fake_llm_call_async)
|
||||
|
||||
message, ok = await action_consolidate_memory("alice")
|
||||
|
||||
assert ok is True
|
||||
assert "removed 1" in message.lower()
|
||||
saved = {m["id"]: m for m in _read_memories(data_dir)}
|
||||
assert set(saved) == {"b", "c"}
|
||||
assert saved["b"]["pinned"] is True
|
||||
|
||||
Reference in New Issue
Block a user