personal memory agent
0
fork

Configure Feed

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

talent/chat: reframe internal follow-up context

Return identity grounding values from the chat context hook and rewrite the synthetic talent_finished message as internal follow-up context. Update the chat-context contract tests for cold-boot identity and the new follow-up wording.

+58 -4
+19 -2
talent/chat_context.py
··· 84 84 day = _resolve_day(context, trigger_payload) 85 85 template_vars = { 86 86 "digest_contents": "", 87 + "identity_self": "", 88 + "identity_agency": "", 87 89 "active_talents": "", 88 90 "trigger_context": "", 89 91 "location": "", ··· 98 100 logger.debug("Digest enrichment failed", exc_info=True) 99 101 100 102 try: 103 + template_vars["identity_self"] = _load_identity_contents("self.md") 104 + template_vars["identity_agency"] = _load_identity_contents("agency.md") 105 + except Exception: 106 + logger.debug("Identity enrichment failed", exc_info=True) 107 + 108 + try: 101 109 tail = read_chat_tail(day, limit=20) 102 110 messages: list[dict[str, str]] = [] 103 111 for event in tail: ··· 111 119 { 112 120 "role": "user", 113 121 "content": ( 114 - f"[talent {trigger_payload['name']} finished: " 115 - f"{trigger_payload['summary']}]" 122 + "[internal follow-up: talent " 123 + f"{trigger_payload['name']} finished. Use this result " 124 + "to answer the owner's pending request with a short " 125 + f"summary. Result: {trigger_payload['summary']}]" 116 126 ), 117 127 } 118 128 ) ··· 172 182 if not digest_path.exists(): 173 183 return "" 174 184 return digest_path.read_text(encoding="utf-8").strip() 185 + 186 + 187 + def _load_identity_contents(file_name: str) -> str: 188 + identity_path = Path(get_journal()) / "identity" / file_name 189 + if not identity_path.exists(): 190 + return "" 191 + return identity_path.read_text(encoding="utf-8").strip() 175 192 176 193 177 194 def _normalize_trigger(context: dict) -> tuple[str | None, dict[str, Any]]:
+39 -2
tests/test_chat_context.py
··· 9 9 from pathlib import Path 10 10 11 11 from convey.chat_stream import append_chat_event 12 + from think.identity import ensure_identity_directory 12 13 13 14 TEMPLATE_VAR_KEYS = { 14 15 "digest_contents", 16 + "identity_self", 17 + "identity_agency", 15 18 "active_talents", 16 19 "trigger_context", 17 20 "location", ··· 211 214 assert len(save_calls) == 1 212 215 213 216 214 - def test_chat_context_talent_finished_appends_final_user_message(monkeypatch, tmp_path): 217 + def test_chat_context_talent_finished_appends_internal_followup_message( 218 + monkeypatch, tmp_path 219 + ): 215 220 journal = tmp_path / "journal" 216 221 monkeypatch.setenv("_SOLSTONE_JOURNAL_OVERRIDE", str(journal)) 217 222 ··· 262 267 assert result["messages"] == [ 263 268 {"role": "user", "content": "What happened?"}, 264 269 {"role": "assistant", "content": "Looking into it."}, 265 - {"role": "user", "content": "[talent exec finished: Found the latest notes.]"}, 270 + { 271 + "role": "user", 272 + "content": ( 273 + "[internal follow-up: talent exec finished. Use this result " 274 + "to answer the owner's pending request with a short summary. " 275 + "Result: Found the latest notes.]" 276 + ), 277 + }, 266 278 ] 279 + 280 + 281 + def test_chat_context_includes_identity_grounding(monkeypatch, tmp_path): 282 + journal = tmp_path / "journal" 283 + monkeypatch.setenv("_SOLSTONE_JOURNAL_OVERRIDE", str(journal)) 284 + _write_journal_config(journal, {}) 285 + ensure_identity_directory() 286 + 287 + digest_seed = (journal / "identity" / "digest.md").read_text(encoding="utf-8") 288 + assert digest_seed == "not yet generated\n" 289 + 290 + monkeypatch.setattr("think.routines.get_routine_state", lambda: []) 291 + monkeypatch.setattr( 292 + "think.routines.get_config", 293 + lambda: {"_meta": {"suggestions_enabled": False, "suggestions": {}}}, 294 + ) 295 + monkeypatch.setattr("think.routines.save_config", lambda config: None) 296 + 297 + result = _load_chat_context_module().pre_process({"day": "20260420"}) 298 + 299 + template_vars = _assert_template_vars_result(result) 300 + assert template_vars["identity_self"] 301 + assert template_vars["identity_agency"] 302 + assert template_vars["identity_self"] != digest_seed.strip() 303 + assert template_vars["identity_agency"] != digest_seed.strip() 267 304 268 305 269 306 def test_chat_context_preserves_save_routines_config_side_effect(monkeypatch, tmp_path):