personal memory agent
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

refactor(chat_context): drop sol awareness injection

+42 -51
-15
talent/chat_context.py
··· 248 248 "recent_conversation": "", 249 249 "active_routines": "", 250 250 "routine_suggestion": "", 251 - "sol_awareness": "", 252 251 } 253 252 254 253 try: ··· 325 324 template_vars["routine_suggestion"] = hint 326 325 except Exception: 327 326 logger.debug("Routine suggestion eligibility check failed", exc_info=True) 328 - 329 - try: 330 - from pathlib import Path 331 - 332 - from think.utils import get_journal 333 - 334 - awareness_path = Path(get_journal()) / "sol" / "awareness.md" 335 - if awareness_path.exists(): 336 - content = awareness_path.read_text(encoding="utf-8") 337 - # Cold-start gating: don't inject placeholder content 338 - if content.strip() != "not yet updated": 339 - template_vars["sol_awareness"] = f"## Awareness\n\n{content}" 340 - except Exception: 341 - logger.debug("Awareness context loading failed", exc_info=True) 342 327 343 328 return {"template_vars": template_vars}
+42 -36
tests/test_chat_context.py
··· 1 1 # SPDX-License-Identifier: AGPL-3.0-only 2 2 # Copyright (c) 2026 sol pbc 3 3 4 + import importlib.util 4 5 from pathlib import Path 5 - 6 - from talent.chat_context import pre_process 7 6 8 7 TEMPLATE_VAR_KEYS = { 9 8 "recent_conversation", 10 9 "active_routines", 11 10 "routine_suggestion", 12 - "sol_awareness", 13 11 } 14 12 15 13 14 + def _load_chat_context_module(): 15 + path = Path(__file__).resolve().parents[1] / "talent" / "chat_context.py" 16 + spec = importlib.util.spec_from_file_location("test_chat_context_local", path) 17 + assert spec is not None 18 + assert spec.loader is not None 19 + module = importlib.util.module_from_spec(spec) 20 + spec.loader.exec_module(module) 21 + return module 22 + 23 + 16 24 def _assert_template_vars_result(result): 17 25 assert isinstance(result, dict) 18 26 assert "template_vars" in result ··· 41 49 talent="unified", 42 50 ) 43 51 44 - result = pre_process({"user_instruction": "Base instruction.", "facet": "work"}) 52 + result = _load_chat_context_module().pre_process( 53 + {"user_instruction": "Base instruction.", "facet": "work"} 54 + ) 45 55 46 56 template_vars = _assert_template_vars_result(result) 47 57 assert "## Recent Conversation" in template_vars["recent_conversation"] ··· 53 63 """Recent conversation is empty when no conversation history exists.""" 54 64 monkeypatch.setenv("_SOLSTONE_JOURNAL_OVERRIDE", str(tmp_path)) 55 65 56 - result = pre_process({"user_instruction": "Base instruction."}) 66 + result = _load_chat_context_module().pre_process( 67 + {"user_instruction": "Base instruction."} 68 + ) 57 69 58 70 template_vars = _assert_template_vars_result(result) 59 71 assert template_vars["recent_conversation"] == "" ··· 102 114 ) 103 115 monkeypatch.setattr("think.utils.get_journal", lambda: "/nonexistent") 104 116 105 - result = pre_process({"user_instruction": "Base instruction."}) 117 + result = _load_chat_context_module().pre_process( 118 + {"user_instruction": "Base instruction."} 119 + ) 106 120 107 121 template_vars = _assert_template_vars_result(result) 108 122 assert all(template_vars[key] == "" for key in TEMPLATE_VAR_KEYS) 109 123 110 124 111 - def test_chat_context_sol_awareness_injected(monkeypatch, tmp_path): 112 - """Sol awareness is injected when awareness.md has content.""" 113 - monkeypatch.setenv("_SOLSTONE_JOURNAL_OVERRIDE", str(tmp_path)) 125 + def test_chat_context_does_not_return_sol_awareness(monkeypatch): 126 + """sol_awareness is no longer part of the chat pre-hook output.""" 114 127 monkeypatch.setattr("think.conversation.build_memory_context", lambda **kw: "") 115 - 116 - sol_dir = tmp_path / "sol" 117 - sol_dir.mkdir() 118 - (sol_dir / "awareness.md").write_text( 119 - "as of: 2026-04-05T10:00:00\n\n## activity\n- focused on work\n" 128 + monkeypatch.setattr("think.routines.get_routine_state", lambda: []) 129 + monkeypatch.setattr( 130 + "think.routines.get_config", lambda: {"_meta": {"suggestions": {}}} 120 131 ) 121 - 122 - result = pre_process({"user_instruction": "Base instruction."}) 132 + monkeypatch.setattr( 133 + "think.utils.get_config", 134 + lambda: {"agent": {"name": "aria", "name_status": "default"}}, 135 + ) 123 136 124 - template_vars = _assert_template_vars_result(result) 125 - assert "## Awareness" in template_vars["sol_awareness"] 126 - assert "activity" in template_vars["sol_awareness"] 137 + result = _load_chat_context_module().pre_process( 138 + {"user_instruction": "Base instruction."} 139 + ) 127 140 128 - 129 - def test_chat_context_sol_awareness_cold_start(monkeypatch, tmp_path): 130 - """Sol awareness is empty when awareness.md has placeholder content.""" 131 - monkeypatch.setenv("_SOLSTONE_JOURNAL_OVERRIDE", str(tmp_path)) 132 - monkeypatch.setattr("think.conversation.build_memory_context", lambda **kw: "") 133 - 134 - sol_dir = tmp_path / "sol" 135 - sol_dir.mkdir() 136 - (sol_dir / "awareness.md").write_text("not yet updated\n") 137 - 138 - result = pre_process({"user_instruction": "Base instruction."}) 139 - 140 - template_vars = _assert_template_vars_result(result) 141 - assert template_vars["sol_awareness"] == "" 141 + assert "sol_awareness" not in result["template_vars"] 142 142 143 143 144 144 def test_chat_context_routines_injected(monkeypatch): ··· 158 158 ], 159 159 ) 160 160 161 - result = pre_process({"user_instruction": "Base instruction."}) 161 + result = _load_chat_context_module().pre_process( 162 + {"user_instruction": "Base instruction."} 163 + ) 162 164 163 165 template_vars = _assert_template_vars_result(result) 164 166 assert "## Active Routines" in template_vars["active_routines"] ··· 170 172 monkeypatch.setattr("think.conversation.build_memory_context", lambda **kw: "") 171 173 monkeypatch.setattr("think.routines.get_routine_state", lambda: []) 172 174 173 - result = pre_process({"user_instruction": "Base instruction."}) 175 + result = _load_chat_context_module().pre_process( 176 + {"user_instruction": "Base instruction."} 177 + ) 174 178 175 179 template_vars = _assert_template_vars_result(result) 176 180 assert template_vars["active_routines"] == "" ··· 191 195 lambda: {"agent": {"name": "aria", "name_status": "default"}}, 192 196 ) 193 197 194 - result = pre_process({"user_instruction": "Base instruction."}) 198 + result = _load_chat_context_module().pre_process( 199 + {"user_instruction": "Base instruction."} 200 + ) 195 201 196 202 template_vars = _assert_template_vars_result(result) 197 203 assert template_vars["active_routines"] == ""