Skip to content

Getting Started

Get up and running with LangCrew Memory in just a few minutes. This guide covers basic setup and common usage patterns.

Install LangCrew with memory support:

Terminal window
# Install LangCrew
uv add langcrew
from langcrew import Agent, Crew
# Create memory configuration - just enable it!
memory_config = True # Uses default settings with all memory types enabled
# Create agent with memory
agent = Agent(
role="Memory Assistant",
goal="Remember and use information from our conversations",
backstory="You are an AI assistant with excellent memory capabilities"
)
# Create crew with shared memory
crew = Crew(
agents=[agent],
memory=memory_config
)

2. Run Your First Memory-Enabled Conversation

Section titled “2. Run Your First Memory-Enabled Conversation”
# First conversation
result1 = crew.kickoff(
inputs={"user_input": "My name is Alice and I love pizza"},
thread_id="conversation_1"
)
# Later conversation - agent remembers Alice
result2 = crew.kickoff(
inputs={"user_input": "What food do I like?"},
thread_id="conversation_1" # Same thread ID
)
print(result2) # Agent will remember Alice likes pizza
from langcrew.memory import MemoryConfig, ShortTermMemoryConfig, LongTermMemoryConfig
# Persistent memory configuration
memory_config = MemoryConfig(
provider="sqlite",
connection_string="sqlite:///my_memory.db",
short_term=ShortTermMemoryConfig(enabled=True),
long_term=LongTermMemoryConfig(enabled=True)
)
crew = Crew(agents=[agent], memory=memory_config)
# Memory persists across program restarts
result = crew.kickoff(
inputs={"user_input": "Remember that I work at TechCorp"},
thread_id="user_alice"
)

Remembers recent conversation history within a session:

from langcrew.memory import MemoryConfig, ShortTermMemoryConfig
# Configure short-term memory
memory_config = MemoryConfig(
short_term=ShortTermMemoryConfig(enabled=True)
)
# Agent will remember context from recent messages
crew = Crew(agents=[agent], memory=memory_config)

Stores important knowledge across sessions:

from langcrew.memory import LongTermMemoryConfig
# Configure long-term memory
memory_config = MemoryConfig(
long_term=LongTermMemoryConfig(
enabled=True,
app_id="my-app" # RECOMMENDED for production
)
)
# Agent learns and remembers important facts
crew = Crew(agents=[agent], memory=memory_config)
from langcrew.memory import MemoryConfig, ShortTermMemoryConfig, LongTermMemoryConfig
memory_config = MemoryConfig(
provider="memory", # Fast, no persistence
short_term=ShortTermMemoryConfig(enabled=True),
long_term=LongTermMemoryConfig(enabled=True)
)
from langcrew.memory import MemoryConfig, ShortTermMemoryConfig, LongTermMemoryConfig
memory_config = MemoryConfig(
provider="postgresql",
connection_string="postgresql://user:pass@localhost:5432/memory_db",
short_term=ShortTermMemoryConfig(enabled=True),
long_term=LongTermMemoryConfig(enabled=True)
)
from langcrew.memory import MemoryConfig, ShortTermMemoryConfig, LongTermMemoryConfig
memory_config = MemoryConfig(
provider="sqlite",
connection_string="sqlite:///development.db",
short_term=ShortTermMemoryConfig(enabled=True),
long_term=LongTermMemoryConfig(enabled=True)
)
from langcrew.memory import MemoryConfig, ShortTermMemoryConfig
# Memory-enabled customer service
memory_config = MemoryConfig(
provider="sqlite",
connection_string="sqlite:///customer_service.db",
short_term=ShortTermMemoryConfig(enabled=True)
)
service_agent = Agent(
role="Customer Service Representative",
goal="Provide personalized customer support",
backstory="You remember customer history and preferences"
)
crew = Crew(agents=[service_agent], memory=memory_config)
# Each customer gets their own thread
result = crew.kickoff(
inputs={"user_input": "I need help with my order"},
thread_id=f"customer_{customer_id}"
)
from langcrew.memory import LongTermMemoryConfig
# Memory-enabled learning assistant
memory_config = MemoryConfig(
provider="sqlite",
connection_string="sqlite:///learning.db",
long_term=LongTermMemoryConfig(
enabled=True,
app_id="learning-assistant"
)
)
tutor = Agent(
role="Personal Tutor",
goal="Adapt teaching based on student progress",
backstory="You remember what students have learned and their difficulties"
)
crew = Crew(agents=[tutor], memory=memory_config)
  • Check your connection_string format
  • Ensure database permissions are correct
  • Verify the database file/connection is accessible
  • Use connection pooling for database providers
  • Consider using SQLite/PostgreSQL instead of in-memory
  • Use PostgreSQL for production workloads
  • Enable connection pooling for database providers
  • Consider memory provider for development/testing