personal memory agent
1# SPDX-License-Identifier: AGPL-3.0-only
2# Copyright (c) 2026 sol pbc
3
4from solstone.convey.sol_initiated.copy import (
5 CATEGORIES,
6 KIND_SOL_CHAT_REQUEST,
7 TRIGGER_LABEL_SOL_INITIATED,
8)
9from solstone.talent import chat_context
10
11
12def test_pre_hook_sets_template_vars_for_sol_request(monkeypatch, tmp_path) -> None:
13 monkeypatch.setenv("SOLSTONE_JOURNAL", str(tmp_path))
14 since_ts = 1_775_000_000_000
15
16 result = chat_context.pre_process(
17 {
18 "day": "20260331",
19 "trigger": {
20 "type": KIND_SOL_CHAT_REQUEST,
21 "summary": "Notice this",
22 "message": "Here is why.",
23 "category": CATEGORIES[0],
24 "since_ts": since_ts,
25 "trigger_talent": "reflection",
26 "request_id": "req",
27 },
28 }
29 )
30
31 template_vars = result["template_vars"]
32 assert template_vars["trigger_kind"] == TRIGGER_LABEL_SOL_INITIATED
33 assert template_vars["summary"] == "Notice this"
34 assert template_vars["message"] == "Here is why."
35 assert template_vars["category"] == CATEGORIES[0]
36 assert template_vars["since_ts"] == since_ts
37 assert template_vars["trigger_talent"] == "reflection"
38 assert f"Type: {TRIGGER_LABEL_SOL_INITIATED}" in template_vars["trigger_context"]
39 assert "Summary: Notice this" in template_vars["trigger_context"]
40 assert "Since ts: 1775000000000" in template_vars["trigger_context"]
41
42
43def test_existing_trigger_kind_labels_remain(monkeypatch, tmp_path) -> None:
44 monkeypatch.setenv("SOLSTONE_JOURNAL", str(tmp_path))
45
46 owner = chat_context.pre_process(
47 {
48 "prompt": "hello",
49 "trigger": {"type": "owner_message", "message": "hello"},
50 }
51 )
52 finished = chat_context.pre_process(
53 {
54 "trigger": {
55 "type": "talent_finished",
56 "name": "exec",
57 "summary": "done",
58 }
59 }
60 )
61
62 assert owner["template_vars"]["trigger_kind"] == "owner_message"
63 assert finished["template_vars"]["trigger_kind"] == "talent_finished"