How AI Agents Remember Things

Damian Galarza www.youtube.com

간략한 요약

이 비디오에서는 AI 에이전트의 기억 시스템 작동 방식과 OpenClaw의 메모리 모델을 예시로 들어 설명합니다. AI 에이전트는 기본적으로 기억이 없지만, 세션과 장기 기억을 통해 이를 보완할 수 있습니다. 효과적인 기억 시스템은 대화에서 핵심 정보를 추출하고, 기억 항목을 통합하며, 이전 결정을 덮어쓸 수 있어야 합니다. OpenClaw는 마크다운 파일을 사용하여 의미 기억과 에피소드 기억을 저장하고, 네 가지 메커니즘을 통해 적절한 시점에 기억을 읽고 씁니다.

  • AI 에이전트는 기본적으로 상태가 없으므로 기억 시스템이 필요합니다.
  • 기억 시스템은 세션(단기 기억)과 장기 기억으로 나눌 수 있습니다.
  • OpenClaw는 마크다운 파일을 사용하여 기억을 저장하고, 네 가지 메커니즘을 통해 기억을 관리합니다.

소개

AI 에이전트는 기본적으로 기억이 없으며, 모든 대화는 백지 상태에서 시작됩니다. OpenClaw는 마크다운 파일과 네 가지 메커니즘을 사용하여 이 문제를 해결했습니다. 이 비디오에서는 OpenClaw의 메모리 시스템 작동 방식을 자세히 설명합니다.

AI 에이전트가 잊어버리는 이유

AI 모델은 본질적으로 상태가 없으므로, 호출 사이에 기억이 없습니다. 대화는 점점 길어지는 컨텍스트 창으로, 대화의 각 턴마다 전달됩니다. 따라서 기억 시스템이 없으면 새로운 대화는 이전 대화의 컨텍스트 없이 시작됩니다.

세션 및 장기 기억

에이전트 기억 시스템은 세션과 장기 기억으로 나눌 수 있습니다. 세션은 LLM과의 단일 대화 기록으로 생각할 수 있습니다. 대화 중에는 대화 상태를 어딘가에 저장해야 합니다. 이 대화 기록은 LLM이 현재 대화 시점을 기억하고 이해할 수 있도록 각 후속 호출에 전달되어야 합니다.

압축 전략

LLM은 컨텍스트 창이 제한되어 있습니다. 컨텍스트 창 제한에 가까워지면 압축이라는 프로세스가 시작됩니다. 압축은 세션의 대화 기록을 가져와 가장 중요하고 관련성 높은 정보로 분해하여 세션의 모든 세부 정보를 잃지 않고 대화를 계속할 수 있도록 하는 행위입니다. 압축을 트리거하는 세 가지 전략이 있습니다. 첫 번째는 횟수 기반입니다. 두 번째는 시간 기반입니다. 세 번째는 이벤트 기반 또는 의미론적입니다.

장기 기억 설명

컨텍스트 창 제한으로 인해 이전 대화 전체를 새 대화에 유지하고 전달할 수 없습니다. 장기 기억은 세션이 끝날 때 살아남는 것입니다. 세션을 현재 프로젝트를 위한 지저분한 책상으로 상상해 보십시오. 책상 주위에 다양한 메모와 문서가 흩어져 있을 수 있습니다. 그런 다음 항목이 분류되고 저장되는 서류 캐비닛이 있을 수 있습니다. 이것이 기억입니다.

Google의 기억 프레임워크 (에피소드, 의미, 절차)

Google은 2025년 11월에 "컨텍스트 엔지니어링 세션 및 기억"이라는 백서를 발표했습니다. 이 백서에서 에이전트 기억을 세 가지 유형으로 나눕니다. 첫 번째 유형은 에피소드 기억입니다. 에피소드 기억은 이전 대화에서 일어난 일과 같은 것을 다룹니다. 두 번째는 의미 기억입니다. 의미 기억은 순수한 사실 또는 사용자 기본 설정입니다. 세 번째는 절차 기억입니다. 절차 기억은 워크플로 및 학습된 루틴과 같은 것을 다룹니다.

