Agentic Memory: LLM 에이전트를 위한 통합 Long-Term/Short-Term 메모리 관리 학습
Agentic Memory: Learning Unified Long-Term and Short-Term Memory Management for Large Language Model Agents
TL;DR Highlight
LLM 에이전트가 장기·단기 메모리를 별도 모듈 없이 툴 호출로 스스로 관리하도록 강화학습으로 훈련하는 프레임워크
Who Should Read
멀티턴 대화나 장기 태스크에서 컨텍스트 폭발·메모리 관리를 고민하는 AI 에이전트 개발자. LangMem, Mem0 같은 메모리 시스템을 프로덕션에 붙여봤지만 성능 한계를 느낀 개발자.
Core Mechanics
- LTM(장기 메모리)과 STM(단기 메모리)을 별개 모듈로 두지 않고 에이전트 정책에 직접 통합 — ADD/UPDATE/DELETE(LTM용) + RETRIEVE/SUMMARY/FILTER(STM용) 6개 툴로 노출
- 3단계 진행형 RL 훈련: 1단계(정보 보며 LTM 구축) → 2단계(방해 정보 속에서 STM 필터링) → 3단계(LTM 검색 + STM 관리 + 최종 추론 통합)
- step-wise GRPO(그룹 상대 정책 최적화)로 메모리 작업의 희소하고 불연속적인 보상 문제 해결 — 최종 태스크 결과를 모든 중간 메모리 결정에 역전파
- 보상 함수를 태스크 완료 + 컨텍스트 관리 + 메모리 품질 3가지로 설계해 단순 정답 보상만 쓸 때보다 수렴 속도와 메모리 품질 모두 개선
- RL 훈련 후 에이전트가 ADD/UPDATE를 더 적극 활용하고, FILTER 호출이 Qwen2.5-7B 기준 0.02→0.31로 급증 — 규칙 없이 알아서 맥락 정리
- Qwen2.5-7B, Qwen3-4B 두 모델에서 모두 LangMem, A-Mem, Mem0, Mem0g(그래프 기반) 4개 베이스라인을 전 벤치마크 초과
Evidence
- Qwen2.5-7B 기준 5개 벤치마크 평균 41.96% — 최강 베이스라인 Mem0(37.14%) 대비 +4.82%p, no-memory(28.05%) 대비 +49.59%
- Qwen3-4B 기준 평균 54.31% — A-Mem(45.74%) 대비 +8.57%p, RL 훈련이 AgeMem-noRL 대비 단독으로 +8.72%p 기여
- 메모리 품질(MQ) 점수: Qwen3-4B에서 0.605 달성 — 차선 A-Mem 0.587 대비 +0.018, Answer-Only 보상 전략(0.415) 대비 +0.190
- STM 툴이 RAG 대체 시 토큰 사용 3.1~5.1% 절감 — Qwen3-4B 기준 2310토큰(RAG) → 2191토큰(AgeMem)
How to Apply
- 메모리 작업을 함수 호출(tool call)로 노출할 때 ADD/UPDATE/DELETE(LTM) + RETRIEVE/SUMMARY/FILTER(STM) 6개 인터페이스를 모두 구현하고 에이전트 시스템 프롬프트에 <think>→<tool_call>→<answer> 구조를 강제하면 메모리 조작이 파싱 가능해짐
- 컨텍스트 폭발이 생기는 장기 대화 시스템에서 RAG를 SUMMARY/FILTER 툴로 교체하면 됨 — 에이전트가 overflow 전에 먼저 호출하도록 Rpreventive 같은 선제 행동 보상을 추가할 것
- RL 학습 없이 툴만 붙여도 베이스라인보다 낫지만, 논문의 3단계 시나리오(정보 수집 → 방해 정보 → 최종 쿼리) 구조로 훈련 데이터를 만들어 GRPO 파인튜닝하면 추가로 8%p 이상 올라감
Code Example
# AgeMem 스타일 메모리 툴 스키마 + 시스템 프롬프트 구조
LTM_TOOLS = [
{
"name": "Add_memory",
"description": "새 정보를 장기 메모리에 저장",
"parameters": {
"content": {"type": "string"}, # 저장할 내용
"memory_type": {"type": "string"}, # 메모리 유형
"metadata": {"type": "object"} # 태그/카테고리 (optional)
}
},
{
"name": "Update_memory",
"description": "기존 메모리 수정 (이전 retrieve로 얻은 memory_id 필요)",
"parameters": {
"memory_id": {"type": "string"},
"content": {"type": "string"}
}
},
{
"name": "Delete_memory",
"description": "메모리 삭제",
"parameters": {
"memory_id": {"type": "string"},
"confirmation": {"type": "boolean"}
}
}
]
STM_TOOLS = [
{
"name": "Retrieve_memory",
"description": "코사인 유사도로 LTM 검색 후 현재 컨텍스트에 삽입",
"parameters": {
"query": {"type": "string"},
"top_k": {"type": "integer", "default": 3} # 보통 3~5
}
},
{
"name": "Filter_context",
"description": "현재 컨텍스트에서 기준과 유사도 0.6 초과 메시지 제거",
"parameters": {
"criteria": {"type": "string"} # 제거할 내용 기술 (e.g. '양자컴퓨팅 블록체인')
}
},
{
"name": "Summary_context",
"description": "대화 히스토리 압축",
"parameters": {
"span": {"type": "string"} # 'all' 또는 숫자 문자열 (e.g. '5' = 마지막 5라운드)
}
}
]
# 시스템 프롬프트 핵심 구조 (논문 Appendix A.1 기반)
SYSTEM_PROMPT = """
## 문제 풀이 워크플로우
1. <think>...</think> 블록에서 추론 및 다음 행동 결정
2. 툴이 필요하면 <tool_call>[{"name": "...", "arguments": {...}}]</tool_call>
(여러 툴 동시 호출 가능 — JSON 배열로)
3. 최종 답변 준비되면 <answer>...</answer>
## 규칙
- <think> 다음에는 <tool_call> 또는 <answer> 중 하나만
- 메모리를 적극 관리: retrieve, add, update, summarize, filter, delete
"""
# 실제 에이전트 호출 예시 (툴 호출 → 결과 반영 루프)
# <think>사용자 선호도 정보가 있음. LTM에 저장해야 함</think>
# <tool_call>[{"name": "Add_memory", "arguments": {"content": "사용자는 120분 집중 세션을 선호하는 시각적 학습자", "memory_type": "user_preference"}}]</tool_call>
# <think>저장 완료. 이제 응답 생성</think>
# <answer>네, 120분 세션으로 커리큘럼을 구성해드리겠습니다.</answer>Terminology
Related Resources
Original Abstract (Expand)
Large language model (LLM) agents face fundamental limitations in long-horizon reasoning due to finite context windows, making effective memory management critical. Existing methods typically handle long-term memory (LTM) and short-term memory (STM) as separate components, relying on heuristics or auxiliary controllers, which limits adaptability and end-to-end optimization. In this paper, we propose Agentic Memory (AgeMem), a unified framework that integrates LTM and STM management directly into the agent's policy. AgeMem exposes memory operations as tool-based actions, enabling the LLM agent to autonomously decide what and when to store, retrieve, update, summarize, or discard information. To train such unified behaviors, we propose a three-stage progressive reinforcement learning strategy and design a step-wise GRPO to address sparse and discontinuous rewards induced by memory operations. Experiments on five long-horizon benchmarks demonstrate that AgeMem consistently outperforms strong memory-augmented baselines across multiple LLM backbones, achieving improved task performance, higher-quality long-term memory, and more efficient context usage.