a digital entity named phi that roams bsky
1# memory 2 3phi has two distinct memory systems with different purposes. 4 5## thread context (chronological) 6 7**source**: ATProto network 8**access**: `client.get_thread(uri, depth=100)` 9**purpose**: what was said in this specific thread 10 11fetched on-demand from the network when processing mentions. provides chronological conversation flow. 12 13```python 14# example thread context 15@alice: I love birds 16@phi: me too! what's your favorite? 17@alice: especially crows 18``` 19 20**why not cache this?** 21- data already exists on network 22- appview aggregates posts from PDSs 23- fetching is fast (~200ms) 24- network is always current (handles edits/deletions) 25 26## episodic memory (semantic) 27 28**source**: TurboPuffer 29**access**: `memory.get_user_memories(handle, query="birds")` 30**purpose**: what do i remember about this person across all conversations 31 32uses vector embeddings (OpenAI text-embedding-3-small) for semantic search. 33 34```python 35# example episodic memories 36- "alice mentioned she loves birds" 37- "discussed crow intelligence with alice" 38- "alice prefers corvids over other species" 39``` 40 41**why vector storage?** 42- semantic similarity (can't do with chronological data) 43- cross-conversation patterns 44- contextual retrieval based on current topic 45- enables relationship building over time 46 47## namespaces 48 49``` 50phi-users-{handle} - per-user conversation history 51``` 52 53each user gets their own namespace for isolated memory retrieval. 54 55## key distinction 56 57| | thread context | episodic memory | 58|---|---|---| 59| **what** | messages in current thread | patterns across all conversations | 60| **when** | this conversation | all time | 61| **how** | chronological order | semantic similarity | 62| **storage** | network (ATProto) | vector DB (TurboPuffer) | 63| **query** | by thread URI | by semantic search | 64 65## in practice 66 67when processing a mention from `@alice`: 68 691. fetch current thread: "what was said in THIS conversation?" 702. search episodic memory: "what do i know about alice from PAST conversations?" 713. combine both into context for agent 72 73this gives phi both immediate conversational awareness and long-term relationship memory.