Module 4 cheat sheet: Production & Beyond
Trace, cache and rate-limit for real users, read old LangChain code, and build custom flows with LangGraph.
Key ideas
- Callbacks, cache, rate limiter, async and LangSmith. Lab 15 โ
- Old 0.x classes live in
langchain-classic. Lab 16 โ - LangGraph: state + nodes + edges; create_agent is built on it. Lab 17 โ
Production one-liners
set_llm_cache(InMemoryCache())
limiter = InMemoryRateLimiter(requests_per_second=0.5)
llm = ChatGroq(model="openai/gpt-oss-20b", rate_limiter=limiter,
timeout=30, max_retries=2)
os.environ["LANGSMITH_TRACING"] = "true"Old โ new
| Old | New |
|---|---|
| LLMChain | prompt | llm | parser |
| ConversationChain | checkpointer + thread_id |
| BufferWindowMemory | trim_messages |
| RetrievalQA | LCEL RAG chain |
| initialize_agent | create_agent |
| .run() | .invoke() |
LangGraph agent
b = StateGraph(MessagesState)
b.add_node("assistant", assistant)
b.add_node("tools", ToolNode(tools))
b.add_edge(START, "assistant")
b.add_conditional_edges("assistant", tools_condition)
b.add_edge("tools", "assistant")
g = b.compile(checkpointer=InMemorySaver(), interrupt_before=["tools"])Common mistakes
- Caching personal answers across users.
- No timeouts or retries.
- Copying 2023 tutorials without converting.
- No recursion limit on custom graphs.
Created by Ajeetkumar ยท EasyLearnSpace