메뉴
HN
Hacker News 4일 전

AI 에이전트 기억 시스템의 구조와 원리

IMP
7/10
핵심 요약

현재 다수의 AI 에이전트 메모리 라이브러리들이 인지과학의 용어를 차용해 쓰고 있지만, 실제 엔지니어링 구현은 그 의미를 제대로 반영하지 못하고 있습니다. 이 글은 에이전트의 기억 시스템이 대화에서 정보를 추출하는 '추출기', 데이터를 저장하고 모순을 처리하는 '저장소', 필요한 정보를 검색하는 '검색기'라는 세 가지 핵심 구성 요소로 이루어져 있음을 설명합니다. 개발자들은 이 세 가지 구조의 동작 방식과 설계 선택(정보 압축, 모순 처리 등)을 이해함으로써 어떤 메모리 라이브러리든 평가하고 활용할 수 있습니다.

번역된 본문

모든 에이전트 메모리 라이브러리는 '에피소드 기억(episodic)', '의미 기억(semantic)', 때로는 '절차적 기억(procedural)'이라는 동일한 단어들을 사용합니다. 이는 인지과학의 어휘를 그대로 API로 가져온 것입니다. 하지만 그 이면의 엔지니어링은 함께 가져오지 않는 경우가 많습니다. 어떤 라이브러리는 의미 기억과 동일한 방식의 저장 및 검색 방식을 사용하면서 절차적 기억이라는 필드를 제공하기도 하는데, 이는 별개의 시스템이 아니라 단순한 레이블(이름표)에 불과합니다.

더 깊은 혼란의 원인은 '기억(memory)'이라는 단어 자체에 있습니다. 이 라이브러리들이 구축하는 대부분의 것은 단어가 암시하는 것보다 훨씬 좁은 개념이며, 이 좁은 의미의 단어를 사용하는 것이 문제를 더욱 뚜렷하게 만듭니다. 이 용어는 1972년 엔델 툴빙(Endel Tulving)의 챕터에서 유래했습니다. 그는 사람들이 하나의 것으로 취급하던 '기억'이 실제로는 적어도 두 가지, 즉 사건에 대한 기억(무슨 일이 있었는지, 어디서, 언제 일어났는지)과 사실에 대한 기억(프랑스의 수도, 물의 끓는점 등)이라고 주장했습니다. 그는 이를 각각 에피소드 기억과 의미 기억이라고 불렀습니다. 이 둘은 작동 방식도 다르고 실패하는 방식도 다릅니다.

이 라이브러리들이 '기억'이라고 부르는 대부분의 것은 단어가 암시하는 것보다 좁습니다. 즉, 완전한 인지적 기억 시스템이 아니라 사용자를 대신하여 보관되는 사용자에 대한 자서전적 콘텐츠(사용자가 어디에 사는지, 무엇을 작업 중인지, 무엇을 결정했는지 등)인 경우가 많습니다.

에이전트 메모리 시스템의 구조

에이전트 메모리 라이브러리는 소수의 핵심 구성 요소로 만들어집니다. 이 부분들을 알면 어떤 라이브러리의 문서든 이해할 수 있습니다.

1. 추출기 (The Extractor)

대화 기록을 읽고 무엇을 보관할지 결정하는 역할을 합니다. 보통 엄격한 프롬프트나 타입이 지정된 출력 스키마를 사용하는 LLM 호출입니다. 이것은 사용자, 세계 또는 작업에 대한 짧고 추상화된 사실인 '구문(statement)'을 생성합니다. 추출기가 내리는 가장 중요한 선택은 '타이밍'입니다. 모든 메시지 후에 즉시(eagerly) 추출하면 결론이 없는 일상적인 대화에 토큰을 낭비하게 됩니다. 반대로 세션이 끝날 때 지연해서(lazily) 추출하면 대명사가 누구를 가리키는지 파악하기 위해 필요했던 문맥이 이미 사라진 상태가 됩니다. 어느 타이밍도 틀린 것은 아니지만, 각각 다른 쪽이 유지하는 것을 잃게 됩니다. 라이브러리에 대해 던져야 할 질문은 '무엇이 버려지는가'입니다. 상호참조 단서(어떤 '그'가 어떤 사람을 지칭하는지), 시간적 닻('어제', '다음 주' 등), 모호함을 해소하는 국소적 문맥이 흔히 희생됩니다. 인지적 관점에서 볼 때 추출은 상황에 맞는 사건을 맥락이 제거된 사실로 압축하는 작업입니다. 예를 들어, '화요일에 커피를 마시면서 사용자가 TypeScript를 선호한다고 언급함'이 '사용자는 TypeScript를 선호함'으로 압축됩니다. 라이브러리가 얼마나 공격적으로 압축하는가는 핵심적인 설계 결정 중 하나입니다.