효과적인 기억을 만드는 요소

기억 시스템이 효과적이려면 대화에서 핵심 세부 정보를 추출하여 유지하는 견고한 방법이 있어야 합니다. 여기에는 무엇을 기억할 가치가 있는지 이해하는 것이 포함됩니다. 대화의 모든 세부 정보가 중요한 것은 아닙니다. 기억이 효과적이려면 대상 필터링이 필요합니다. 또한 기억 항목을 통합할 수 있어야 합니다. 또한 이전 결정이나 판단을 덮어쓸 수 있어야 합니다.

OpenClaw의 기억 시스템

OpenClaw 메모리 모델은 에이전트 메모리의 실제 사례입니다. OpenClaw 메모리 시스템에는 세 가지 핵심 구성 요소가 있습니다. 첫 번째 구성 요소는 메모리 MD 파일입니다. 여기에는 안정적인 사실, 기본 설정 및 신원에 대한 정보가 포함됩니다. 두 번째는 일일 로그입니다. 세 번째는 세션 스냅샷입니다.

네 가지 메커니즘

OpenClaw 메모리는 마크다운 파일입니다. 이러한 파일은 이야기의 절반에 불과합니다. 파일을 올바른 시간에 읽고 쓰는 것이 없으면 아무것도 하지 않습니다. 파일은 서류 캐비닛입니다. 이제 책상에서 캐비닛으로 물건을 옮기는 메커니즘을 살펴볼 것입니다.

부트스트랩 로딩

첫 번째 메커니즘은 세션 시작 시 부트스트랩 로딩입니다. 모든 새 대화에 대해 메모리 MD가 자동으로 프롬프트에 삽입됩니다. 에이전트는 항상 가지고 있습니다. 또한 에이전트의 지침은 최근 컨텍스트에 대해 오늘과 어제의 일일 로그를 읽도록 지시합니다.

사전 압축 플러시

두 번째 메커니즘은 사전 압축 플러시입니다. OpenClaw는 횟수 기반 접근 방식을 취합니다. 세션이 컨텍스트 창 제한에 가까워지면 OpenClaw는 사용자에게 보이지 않는 자동 에이전트 턴을 삽입합니다. LLM에 압축에 가까워지고 있으며 중요한 것을 저장해야 한다고 지시합니다. 에이전트가 이 메시지를 보면 일일 로그에 씁니다.

세션 스냅샷

세 번째 메커니즘은 새 세션을 시작할 때 실행되는 세션 스냅샷입니다. 세션 스냅샷은 /new 또는 /reset 명령을 통해 새 세션이 시작될 때마다 저장됩니다. 이전 대화의 마지막 청크를 가져와 의미 있는 메시지만 필터링하고 LM은 파일 이름에 대한 설명 슬러그를 생성합니다.

사용자 시작 기억

마지막으로 가장 간단한 메커니즘은 사용자가 묻는 것입니다. 사용자가 "이것을 기억하십시오"와 같이 말하면 에이전트는 의미 기억 또는 메모리 MD 파일 또는 에피소드 기억으로 일일 로그에 속하는지 여부를 결정합니다. 특별한 후크가 필요하지 않습니다. 에이전트는 파일 쓰기 기능만 있고 지침은 정보를 라우팅하는 방법을 알려줍니다.

결론

