langchain-3-conversation-memory
Sub-skill of langchain: 3. Conversation Memory.
Best use case
langchain-3-conversation-memory is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Sub-skill of langchain: 3. Conversation Memory.
Teams using langchain-3-conversation-memory should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/3-conversation-memory/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How langchain-3-conversation-memory Compares
| Feature / Agent | langchain-3-conversation-memory | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Sub-skill of langchain: 3. Conversation Memory.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# 3. Conversation Memory
## 3. Conversation Memory
**Conversation Buffer Memory:**
```python
from langchain_openai import ChatOpenAI
from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder
from langchain_core.runnables.history import RunnableWithMessageHistory
from langchain_community.chat_message_histories import ChatMessageHistory
from langchain_core.chat_history import BaseChatMessageHistory
# Store for session histories
store = {}
def get_session_history(session_id: str) -> BaseChatMessageHistory:
"""Get or create message history for a session."""
if session_id not in store:
store[session_id] = ChatMessageHistory()
return store[session_id]
def create_conversational_chain():
"""
Create a chain with conversation memory.
"""
llm = ChatOpenAI(model="gpt-4", temperature=0.7)
prompt = ChatPromptTemplate.from_messages([
("system", """You are an expert offshore engineering consultant.
You help with mooring design, vessel dynamics, and marine operations.
Maintain context from previous messages in the conversation."""),
MessagesPlaceholder(variable_name="history"),
("human", "{input}")
])
chain = prompt | llm
# Wrap with message history
chain_with_history = RunnableWithMessageHistory(
chain,
get_session_history,
input_messages_key="input",
history_messages_key="history"
)
return chain_with_history
# Usage
conversational_chain = create_conversational_chain()
# First message
response1 = conversational_chain.invoke(
{"input": "I'm designing a spread mooring system for a 100,000 DWT tanker."},
config={"configurable": {"session_id": "project-123"}}
)
print(f"Assistant: {response1.content}")
# Follow-up (remembers context)
response2 = conversational_chain.invoke(
{"input": "What line configuration would you recommend?"},
config={"configurable": {"session_id": "project-123"}}
)
print(f"Assistant: {response2.content}")
# Check history
history = get_session_history("project-123")
print(f"\nConversation has {len(history.messages)} messages")
```
**Summary Memory for Long Conversations:**
```python
from langchain_openai import ChatOpenAI
from langchain.memory import ConversationSummaryBufferMemory
from langchain.chains import ConversationChain
def create_summary_memory_chain():
"""
Create chain with summary memory for long conversations.
Keeps recent messages verbatim, summarizes older ones.
"""
llm = ChatOpenAI(model="gpt-4", temperature=0.7)
# Summary buffer keeps last 1000 tokens verbatim
memory = ConversationSummaryBufferMemory(
llm=llm,
max_token_limit=1000,
return_messages=True
)
chain = ConversationChain(
llm=llm,
memory=memory,
verbose=True
)
return chain, memory
# Usage
chain, memory = create_summary_memory_chain()
# Simulate long conversation
responses = []
questions = [
"What are the main types of mooring systems?",
"Tell me about spread moorings in detail.",
"What about single point moorings?",
"How do turret moorings work?",
"Compare the maintenance requirements.",
"What are the cost implications?"
]
for q in questions:
response = chain.predict(input=q)
responses.append(response)
print(f"Q: {q}")
print(f"A: {response[:200]}...")
print()
# Check memory state
print("Memory Summary:")
print(memory.moving_summary_buffer)
```Related Skills
memory-bridge-operations
Operate and recover the Hermes-to-repo memory bridge: drift checks, quality gate, bridge commits, push verification, and stash recovery when pre-bridge scripts fail after generating outputs.
hermes-memory-bridge
Architecture and scripts for syncing Hermes memory into git-tracked .claude/memory/ so all machines get context via git pull. Covers quality gate, drift detection, topic mirroring, and cron automation.
memory-bridge-operation
Manage the Hermes ↔ repo memory sync system — bridge, quality gate, compaction, health checks, and cron
memory-bridge-commit-fallbacks
Fallback procedures when the Hermes ↔ Codex memory bridge writes .Codex/memory outputs but the internal git commit/push path fails because of dirty, stale, or broken submodule state.
agent-memory-bridge
Bidirectional sync between Hermes memory and Codex auto-memory, with licensed machine bootstrap. Use when context parity across agents is needed.
memory-management
Two-tier memory system for decoding workplace shorthand, acronyms, nicknames, and internal language.
pandas-data-processing-1-memory-efficiency
Sub-skill of pandas-data-processing: 1. Memory Efficiency (+3).
openpyxl-1-memory-management
Sub-skill of openpyxl: 1. Memory Management (+2).
memory-management-working-memory-format-claudemd
Sub-skill of memory-management: Working Memory Format (AGENTS.md).
memory-management-what-it-is
Sub-skill of memory-management: What It Is.
memory-management-what-goes-where
Sub-skill of memory-management: What Goes Where.
memory-management-tools-systems
Sub-skill of memory-management: Tools & Systems.