Factual retrieval
Preserve and retrieve explicit facts, values, and other localized details.
AGENT MEMORY / SELF-EVOLUTION
BEAM-1M
Over strongest baselineLongMemEval-M
Over strongest baselineTokens of history
Generalization to longer contexts01 / THE INSIGHT
Existing self-evolving memory methods revise a memory program using one overall score. But memory is multidimensional, and that score blurs what each revision actually achieved.
We derive five representative capabilities from a broad review of agent memory benchmarks and memory systems. Then we annotate every question with the one it primarily requires, plus up to two secondary ones. These labels only organize feedback during evolution and are never given to the memory program at test time.
Preserve and retrieve explicit facts, values, and other localized details.
Order events, determine recency, track states and knowledge updates.
Recover and apply user preferences, instructions and constraints.
Aggregate and synthesize evidence across multiple sessions or events.
Abstain when memory lacks supporting evidence, or cautiously resolve contradictory or misleading evidence.
02 / THE METHOD
PrisMem evolves an executable memory program in three stages: build a base, grow capability specialists, then integrate them.
ZOOM IN · STAGE II
Which capability to refine, and which of its failures to learn from.
CHOICE 1 · DEPENDENCY-AWARE SELECTION
urgency = own error + strongest pressure on another capability1 + times already picked
A capability is chosen because it is weak itself, or because it holds another capability back. Each past pick lowers its priority, so plateaued capabilities step aside: here T wins although M has the larger raw urgency (dashed).
CHOICE 2 · HISTORY-GUIDED DIAGNOSIS
priority = how well earlier programs answered ittimes it, or a similar case, was already picked
A case that used to be solved and now fails shows exactly what a recent revision broke. Discounting repeats keeps the five cases diverse.
Schematic diagrams with illustrative values. They show the idea behind the two selection rules (Eqs. 1–7 in the paper).
ZOOM IN · STAGE III
Paired differential cases show where programs behave differently; the integration plan decides what to carry over.
EVIDENCE · PAIRED DIFFERENTIAL CASES
Specialist wins → bring in. Base P17 wins → protect.
PLAN · LINEAGE-ORDERED INTEGRATION
While contrasting cases serve as diagnostic indicators targeting specific program components, the plan leverages these insights to localize code modules and formulate a step-by-step integration strategy.
03 / LIVE DEMO
One real 20-round run on BEAM, replayed step by step: which program was revised, what failed, and what changed.
04 / THE EXPERIMENTAL RESULTS
3 runs · Bars show means · whiskers show ±1 standard deviation.
% · higher is better
lower is better
PrisMem leads all five capability metrics on BEAM-1M and improves Overall by 11.53 pp over the strongest static baseline (10.54 pp over the strongest self-evolving baseline), while using fewer tokens per question than Mem0, A-MEM, and HippoRAG2.
% · higher is better
lower is better
% · higher is better
lower is better
PrisMem leads or ties four of five capability metrics on LongMemEval-M, improves Overall by 7.83 pp over the strongest baseline, EvolveMem, and uses fewer tokens per question than EvolveMem.
Capability scores on BEAM · dashed: best ever reached · solid: final program
PrisMem reaches further than holistic evolution on every capability, and its final program closely matches its peaks.
Overall score lost when a component is removed (pp) · BEAM-1M · full PrisMem: 63.39
Removing capability-driven evolution yields the largest drop by blurring potential optimization directions when focusing solely on overall performance. Meanwhile, substituting with random case selection, omitting trace-guided integration, and simplifying to round-robin target selection degrade results by removing informative failure feedback, program fusion, and priority targeting.
Evolve withQwen3.8-27Bfrozen programRun withGPT-5.5
Evolve onBEAM-100Kfrozen programRun onLongMemEval-M
These results show that the evolved memory programs maintain strong performance even when transferred to different models and datasets without additional program optimization, demonstrating the robustness and generalizability of the capability-driven evolution approach.
Capability-best programs come from the same PrisMem evolution run
ROUTING
Overall score (%) ↑ · Qwen3.8-27B on BEAM-1M · mean ± std · Table 12 · y-axis starts at 50
In contrast, trace-guided integration combines complementary mechanisms within a shared program and reconciles their conditions of use, resulting in stronger overall performance. These results support the value of integrating useful capability-specific revisions into a shared memory program.
Evolution starts from the same seed program (left). On the right is the final program PrisMem evolved from it.
from dataclasses import dataclass, field MemoryExtractionInstruction = "Extract the key information from the text into several memory units."QueryPlanningInstruction = "Given the following question, generate a query to retrieve relevant memory."AnswerInstruction = "Based on the retrieved memory and the original question, provide a short answer without explanation." @dataclassclass MemoryUnit: memory_text: str = field( metadata={"description": "One piece of information worth remembering from the text"} ) @dataclassclass Query: query_text: str = field( metadata={"description": "A query for retrieving information relevant to the question"} ) class Memory: def __init__(self, backend): self.backend = backend self.memories: list[str] = [] def index(self, units: list[MemoryUnit], raw_text: str) -> None: self.memories.extend(unit.memory_text for unit in units) def retrieve(self, query: Query) -> str: return "\n\n".join(self.memories)[:OUT_CHAR_BUDGET]import reimport numpy as npfrom dataclasses import dataclass, field MemoryExtractionInstruction = ( "Extract distinct atomic facts, decisions, preferences, " "instructions, and temporal events from the text. " "Resolve pronouns and references to full names. Preserve " "exact values, names, dates, times, and lists verbatim. " "If the text contains a user preference or standing " "instruction, capture it explicitly as its own memory " "unit. For cross-cutting preferences or standing " "instructions that apply broadly regardless of the " "specific topic or project (e.g. 'always format code " "with syntax highlighting', 'prefer minimal " "dependencies', 'always compare multiple solution " "methods'), set standing_preference to True. For " "preferences tied to a specific project, feature, or " "domain (e.g. 'prefers Bootstrap for this website'), set " "standing_preference to False. Capture any " "contradictions or updates to previously stated facts. " "For each fact, assign a concise topic identifier " "(entity+thread in lowercase hyphenated form, e.g. " "'weather-app-autocomplete', " "'greg-research-collaboration', " "'triangle-classification-progress') that groups all " "related facts about the same ongoing thread, project, " "or person across sessions. Set session_date to the " "current conversation session date in YYYY-MM-DD format " "(the date the user discussed the topic in chat, NOT any " "project or schedule date in the content).") QueryPlanningInstruction = ( "Given the question, decompose it into one or more " "retrieval sub-queries. For single-topic questions, " "provide exactly one sub-query. For multi-aspect, " "synthesis, or multi-part questions, provide one " "sub-query per distinct topic or aspect so that all " "relevant evidence scattered across sessions is " "retrieved independently. Each sub-query should be " "concise and contain the key entities, specific time " "references, and the particular aspect being asked " "about. For temporal questions include relevant date or " "event words. For preference or instruction questions " "include the domain and the type of constraint. For " "existence or experience questions (e.g. 'Have I ever " "done X', 'Have I completed X', 'Did I do X before', " "'Have I used X'), include an additional sub-query " "targeting negation or absence (e.g. 'never X', 'not " "done X before', 'no prior experience with X', 'has not " "attempted X') so that explicit denial or inexperience " "statements are retrieved with equal prominence " "alongside affirmative evidence.") AnswerInstruction = ( "Based on the retrieved memory context and the original " "question, provide a concise and accurate answer. Each " "entry is prefixed with [YYYY-MM-DD] showing the session " "date when the user discussed that topic. For questions " "about the order or sequence in which the user raised " "topics, use these session-date prefixes to determine " "chronological order. Distinguish statement time (the " "[YYYY-MM-DD] prefix) from event time (dates within the " "entry text, e.g. project schedules). For synthesis or " "summary questions, group entries by topic and present a " "unified chronological narrative of how the user's " "project or understanding progressed, describing how " "earlier sessions set the stage for later developments. " "For count or total questions about progress across " "sessions, sum values reported in separate distinct " "events (e.g. 'completed 10' in one session then " "'completed 15' in a later session = 25 total); use the " "latest value only when entries track a single running " "total. However, if two values appear to be " "contradictory statements about the same quantity in the " "same session or context, do NOT sum them-surface the " "contradiction instead. If the context contains " "contradictory information, explicitly surface the " "contradiction and note the conflicting details. If the " "context does not contain sufficient information to " "answer, state that clearly rather than guessing. If any " "retrieved entry states a user preference or standing " "instruction (e.g., 'always include...', 'I prefer...', " "'make sure to...'), you MUST apply that constraint to " "the structure and content of your answer-not merely " "acknowledge it. If a [Standing Preferences] section " "appears in the retrieved context, apply every " "preference listed there. CRITICAL for existence or " "experience questions (e.g. 'Have I ever X', 'Did I do " "X', 'Have I completed X before'): if the retrieved " "context contains BOTH affirmative evidence that the " "user did, completed, or used X AND explicit statements " "that the user never did X, has not done X, or has no " "prior X, your answer MUST lead with the contradiction. " "Present both the affirmative evidence and the negation " "statement explicitly, briefly quote or paraphrase each, " "and ask the user to clarify which is correct. Do NOT " "resolve the contradiction by picking one side, " "dismissing one as outdated, or explaining away the " "other.") @dataclassclass MemoryUnit: memory_text: str = field( metadata={"description": "One atomic piece of information worth remembering: a fact, event, preference, decision, or instruction. Include specific names, values, and dates."} ) session_date: str = field( default="", metadata={"description": "The conversation session date in YYYY-MM-DD format. This is the date of the current chat session, not any project or schedule date mentioned in the content."} ) topic: str = field( default="", metadata={"description": "A concise topic identifier in lowercase-hyphenated form (entity+thread) grouping related facts across sessions. Examples: 'weather-app-autocomplete', 'triangle-classification-progress', 'portfolio-website-sprint-1'. Use 'general' if no clear thread."} ) standing_preference: bool = field( default=False, metadata={"description": "True ONLY for cross-cutting user preferences or standing instructions that apply broadly regardless of topic (e.g. 'always use tree diagrams for probability', 'prefer minimal dependencies'). False for topic-specific facts or one-off requests."} ) @dataclassclass Query: query_texts: list[str] = field( metadata={"description": "A list of retrieval sub-queries. Each sub-query targets one distinct topic or aspect. For single-topic questions use one entry. For multi-aspect or synthesis questions, decompose into one sub-query per distinct topic so that all relevant evidence is retrieved. Each should contain key entities, time references, and the specific aspect being asked about."} ) class Memory: def __init__(self, backend): self.backend = backend self.memories: list[str] = [] self.embeddings: list[np.ndarray] = [] self.session_dates: list[str] = [] self.topics: list[str] = [] self.standing_prefs: list[str] = [] self.topic_to_indices: dict[str, list[int]] = {} _STOP = frozenset( "the a an is are was were in on at to for of and or but if how what when where who which did do does have has had i my me you your we our they their it its this that with from by as be been being am will would can could should may might shall not no yes any all each every some there here so than too very just also only own same out up down over under again further then once your you my me i we they he she it its his her their our your mine yours his hers ours theirs".split() ) @staticmethod def _parse_session_date(raw_text: str) -> str: header = raw_text[:500] m = re.search(r'(\d{4})-(\d{2})-(\d{2})', header) if m: return f"{m.group(1)}-{m.group(2)}-{m.group(3)}" m = re.search(r'(\d{1,2})/(\d{1,2})/(\d{4})', header) if m: return f"{m.group(3)}-{int(m.group(1)):02d}-{int(m.group(2)):02d}" return "" @staticmethod def _content_tokens(text: str) -> set[str]: return {t for t in re.findall(r"\b\w+\b", text.lower()) if t not in Memory._STOP and len(t) > 1} @staticmethod def _normalize_topic(topic: str) -> str: return re.sub(r'[^a-z0-9]+', '-', topic.lower()).strip('-') or "general" def _topic_tokens(self, topic: str) -> set[str]: normalized = self._normalize_topic(topic) parts = set(normalized.split('-')) parts.add(normalized) return {t for t in parts if len(t) > 2} def index(self, units: list[MemoryUnit], raw_text: str) -> None: if not units: return parsed_date = self._parse_session_date(raw_text) texts = [u.memory_text for u in units] embs = self.backend.embed(texts) for i, u in enumerate(units): sd = getattr(u, 'session_date', '') or parsed_date topic = getattr(u, 'topic', '') or '' sp = getattr(u, 'standing_preference', False) self.memories.append(texts[i]) self.embeddings.append(embs[i]) self.session_dates.append(sd) self.topics.append(topic) norm_topic = self._normalize_topic(topic) if norm_topic not in self.topic_to_indices: self.topic_to_indices[norm_topic] = [] self.topic_to_indices[norm_topic].append(i) if sp and texts[i] not in self.standing_prefs: self.standing_prefs.append(texts[i]) def retrieve(self, query: Query) -> str: if not self.memories: return "" sub_queries = query.query_texts if not sub_queries: return "" # Build standing preferences block standing_prefs_block = "" if self.standing_prefs: prefs_lines = [f"- {p}" for p in self.standing_prefs] standing_prefs_block = "[Standing Preferences]\n" + "\n".join(prefs_lines) if len(standing_prefs_block) > 400: standing_prefs_block = standing_prefs_block[:400] standing_overhead = (len(standing_prefs_block) + 4) if standing_prefs_block else 0 main_budget = OUT_CHAR_BUDGET - standing_overhead if main_budget < 800: main_budget = OUT_CHAR_BUDGET standing_overhead = 0 standing_prefs_block = "" n = len(sub_queries) per_query_budget = main_budget // n all_embs = np.stack(self.embeddings) seen_texts: set[str] = set() selected: list[tuple[float, str, str]] = [] # (score, session_date, text) for sq in sub_queries: query_emb = self.backend.embed([sq])[0] cos_scores = all_embs @ query_emb q_tokens = self._content_tokens(sq) kw_scores = np.zeros(len(self.memories), dtype=np.float64) if q_tokens: for i, txt in enumerate(self.memories): t_tokens = self._content_tokens(txt) kw_scores[i] = len(q_tokens & t_tokens) / len(q_tokens) # Topic boost topic_boost = np.zeros(len(self.memories), dtype=np.float64) if q_tokens: for topic, indices in self.topic_to_indices.items(): t_toks = self._topic_tokens(topic) if not t_toks: continue overlap = q_tokens & t_toks if len(overlap) >= 2: for idx in indices: topic_boost[idx] = 0.05 elif len(overlap) == 1: for tok in overlap: if len(tok) > 4: for idx in indices: topic_boost[idx] = 0.05 break scores = 0.7 * cos_scores + 0.3 * kw_scores + topic_boost order = np.argsort(-scores) used = 0 for idx in order: idx = int(idx) txt = self.memories[idx] if txt in seen_texts: continue sd = self.session_dates[idx] if idx < len(self.session_dates) else "" prefix_len = len(sd) + 3 if sd else 0 cost = len(txt) + prefix_len + 2 if used + cost > per_query_budget: continue selected.append((float(scores[idx]), sd, txt)) seen_texts.add(txt) used += cost if not selected: return standing_prefs_block if standing_prefs_block else "" # Keep relevance order; format with date prefix for temporal context parts: list[str] = [] total = 0 for score, sd, txt in selected: prefix = f"[{sd}] " if sd else "" formatted = prefix + txt sep = "\n\n" if parts else "" if total + len(sep) + len(formatted) > main_budget: break parts.append(formatted) total += len(sep) + len(formatted) result = "\n\n".join(parts) if standing_prefs_block: result += "\n\n" + standing_prefs_block return result[:OUT_CHAR_BUDGET]from dataclasses import dataclass, field MemoryExtractionInstruction = "Extract the key information from the text into several memory units."QueryPlanningInstruction = "Given the following question, generate a query to retrieve relevant memory."AnswerInstruction = "Based on the retrieved memory and the original question, provide a short answer without explanation." @dataclassclass MemoryUnit: memory_text: str = field( metadata={"description": "One piece of information worth remembering from the text"} ) @dataclassclass Query: query_text: str = field( metadata={"description": "A query for retrieving information relevant to the question"} ) class Memory: def __init__(self, backend): self.backend = backend self.memories: list[str] = [] def index(self, units: list[MemoryUnit], raw_text: str) -> None: self.memories.extend(unit.memory_text for unit in units) def retrieve(self, query: Query) -> str: return "\n\n".join(self.memories)[:OUT_CHAR_BUDGET]from dataclasses import dataclass, fieldimport numpy as np MemoryExtractionInstruction = ( "Extract distinct atomic facts, procedures, " "relationships, decisions, and preferences from the text " "into several memory units. Resolve pronouns and " "references to explicit entity names. Preserve exact " "names, numeric values, dates/times, and lists verbatim. " "For each unit, also set session_date to the ISO date " "(YYYY-MM-DD) of the conversation, taken from the " "timestamp in the conversation header.") QueryPlanningInstruction = ( "First, classify the question into one of these types: " "(A) preference/suggestion/advice/recommendation, (B) " "temporal/ordering/sequence, (C) factual retrieval with " "specific qualifiers, (D) multi-session synthesis or " "aggregate/count, (E) verification or potential " "abstention. Then write query_text tailored to that " "type. (A) For preference/suggestion/advice questions, " "do NOT write only a surface-topic query (e.g., " "'activities to do during commute'). Instead, construct " "a query that explicitly targets the user's stated " "preferences, interests, exclusions, constraints, and " "relevant personal history in the domain. Combine domain " "keywords from the question (e.g., 'commute', 'podcast', " "'listening', 'hotel') with preference-signal terms " "(e.g., 'user prefers', 'interested in', 'wants to " "explore', 'branch out', 'does not want', 'exclusion', " "'genre', 'specifically likes', 'personal history') so " "that memory units recording what the user likes, " "dislikes, wants to try next, and their background in " "that domain rank highest. (B) For temporal/ordering " "questions, include the specific entities and any time " "references so dated events are retrieved. (C) For " "factual retrieval, include exact entity names and ALL " "qualifying criteria from the question. (D) For " "multi-session synthesis or aggregate questions, name " "each distinct component or entity mentioned so evidence " "across sessions is retrieved. (E) For verification or " "abstention questions, include the specific role, title, " "or condition named in the question to confirm whether " "it exists. Keep the query concise but information-dense.") AnswerInstruction = ( "First, identify the question type and follow the " "corresponding strategy. Then answer using ONLY the " "retrieved memory text.\n\n=== RECOMMENDATION / " "SUGGESTION / ADVICE / OPINION QUESTIONS (HIGHEST " "PRIORITY) ===\nIf the question asks for a " "recommendation, suggestion, advice, or opinion (e.g., " "'recommend resources', 'what should I try', 'should I " "attend X', 'what would be good for me', 'do you think " "it would be a good idea', 'what should I do', 'any tips " "or ideas'):\n- The user's stated preferences, " "interests, skill level, software/tools they use, " "exclusions, and personal history found in the retrieved " "memory ARE the answer. You MUST generate a concrete " "recommendation or suggestion explicitly shaped by those " "preferences.\n- It is NEVER correct to answer " "'information not available', 'no specific resources " "found', or 'the specific information is not available' " "when the retrieved memory contains ANY domain " "preference, interest, tool, or relevant personal " "context for the user. The preference itself IS the " "useful information. Do not treat the user's preferences " "as 'similar but different facts' to be rejected.\n- " "Example: If asked to recommend video editing learning " "resources and the memory says the user enjoys Adobe " "Premiere Pro and wants to learn advanced settings, the " "answer must recommend Adobe Premiere Pro advanced " "tutorials or resources, NOT say 'no specific resources " "are available.'\n- Enumerate every explicitly stated " "preference, constraint, exclusion, and relevant " "personal fact from the retrieved memory. A preference " "stored without an explicit location, date, or occasion " "scope is a GENERAL preference that applies to any " "suggestion in the same domain. Apply all as binding " "constraints. Generate suggestions that respect all " "listed constraints, explicitly note exclusions, and " "reference the user's personal history as supporting " "evidence. Never ignore a stated exclusion.\n\n=== " "TEMPORAL / ORDERING / DURATION / 'HOW MANY DAYS OR " "WEEKS' QUESTIONS ===\n- The [YYYY-MM-DD] prefix on each " "memory line IS the date of the event or conversation " "that produced that memory. Treat it as the event date " "for that fact. Use these dates to compute differences.\n" "- When the question asks for a duration, difference, or " "ordering between two or more events, identify the " "[YYYY-MM-DD] date for each event from the retrieved " "memory, then compute the exact numerical difference in " "days (or convert to weeks if the question asks for " "weeks). Show the calculation briefly.\n- Example: If " "one event is dated [2023-03-17] and another is dated " "[2023-04-23], the difference is 37 days. State the " "exact number.\n- For ordering questions, sort all dated " "events chronologically by their [YYYY-MM-DD] prefix and " "present the ordered list using exact entity names as " "written in the memory.\n\n=== FACTUAL RETRIEVAL WITH " "SPECIFIC QUALIFIERS ===\n- When the question contains " "multiple qualifying criteria, select the single memory " "fact that satisfies ALL of them. Do not pick a " "partially matching fact.\n- Exactness: Reproduce entity " "names, dates, times, and numeric values exactly as they " "appear in the retrieved memory. Never paraphrase or " "approximate. For example, use 'Modern Art Museum' not " "'Modern Art Gallery'.\n- Near-miss/abstention: If the " "retrieved memory mentions a similar but different fact " "than what the question specifically asks about, do NOT " "substitute it. State that the specific information is " "not available. For instance, if asked about an " "'undergrad course research project' poster but the " "memory only records a 'thesis research' poster, answer " "that the specific information is not available. This " "rule does NOT apply to recommendation or suggestion " "questions covered above.\n\n=== MULTI-SESSION SYNTHESIS " "/ AGGREGATE / COUNT / SUM QUESTIONS ===\n- Identify " "EVERY relevant numeric value or duration across all " "retrieved memory units and sum or count them to produce " "a single final answer.\n- Include values that refer to " "the same entity but represent distinct occurrences " "(e.g., the same game played on two different " "difficulties counts as two separate values).\n- " "Example: If asked for the total weeks to complete two " "activities, and memory shows 2 weeks for one and 1.5 " "weeks for the other, the answer is 3.5 weeks, not two " "separate answers.\n\n=== VERIFICATION / ABSTENTION " "QUESTIONS ===\n- Include the specific role, title, or " "condition named in the question to confirm whether it " "exists in the retrieved memory.\n- If the retrieved " "memory does not contain the specific information asked " "about, state clearly that it is not available. Do not " "substitute a similar fact.\n\n=== GENERAL RULES (apply " "to all types) ===\n- Keep the answer concise. Do not " "add information not present in the retrieved memory.\n- " "Use exact entity names, dates, and values as written in " "the retrieved memory.") @dataclassclass MemoryUnit: memory_text: str = field( metadata={"description": "One piece of information worth remembering from the text"} ) session_date: str = field( default="", metadata={"description": "The ISO date (YYYY-MM-DD) of the session from which this memory was extracted, taken from the conversation timestamp"} ) @dataclassclass Query: query_text: str = field( metadata={"description": "A query for retrieving information relevant to the question"} ) class Memory: def __init__(self, backend): self.backend = backend self.memories: list[str] = [] self.embeddings: list[np.ndarray] = [] self.session_dates: list[str] = [] def index(self, units: list[MemoryUnit], raw_text: str) -> None: texts = [unit.memory_text for unit in units] dates = [unit.session_date for unit in units] if texts: vecs = self.backend.embed(texts) self.memories.extend(texts) self.session_dates.extend(dates) self.embeddings.extend(list(vecs)) def retrieve(self, query: Query) -> str: if not self.memories: return "" q_vec = self.backend.embed([query.query_text])[0] all_vecs = np.stack(self.embeddings) scores = all_vecs @ q_vec sorted_indices = np.argsort(-scores) selected: list[str] = [] total_chars = 0 MIN_SIMILARITY = 0.25 for idx in sorted_indices: if scores[idx] < MIN_SIMILARITY: break text = self.memories[idx] date = self.session_dates[idx] tagged = f"[{date}] {text}" if date else text extra = len(tagged) + (2 if selected else 0) if total_chars + extra > OUT_CHAR_BUDGET: continue selected.append(tagged) total_chars += extra return "\n\n".join(selected)05 / CITE
@misc{chen2026prismem,
title = {Capability-Driven Self-Evolution of Agent Memory},
author = {Chen, Yaoqi and Feng, Yuru and Zhang, Qianxi and Lu, Baotong and Lu, Jianan and Wang, Zhirui and Xu, Shusen and Jin, Zewen and Li, Zengzhong and Li, Cheng and Chen, Qi},
year = {2026},
eprint = {2610.06361},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/2610.06361}
}