OpenClaw의 전체 메모리 시스템은 마크다운 파일과 언제 작성해야 하는지 아는 것으로 귀결됩니다. 의미 기억은 메모리 MD 파일에, 에피소드 기억은 일일 로그 및 세션 스냅샷에, 네 가지 메커니즘은 대화 수명 주기에서 올바른 순간에 실행됩니다. 이러한 패턴은 OpenClaw에만 있는 것이 아닙니다. Claude Code는 최근 메모리 기능을 출시했으며 마크다운 파일도 사용합니다. 에이전트에게 기억을 제공하기 위해 복잡한 설정이 필요하지 않습니다. 세 가지 질문에 대한 명확한 지침만 있으면 됩니다. 무엇을 기억할 가치가 있습니까? 어디로 갑니까? 언제 작성됩니까?

유튜브 영상을 몇 초 만에 요약하세요

무료 Summ 앱으로 어떤 영상이든 이런 요약을 원하는 언어로 받아보세요.

App Store에서 다운로드
Google Play에서 다운로드

스크립트

“How AI Agents Remember Things”의 전체 스크립트입니다. 타임스탬프를 클릭하면 해당 장면부터 영상이 열려요. 다른 영상이 필요하다면 유튜브 스크립트 추출기를 이용하세요.

0:00 Out of the box, AI agents have no memory. Every conversation starts with a blank slate. Most people think that you need a vector database, complex retrieval pipelines, or specialized memory to handle this. But OpenClaus solved it with markdown files and four mechanisms that fire at the right moments in a conversation. I'll show you exactly how it works. AI models are inherently stateless. There's no memory between calls. Your conversation is an increasingly long context window that gets passed on each turn of the conversation. This is why without some kind of memory system, each new conversation starts without any context of the previous one. So how does an agent memory system actually work? Memory systems can be broken up into two pieces, the session and longerterm memory. The session can be thought of as

0:48 a history of a single conversation with an LLM. During the conversation, the state of it needs to be saved somewhere. This conversation history needs to be passed on each subsequent call you make to the LLM for it to remember and understand the current point of the conversation. There's a problem though. LMS have a finite context window. Because of this, as you approach the limits of your context window, a process called compaction kicks in. Compaction is the act of taking the session's conversation history and breaking it down into the most important relevant information in order to allow the conversation to continue without losing all of the details of the session. There are three different strategies for triggering compaction. First is countbased. This is when you compact a conversation once it's exceeded a certain token size or a certain turn

1:33 count in the conversation. Second is timebased. This is triggered when the user stops interacting for a certain period of time. Compaction is then triggered in the background. Third is event-based or semantic. Here an agent triggers compaction when it has detected that a particular task or topic has concluded. It's the most intelligent version of compaction, but also the most difficult to implement accurately because of the context window limit. We can't just persist and pass entire old conversations into a new conversation with an LLM. That is where long-term memory comes in. The memory is what survives at the end of a session. Imagine a session as a messy desk for a current project. You might have various notes and documents scattered around your desk. Then you might have a filing cabinet where things are categorized and

2:20 stored. This is the memory. There's a great framework for thinking about memory. Google published a white paper in November of 2025 titled context engineering sessions and memory. In it, they break down agent memory into three types. The first type is episodic. Episodic memory covers things like what happened in our last conversation. These are events or interactions you might have had with the LM. Second is semantic. Semantic memory are pure facts or user preferences. Think what do I the LM know about you the user or the topic. Third is procedural. Procedural memory covers things like workflows and learned routines or how do I accomplish this task. All of these come together to form a memory for an agent. In order for the memory system to be effective, it must have a solid method of extracting key

3:06 details from a conversation in order to persist them. Part of this is understanding what is worth remembering. Not every detail of a conversation is going to be important. Targeted filtering is needed in order for the memory to be effective. Just like a human's memory where we may not remember full details of something. Instead, we remember key concepts and facts. In addition to this, it must also be able to consolidate items in memory. For example, imagine a user tells agent that I prefer dark mode in one conversation. In a later conversation, it says I don't like dark mode anymore. And in another, it says I switched to dark mode. Without consolidation, all three entries sit in the memory saying essentially the same thing. A good memory system collapses those into a single entity. User prefers

