0Pricing
LangChain / RAG / Vector DBs · 강의

에이전트형 RAG의 메모리와 상태

RAG 에이전트에 단기 및 장기 메모리를 부여해 대화를 이어 가고 여러 차례의 대화에서 사실을 기억하도록 해 보세요.

에이전트형 RAG의 메모리와 상태은(는) CoddyKit의 무료 LangChain / RAG / Vector DBs 강의입니다. 이것은 4개 중 4번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 LangChain / RAG / Vector DBs 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. LangChain / RAG / Vector DBs 강의에는 총 4개의 강의가 포함되어 있습니다.

이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.

Why Agents Need Memory

A stateless agent forgets everything after each call. Memory lets an agent track the conversation, remember user preferences, and avoid repeating retrievals.

Short-Term vs. Long-Term

Short-term memory holds the current conversation in the context window. Long-term memory persists facts across sessions, often in a vector store or database.

Conversation Buffer

The simplest memory keeps the full message history and replays it each turn so the model has full context.

history = []

def chat(user_msg):
    history.append({"role": "user", "content": user_msg})
    reply = llm.invoke(history)
    history.append({"role": "assistant", "content": reply})
    return reply

The Context Window Limit

Replaying the entire history eventually overflows the model context. You must summarize or trim older turns to stay within the token budget.

Summary Memory

Periodically compress old turns into a running summary, keeping recent turns verbatim. This preserves gist while freeing tokens.

if len(history) > 20:
    summary = llm.invoke("Summarize: " + str(history[:-6]))
    history[:] = [{"role": "system", "content": summary}] + history[-6:]

Long-Term Memory via Vectors

Store durable facts as embeddings. On each turn, retrieve relevant memories by similarity and inject them, just like RAG over a knowledge base.

memory_store.add_texts(["User prefers metric units"])
relevant = memory_store.similarity_search(user_msg, k=3)

Choosing What to Remember

Do not store everything. Extract durable, reusable facts (preferences, decisions, entities) and skip ephemeral chatter to keep long-term memory clean.

State Beyond Chat

Agents also track non-conversational state: which tools ran, intermediate results, and a scratchpad of reasoning steps used to plan the next action.

Thread and Session Keys

In multi-user systems, scope memory by a thread_id or user_id so conversations never leak between people.

def get_history(thread_id):
    return store.get(thread_id, [])

def save(thread_id, messages):
    store[thread_id] = messages

Persistence

For memory to survive restarts, back it with a database or checkpointer rather than an in-process dictionary. LangGraph offers checkpointers for exactly this.

Putting It Together

Combine a trimmed conversation buffer for recency, summary memory for the middle, and vector long-term memory for durable facts, all keyed by session.

Quick Check

Test your understanding of agent memory.

Recap

You added memory to agents:

  • Short-term buffer for the current chat
  • Summary memory to fit the context window
  • Long-term vector memory for durable facts
  • Scope by session and persist for durability

자주 묻는 질문

“에이전트형 RAG의 메모리와 상태” 강의는 무료인가요?

네 — “에이전트형 RAG의 메모리와 상태” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 LangChain / RAG / Vector DBs 강의 전체를 잠금 해제할 수 있습니다. LangChain / RAG / Vector DBs 강의에는 총 4개의 강의가 포함되어 있습니다.

“에이전트형 RAG의 메모리와 상태”에서 뭘 배우나요?

RAG 에이전트에 단기 및 장기 메모리를 부여해 대화를 이어 가고 여러 차례의 대화에서 사실을 기억하도록 해 보세요. 브라우저에서 직접 실행하는 실습 코드로 LangChain / RAG / Vector DBs을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.

LangChain / RAG / Vector DBs을(를) 시작하는 데 경험이 필요한가요?

사전 경험은 필요하지 않습니다. CoddyKit의 LangChain / RAG / Vector DBs은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 4번째 강의입니다.

“에이전트형 RAG의 메모리와 상태” 강의는 얼마나 걸리나요?

대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.

이 LangChain / RAG / Vector DBs 강의에서 코드를 작성하고 실행할 수 있나요?

네. 모든 LangChain / RAG / Vector DBs 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.

이 강의의 모든 강의

  1. LangChain 에이전트와 도구 개념
  2. 멀티 에이전트 RAG 워크플로 구축
  3. 외부 API를 도구로 통합
  4. 에이전트형 RAG의 메모리와 상태
← LangChain / RAG / Vector DBs(으)로 돌아가기