메모리 시스템
OpenClaw의 QMD(Question-Memory-Dialogue) 메모리 시스템을 이해하고 활용하세요.
메모리 시스템이란?
메모리 시스템은 에이전트가 대화 맥락을 저장하고 세션 간에 정보를 공유하는 기능입니다:
- 단기 메모리: 현재 세션의 대화 기록
- 장기 메모리: 세션 종료 후에도 보존되는 정보
- 의미론적 검색: 키워드가 아닌 의미로 정보 검색
QMD 아키텍처
Question (질문)
↓
Memory (메모리 검색) ←→ Vector Database
↓
Dialogue (대화 생성)
↓
Memory Update (메모리 저장)
단기 메모리 (Short-term Memory)
현재 세션의 대화 기록을 저장합니다.
설정
sessions:
maxHistory: 50
timeout: 3600
memory:
persistMemory: true
memoryPath: "~/.openclaw/memory/"
맥락 윈도우 (Context Window)
agents:
defaults:
contextWindow:
maxMessages: 50
maxTokens: 100000
importantPatterns:
- "!important"
- "!pin"
장기 메모리 (Long-term Memory)
세션 종료 후에도 보존되는 중요한 정보입니다.
자동 저장 트리거
| 트리거 | 예시 |
|---|---|
| 명시적 요청 | "이 정보를 기억해줘" |
| 반복 언급 | 3회 이상 언급된 정보 |
| 중요 마커 | !important, !remember |
| 개인 설정 | "항상 ~로 설정해줘" |
| 프로젝트 정보 | 프로젝트 이름, 목표 |
자동 저장 설정
sessions:
memory:
autoSave:
- trigger: "repetition"
minCount: 3
- trigger: "explicit"
patterns: ["!remember", "!important", "기억해"]
- trigger: "preference"
patterns: ["항상", "기본으로", "언제나"]
의미론적 검색 (Semantic Search)
키워드가 아닌 의미로 정보를 찾습니다:
# 키워드 검색 (한계)
search("고객 데이터")
→ "고객 데이터"라는 단어가 정확히 있어야 함
# 의미론적 검색 (유연)
search("우리 회사의 클라이언트 정보는?")
→ "고객 데이터", "사용자 정보", "client data" 등 모두 검색
메모리 유형
선호도 (Preference)
memory:
type: "preference"
content: "JSON 형식으로 출력해주세요"
"항상 JSON으로 보여줘" → preference 메모리로 자동 저장
사실 (Fact)
memory:
type: "fact"
content: "회사: TechCorp, 부서: 데이터 분석팀"
confidence: 0.95
"우리 회사는 TechCorp야" → fact 메모리로 저장
맥락 (Context)
memory:
type: "context"
content: "프로젝트: Q1 고객 데이터 분석"
expiresAt: "2026-03-31T23:59:59Z"
코드 스니펫 (Code Snippet)
memory:
type: "code"
language: "python"
content: |
import pandas as pd
df = pd.read_csv('data.csv')
usageCount: 8
메모리 관리 명령어
# 메모리 검색
openclaw memory search "프로젝트"
# 특정 사용자의 메모리
openclaw memory search --user "user-123" "설정"
# 최근 메모리 목록
openclaw memory list --limit 10
# 메모리 삭제
openclaw memory delete <memory-id>
# 메모리 태그 추가
openclaw memory tag <memory-id> --tags "중요,프로젝트"
# 메모리 아카이브
openclaw memory archive <memory-id>
메모리 최적화
오래된 메모리 정리
sessions:
memory:
retention:
archiveAfterDays: 30
deleteAfterDays: 90
keepIfAccessCount: 5
메모리 보안
민감한 정보 자동 마스킹:
masking:
patterns:
- regex: "\\d{3}-\\d{4}-\\d{4}"
replacement: "***-****-****" # 전화번호
- regex: "\\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Z|a-z]{2,}\\b"
replacement: "***@***.***" # 이메일
모범 사례
명시적 메모리 저장:
"이 정보를 기억해줘: API 엔드포인트는 api.example.com"
"!pin: 프로젝트 마감일은 3월 15일"
메모리 태그 사용:
"!remember #work #project 프로젝트 목표: 고객 이탈률 10% 감소"
"!important #personal 회의 시간: 매주 화요일 10시"
비밀번호 같은 민감한 정보는 저장하지 않고 별도의 비밀 관리자를 사용합니다.
참고: