feat(brain): keep how each answer was made (records, tools, plan, thinking, tool calls)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
javis-bot
2026-11-16 03:00:10 +09:00
parent 2a140d8490
commit a20ebe4eae
8 changed files with 265 additions and 8 deletions

View File

@@ -238,3 +238,26 @@ def test_chat_tool_reads_and_searches_one_channels_messages(store):
assert sorted(texts(store.search_chat(["c1", "c2"], "회의"))) == ["회의 취소", "회의는 3시"]
assert store.search_chat([], "회의") == []
assert store.chat_channel_of("m3") == "c2" and store.chat_channel_of("nope") is None
def test_how_an_answer_was_made_is_kept_per_person_and_never_searched(store):
steps = [{"kind": "tools", "names": ["getWeather"]},
{"kind": "tool", "name": "getWeather", "args": {"location": "서울"}, "ok": True, "result": "맑음"}]
store.add_trace("voice", VC, "a", "서울 날씨 어때", "맑습니다", steps, ms=1200, ts=T0)
store.add_trace("chat", CHAT, "b", "안녕", "", [], ms=50, ts=T0 + 1)
[t] = store.traces_of("a")
assert (t.via, t.channel_id, t.question, t.answer, t.ms, t.steps) == ("voice", VC, "서울 날씨 어때", "맑습니다", 1200, steps)
# A trace is no record: the brain never reads it back as history.
assert store.search("a", "날씨", scope=Scope()) == []
assert store.recent("a", T0 + 2, scope=Scope()) == []
store.forget_person("a")
assert store.traces_of("a") == [] and len(store.traces_of("b")) == 1
def test_traces_have_their_own_retention_and_follow_the_history_retention(store):
store.add_trace("voice", VC, "a", "옛 질문", "옛 답", [], ms=1, ts=T0)
store.add_trace("voice", VC, "a", "새 질문", "새 답", [], ms=1, ts=T0 + 100)
store.purge_traces_older_than(T0 + 50)
assert [t.question for t in store.traces_of("a")] == ["새 질문"]
store.purge_older_than(T0 + 200)
assert store.traces_of("a") == []