2. 저장소 (The Store)

데이터베이스 역할을 합니다. 일반적으로 벡터 인덱스(의미적 유사성으로 색인된 항목), 관계형 테이블(필터링할 수 있는 열로 색인된 항목), 지식 그래프(유형이 지정된 간선으로 연결된 항목) 중 하나 이상을 사용합니다. 각 구문에는 메타데이터, 즉 타임스탬프, 때로는 신뢰도 점수, 원래 대화로 돌아가는 소스 포인터가 포함됩니다. 저장소가 해결해야 할 가장 어려운 질문은 어디에 보관할것인가가 아닙니다. 새로운 구문이 이전 구문과 모순될 때 어떻게 할 것인가입니다. 사용자가 4월까지 파리에 살다가 암스테르담으로 이사했다면, 저장소에는 두 가지 항목이 모두 현재 상태로 존재하게 됩니다. 이때 선택지는 덮어쓰기(하나의 진실, 기록 없음), 추가(둘 다 두고 검색 시 정렬하게 함), 이전 항목을 만료된 것으로 표시하고 둘 다 보관하기 중 하나입니다. '지난달에 내가 무엇을 믿었는가?'라는 질문에 답할 수 없는 저장소는 진정한 기억 시스템이 아닙니다. 그것은 단지 타임스탬프가 찍힌 스냅샷일 뿐입니다.

3. 검색기 (The Retriever)

쿼리 시점에 이 구성 요소는 현재 질문을 검색으로 변환하고 가장 관련성이 높을 가능성이 있는 구문을 반환합니다. 벡터 유사도가 기본이며, 그 위에 키워드 검색을 추가하는 것이 일반적입니다. 재순위 지정 모델(Reranker)이 표준적인 세 번째 레이어입니다. 구조적으로 이것은 RAG(검색 증강 생성)와 같습니다. 다만 말뭉치(corpus)가 문서 라이브러리가 아니라 사용자의 축적된 구문이라는 점이 다릅니다. 일부 라이브러리는 시간 필터(시대에 뒤떨어진 것으로 알려진 구문을 반환하지 않음)와 전제 조건 확인(질문 자체가 오래된 사실을 전제하고 있는지 감지하여 이를 컨텍스트로 가져오는 것을 차단함)도 실행합니다.

에이전트 메모리 라이브러리 간의 모든 차이점은 이 세 가지 부분 중 하나에 존재합니다. 라이브러리의 용도를 아직 모르더라도 이러한 측면에서 어떤 라이브러리든 설명할 수 있습니다.

기억의 종류

인지과학의 표준적인 분류 체계는 네 가지로 구성됩니다. (역주: 원문이 네 가지로 구성된다고 언급하며 끝맺음)

