All Frameworks

LangChain Quickstart

Give your LangChain agents persistent memory across sessions.

1Setup (30 seconds)

$ npm install -g agmry
  $ agmry init --write
  # Creates .mcp.json, shows agent instructions, test commands
  # Already have a key? agmry login --local
  # New user? agmry signup my-project --email you@co --local

2Build an Agent with Persistent Memory

Use AgenticMemory to persist conversation history across LangChain sessions.

from agenticmemoryai import AgenticMemory
from langchain_openai import ChatOpenAI
from langchain_core.messages import HumanMessage, AIMessage, SystemMessage

memory = AgenticMemory()
llm = ChatOpenAI(model="gpt-4o")

# Create or reuse a memory space
space = memory.create_space("LangChain Agent", "langchain-agent")
space_id = space["space"]["_id"]

# Bootstrap: load prior context from previous sessions
ctx = memory.bootstrap(space_id, messages=20, entries=5, semantic=True, query="project status")

# Convert stored messages to LangChain format
lc_messages = [SystemMessage(content="You are a helpful project assistant.")]
for m in ctx.get("messages", []):
    if m["role"] == "user":
        lc_messages.append(HumanMessage(content=m["content"]))
    elif m["role"] == "assistant":
        lc_messages.append(AIMessage(content=m["content"]))

# Chat loop with persistent memory
user_input = "What's the status of the auth module?"

# Store user message
memory.store(space_id, role="user", content=user_input)
lc_messages.append(HumanMessage(content=user_input))

# Get LLM response
response = llm.invoke(lc_messages)
print("Assistant:", response.content)

# Store assistant response
memory.store(space_id, role="assistant", content=response.content)

# Save a long-term summary entry
memory.add_entry(space_id, type="summary", title="Auth status check",
                 content=response.content, tags=["auth", "status"])

# Search across all memory later
results = memory.search(space_id, "auth module", limit=5, scope="all")
print("Found", len(results["results"]), "relevant memories")

3Expected Output

Assistant: Based on our previous discussions, the auth module was delivered
in Sprint 4. All tests are passing and it's deployed to staging.
Found 3 relevant memories

Starter ($1 one-time): 1 space, 1K messages/month. Upgrade to Pro ($24.99/mo) for semantic search, entries, and entities.

Help
Help

Click the icon on any page for context-sensitive help.

Quick Links