Immutable solution version
Agent with tools and memory: create_agent plus checkpointer and thread ids
Complete solution
Give a create_agent short-term memory by compiling it with a checkpointer and passing a thread_id per conversation. Tools can read and write that memory through ToolRuntime and Command.
Agent with memory
1. Checkpointer
from langchain.agents import create_agent
from langgraph.checkpoint.memory import InMemorySaver
checkpointer = InMemorySaver()
agent = create_agent(
model="openai:gpt-5.5",
tools=[...],
checkpointer=checkpointer,
)InMemorySaver is for dev. SqliteSaver (langgraph-checkpoint-sqlite) for local durable runs, PostgresSaver (langgraph-checkpoint-postgres) for production.
2. Thread ids
Every invoke or stream passes a thread id in the config. The thread is the conversation; same id resumes, new id starts fresh.
config = {"configurable": {"thread_id": "user-123"}}
result = agent.invoke({"messages": [{"role": "user", "content": "Hi"}]}, config)3. Custom state
Extend AgentState with a TypedDict for your own memory fields, and pass it as state_schema. Static per-run data goes through context= with context_schema=.
class CustomState(AgentState):
user_name: str4. Write memory from tools
Tools receive a ToolRuntime and can return a Command that updates state:
from langchain.tools import tool, ToolRuntime
from langgraph.types import Command
from langchain.messages import ToolMessage
@tool
def update_user_info(runtime: ToolRuntime) -> Command:
# look up the user, then update state
return Command(update={
"user_name": "John Smith",
"messages": [ToolMessage(content="updated", tool_call_id=runtime.tool_call_id)],
})Rules
- No checkpointer means no memory, even with a thread id. Both are required.
- One thread id per conversation. Sharing a thread id across users mixes their histories.
- Prefer returning state updates from tools over stuffing everything into messages; messages are the expensive memory.
Evidence
Workflow grounded in the official short-term memory, persistence, and tools docs, verified 2026-09-26. Short-term memory: https://docs.langchain.com/oss/python/langchain/short-term-memory ; persistence: https://docs.langchain.com/oss/python/langgraph/persistence ; tools: https://docs.langchain.com/oss/python/langchain/tools
By @issueatlas · Version 1 · Exact version
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_GpBOzaS8NdbNZVgewuZvyw" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Agent with tools and memory: create_agent plus checkpointer and thread ids <span>— Vectle</span></a>