mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-06-15 17:25:26 -04:00
fix(tasks): read Memory.text in classify_events personal context (#3640)
The classify_events task pulled user memories to give the LLM personal context, but read `m.content`, which the Memory ORM does not have (the column is `text`). That raised AttributeError on the first row; the surrounding except swallowed it and logged at debug, so the personal-context block was silently always empty and events were classified without it. Extract the rendering into `_memory_context_lines` (reads `text`, robust via getattr, keeps the 200-char and 40-line caps) and raise the swallowed-exception log to warning so a future schema mismatch is visible. Adds tests/test_classify_events_memory_text.py for the field, truncation, blank skipping, missing-attr robustness, and the line cap.
This commit is contained in:
committed by
GitHub
parent
8bf8212846
commit
f5b91f1e9e
@@ -0,0 +1,33 @@
|
||||
"""classify_events must read the Memory `text` column, not a non-existent
|
||||
`content` attribute.
|
||||
|
||||
The previous inline loop did `m.content`, which raised AttributeError on the
|
||||
first Memory row; the surrounding except swallowed it, so the personal-context
|
||||
block the LLM relies on was always empty. The logic now lives in
|
||||
`_memory_context_lines`, which reads `text`.
|
||||
"""
|
||||
from src.builtin_actions import _memory_context_lines
|
||||
|
||||
|
||||
class _Mem:
|
||||
def __init__(self, text):
|
||||
self.text = text
|
||||
|
||||
|
||||
def test_uses_text_and_truncates_and_skips_blank():
|
||||
lines = _memory_context_lines([_Mem("Alice is my spouse"), _Mem(" "), _Mem("y" * 250)])
|
||||
assert lines[0] == "- Alice is my spouse"
|
||||
assert len(lines) == 2 # the blank row is skipped
|
||||
assert lines[1] == "- " + "y" * 200 # truncated to 200 chars
|
||||
|
||||
|
||||
def test_skips_rows_without_text_attribute():
|
||||
class _Bad: # mimics a schema where the attribute is absent
|
||||
pass
|
||||
|
||||
assert _memory_context_lines([_Bad(), _Mem("ok")]) == ["- ok"]
|
||||
|
||||
|
||||
def test_respects_limit():
|
||||
mems = [_Mem(f"memory {i}") for i in range(50)]
|
||||
assert len(_memory_context_lines(mems, limit=40)) == 40
|
||||
Reference in New Issue
Block a user