The Per-Turn Procedure of MemoryOS

STM · recent turnsqueue of pages · FIFOoldest page spills · match scoreMTM · topic folderspages by topic · heat · evictheat > τ · promoteLPM · personauser · agentretrieveall three tiers → promptgenerateLLM → answer → new page
1retrieve2generate3store the new page4overflow to mid-term5heat · promote or evictSTM→ all pages in the queueMTMmatch score→ top-m = 5 foldersembedding sim→ top-k = 10 pagesNvisit += 1 · recency ← nowLPMembedding sim→ top-10 User KB entries→ top-10 Agent Traits+ all profiles and User TraitsLLM · query keywordsfor the keyword term of thematch score (≤ 3 keywords, code)LLM calls here: 1prompt =STM pages+MTM pagesLPM persona+queryLLM · final answerreply R"…don't forget the gym!"one generation callper turn, memory inlinedLLM calls here: 1new page {Q, R, T}query · reply · timestampLLM · link or reset?continues the last page'sthread? → join the chain,else start a new chainLLM · chain summarymeta ← summary of the chainpush to the STM queuecapacity 7LLM calls here: 2STM longer than 7 ?→ FIFO pop the oldest pageF = cos(emb) + Jaccard(kw)against every folder'ssummary and keyword setF > θ = 0.6 ?yes → join that folderLLM · summary + keywordsno → open a new folderthe page is its first memberLLM calls here: ≤ 1heat = Nvisit + Linteraction + Rrecencyα = β = γ = 1 · μ = 1e7 sheat > τ = 5 ?LLM · persona extraction→ User KB · User Traits→ Agent Traitsqueues of 100 · Linteraction ← 0folders > 2000 ?evict the coldest folderlowest heat leaves firstLLM calls here: ≤ 1next turnLLM callembedding / keywordsconstantevictionper response the paper measures 4.9 LLM calls and 3,874 recalled tokens on LoCoMo (Table 3)
19 / 25