3:53 dark mode. It also must be able to overwrite previous decisions or determinations. Something that might be true today may not necessarily be true tomorrow. The memory system must be able to differentiate and update its memory knowledge bank. Without this, the memory can become noisy and contradictory. These are both typically handled by another LLM instance that takes a conversation and handles this extraction and consolidation. There are different ways you can store memory from simple solutions such as markdown files for a local agent to specialized databases like vector storage that can be searched for relevant data when appropriate. Let's take a look at a real world example of this system in place. Open clause memory model is a great example of agent memory in practice. I recently did a video

4:38 explaining the underlying system of OpenClaw at a high level. Let's take a closer look at how its memory works. The OpenClaw memory system has three core components. The first component is the memory MD file. This is the semantic memory store for Open Claw. It includes stable facts, preferences, and information about your identity. This is loaded into every single prompt and has a recommended 200line cap. The memory is broken up into structured sections. Second are daily logs. Daily logs are one of open clause implementations of episodic memory. It contains recent context organized by day. These memory files are appended only which means that new memory entries are continually added but nothing gets removed. Third are session snapshots. Session

5:25 snapshots are the second implementation of episodic memory by openclaw. These are triggered by the session memory hook that fires when a new session is started via the slashnew or slashreset command. The snapshot captures the last 15 meaningful messages from your conversation. These are filtered to only user and assistant messages. That means things like tool calls and system messages and slash commands are all excluded. It's not a generated summary, but it's actually the raw conversation text saved as a markdown file with a descriptive name. So at its core, open clause memory is just markdown files. That's straightforward enough, but it turns out that these files are only half the story. Without something that reads and writes them at the right times, they're just sitting there doing nothing. Remember the desk and the filing cabinet? The files are the filing cabinet. And what we're about to look at

6:11 are the mechanisms that move the things from the desk to the cabinet at the right moments. The first mechanism, bootstrap loading at the session start. For every new conversation, the memory MD is automatically injected into the prompt. The agent always has it. On top of that, the agent's instructions tell it to read today and yesterday's daily logs for recent context. So the memory MD is injected by the system and the daily logs are loaded by the agent itself following its own instructions. This is the simplest pattern and the most important one. The second mechanism is the pre-ompaction flush. Open claw takes a count-based approach towards compaction. When a session nears the context window limit, open claw injects a silent agentic turn that is invisible to the user. It instructs the LLM that

6:57 you're near compaction and it needs to save anything that's important. Now, when the agent sees this message, it writes to the daily log. This serves as a checkpoint for the conversation. This turns a destructive operation such as losing context into a checkpoint. It follows a common database pattern or write ahead log, saving memory before it's lost. The third mechanism fires when you start a new session, the session snapshot. Session snapshots are saved whenever a new session is started, whether that's via the /new or/reset command. As I mentioned in the previous video, sessions are per channel. A hook grabs the last chunk of your previous conversation, filters to meaningful messages only, and the LM generates a descriptive slug for the file name. It's not a summary, it's a snapshot of what you were talking about, saved before the

7:42 slate gets wiped. And finally, the simplest mechanism, the user just asks. If a user says something like remember this, the agent determines whether it belongs in the semantic memory or memory MD file or the daily log as episodic memory. No special hook is needed. The agent just has file writing capabilities and its instructions tell it how to route the information. And that's it. Open Claw's entire memory system comes down to markdown files and knowing when to write to them. semantic memory in the memory MD file, episodic memory in daily logs and session snapshots, and four mechanisms that fire at the right moments in the conversation's life cycle. And these patterns aren't just an open claw. Claude Code recently shipped the memory feature, and it uses markdown files as well. You don't need a complex setup to give an agent memory. You just

8:29 need clear instructions to three questions. What's worth remembering? Where does it go? And when does it get written? If you want to go deeper into agent architecture and patterns like this, I write a weekly newsletter covering AI augmented engineering and building with LLM. Link is in the description.

Share

다른 영상 요약