원문 보기
원문 보기 (영어)
every agent memory library uses the same words: episodic , semantic , sometimes procedural . they’re cognitive science’s vocabulary, lifted into the API. the engineering often isn’t lifted with them. a library can have a procedural field that uses the same storage and retrieval as semantic — a label, not a separate system. the deeper slip is the word memory itself: most of what these libraries build is narrower than that, and the narrower term sharpens the problem. the terminology comes from a 1972 chapter by Endel Tulving. 1 he argued that what people had been treating as one thing — memory — was at least two: memory for events (what happened, where, when), and memory for facts (the capital of France, water’s boiling point). he called them episodic and semantic . they behave differently and they fail differently. most of what these libraries call “memory” is narrower than the word suggests: not a full cognitive memory system, but autobiographical content about the user held on the user’s behalf — where they live, what they’re working on, what they’ve decided. the anatomy of an agent memory system an agent memory library is built from a small number of components. you can read any library’s docs by knowing the parts. the extractor. the thing that reads conversation transcripts and decides what to keep. usually an LLM call, sometimes with a strict prompt or a typed output schema. it produces statements — short, abstracted facts about the user, the world, or the task. the most consequential choice an extractor makes is timing. extract eagerly, after every message, and you spend tokens on small talk that goes nowhere. extract lazily, at the end of a session, and the context you needed to resolve a pronoun is already gone. neither timing is wrong; each loses something the other keeps. the question worth asking of any library is what gets thrown away — coreference cues (which “he” refers to which person), temporal anchors (“yesterday,” “next week”), and disambiguating local context are common casualties. extraction is, in cognitive terms, a compression from situated event to decontextualized fact: user mentioned over coffee on Tuesday that they prefer TypeScript becomes user prefers TypeScript . how aggressively a library compresses is one of its central design decisions. the store. the database. one or more of: a vector index (entries indexed by semantic similarity), a relational table (entries indexed by columns you can filter on), a knowledge graph (entries connected by typed edges). each statement carries metadata — a timestamp, sometimes a confidence score, sometimes a source pointer back to the original conversation. the hardest question a store answers isn’t where to put things. it’s what to do when a new statement contradicts an old one. the user lived in Paris until April, then moved to Amsterdam — and the store now has both, each presenting as current. the choice is whether to overwrite (one truth, no history) append (both, leave it to retrieval to sort out) keep both with the old marked as superseded. a store that can’t answer what did I believe last month? isn’t a memory system. it’s a snapshot with a timestamp on it. the retriever. at query time, this component turns the current question into a search and returns the statements most likely to be relevant. vector similarity is the baseline. keyword search on top of that is common. a reranker is the standard third layer. structurally this is RAG; the corpus is the user’s accumulated statements rather than a document library. some libraries also run a time filter (don’t return statements known to be out of date) and a presupposition check — detect when the question itself assumes a stale fact and block it from being pulled into context. every difference between agent memory libraries lives in one of these three parts. you can describe any library in terms of them without yet knowing what it’s for. the kinds of memory cognitive science’s canonical taxonomy consists of four kinds: episodic, semantic, procedural, and working. working memory in agents is the context window — a different machine from the one this post is about, worth setting aside. 2 that leaves three. add prospective — it isn’t in the canonical taxonomy, but it names a gap the field hasn’t filled. episodic memory. specific events tied to a time and place. I had coffee with Aleksandra last Tuesday at the place on Mostowa. the memory is dated, situated, and personal. you experienced it. recall feels like re-experiencing — you can place yourself back in the scene. agent memory libraries handle this with a table of timestamped statements. user mentioned they live in Berlin (2026-03-14). each entry is a single event the system observed. some libraries keep the raw conversation episode alongside the extracted facts. semantic memory. facts about the world that aren’t tied to any specific event. Berlin is the capital of Germany. the boiling point of water is 100°C at sea level. you know these things; you can’t usually recall when you learned them. the knowledge is decontextualized. most of what people mean by “agent memory” is this. user prefers TypeScript started as an episodic observation — they said it on Tuesday — but by the time it lands in the store, the context is gone and what remains is a fact about the user, true until contradicted. procedural memory. 3 knowing how to do things. tying shoes, riding a bike, the muscle memory of a keyboard shortcut. you can’t usually verbalize procedural memory — try explaining how you keep your balance — but it shapes behavior reliably. procedural memory is the cleanest litmus test for the gap between what a library claims and what it implements. LangMem 4 treats it as a distinct mechanism — evolving the system prompt from scored trajectories, so what’s remembered isn’t a retrievable fact but a behavioral disposition encoded in instructions. Mem0 exposes the procedural label but writes it into the same index it uses for facts — metadata.memory_type = "procedural" is the only difference. Graphiti doesn’t expose procedural memory at all; everything lands in the same bitemporal graph regardless of source. prospective memory. remembering to do something in the future. don’t forget to send the contract tomorrow. next time the user asks about pricing, mention the new tier. prospective memory is one of the most studied failure modes in humans — people forget intentions far more often than they forget facts. the closest analogs in production are scheduled triggers in agent frameworks; they solve the do Y at time T case but not the harder do Y when condition X next appears , which is the form prospective memory actually takes. no production library I’ve seen ships this. open territory. what these libraries actually are of these four kinds, three are mostly absent from production memory libraries — episodic gets compressed to semantic at extraction, procedural is mostly mislabeled semantic, prospective barely exists. what’s left is semantic memory, and within semantic, one specific subset: autobiographical memory — the facts a person knows about their own life. borrowing the term loosely: the agent isn’t remembering its own life, it’s maintaining the user’s by proxy. when people say agents should “remember the user,” what they usually mean is autobiographical content held on the user’s behalf: where they live, what they’re working on, who matters to them, what they’ve asked for and decided — facts the agent keeps about the user’s life and preferences to act consistently across sessions. most agent memory libraries are autobiographical memory systems with extra steps. the field’s central problem is narrower than “memory” — and clearer when you name it. where the analogy breaks the three parts have rough biological analogs. extraction is the agent analog of consolidation — the slow compression from situated experience to decontextualized fact (in humans, during sleep, over hours; in agents, at conversational