An r/LangChain post described production LangChain agents as amnesic. The fix has two parts: cross-turn state (LangGraph) and unambiguous tool routing (clearly named MCP tools). This walks both.
Prerequisites
- LangChain 0.3+
- LangGraph
- Scavio API key + langchain-scavio
- Postgres or SQLite for checkpoint storage
Walkthrough
Step 1: Install LangGraph and the Scavio tool
Both ship as standard PyPI packages.
pip install langgraph langchain-scavio langchain-anthropicStep 2: Define the state shape
Track conversation history + tool-call decisions.
from typing import TypedDict, List
from langgraph.graph import StateGraph, END
class AgentState(TypedDict):
messages: List
last_tool: str
decisions: List[str]Step 3: Wire Scavio's named tools
Each tool has a clear semantic name; the LLM routes by name.
from langchain_scavio import ScavioSearchTool, ScavioRedditTool, ScavioYoutubeTool
tools = [
ScavioSearchTool(name='web_search'),
ScavioRedditTool(name='reddit_search'),
ScavioYoutubeTool(name='youtube_search'),
]Step 4: Add a checkpointer for cross-turn memory
SQLite for dev, Postgres for prod.
from langgraph.checkpoint.sqlite import SqliteSaver
checkpointer = SqliteSaver.from_conn_string(':memory:') # or 'agent.db'
graph = builder.compile(checkpointer=checkpointer)Step 5: Invoke with a thread_id for persistent memory
Each thread_id is a separate conversation memory.
config = {'configurable': {'thread_id': 'user-42'}}
result = graph.invoke({'messages': [HumanMessage('Find top AI agent threads')]}, config=config)Python Example
# The state survives across turns; the agent recalls prior tool calls and decisions.JavaScript Example
// LangGraph is Python-first. JS-side, use LangChain.js with manual state in a KV store.Expected Output
Agent that remembers prior turns and routes correctly because tools have semantic names (web_search, reddit_search, youtube_search) instead of generic 'search_v1'.