LangChain Patterns
Pattern catalog for auditing LangChain codebases — imports, code shapes, and deprecation status.
This page is a reference for the Audit & Design phase. It lists the LangChain patterns an AI assistant should search for when auditing a codebase, organized by era and type.
Eras of LangChain Code
LangChain code in the wild falls into three eras. Real codebases often mix them.
| Era | Period | Key Pattern | Status |
|---|---|---|---|
| Legacy Chains | 2022–2023 | LLMChain, SequentialChain | Deprecated in v0.1.17, removed in v1.0 |
| LCEL | 2023–present | prompt | llm | parser pipe composition | Current standard |
| LangGraph | 2024–present | StateGraph with nodes and edges | Emerging standard for stateful workflows |
Imports to Search For
Core (Current)
LangGraph
Legacy (Deprecated)
RAG (Current)
TypeScript/JavaScript
Code Shapes
These are the patterns to recognize during the audit step. Each maps to a Noukai flow topology.
LCEL Chain (Sequential)
The most common pattern in modern LangChain code. Maps to a sequential Noukai flow.
What to capture: Each segment of the pipe (prompt, model, parser) becomes a block. The prompt template becomes the block's prompt text. The model becomes the block's model config.
LCEL with RunnableParallel
Maps to a parallel container in Noukai.
What to capture: Each named branch becomes a parallel block inside a v container. The keys (summary, keywords, sentiment) suggest block names.
RunnableBranch (Routing)
Maps to a branching flow — a router block followed by conditional blocks.
What to capture: The routing logic becomes a router block (or can be encoded in prompt logic). Each branch becomes a downstream block. The default branch is the fallback.
LangGraph StateGraph
Maps to a complex Noukai flow with sequential and conditional blocks.
What to capture: Each node that contains an LLM call becomes a block. Edges define the flow topology. Conditional edges suggest branching. The State TypedDict suggests the flow's input/output schema.
Agent with Tool Calling
Maps to a single LLM block with tool configuration or a more complex flow depending on the tools.
Agent loops are the hardest pattern to migrate because Noukai flows are DAGs (directed acyclic graphs), not loops. For agent patterns, consider: (1) converting the agent to a single powerful LLM block with tool descriptions in the prompt, (2) breaking the agent into a classification block + specialized handler blocks, or (3) keeping the agent as-is and only migrating the non-agent chains.
RAG Chain
Maps to a sequential flow where the first block handles retrieval context and the second generates the answer.
The retrieval step (vector search) runs outside Noukai — it's not an LLM call. In the migrated version, your code performs the retrieval locally and passes the retrieved context as input to the Noukai flow. The Noukai flow handles only the LLM generation part.
Legacy LLMChain (Deprecated)
If found, flag as deprecated. Maps to a single LLM block.
Legacy SequentialChain (Deprecated)
If found, flag as deprecated. Maps to a sequential Noukai flow.
Memory Patterns
LangChain memory classes manage conversation history. In Noukai, the calling code manages history and passes relevant context as input to the flow.
| LangChain Memory | Status | Migration Approach |
|---|---|---|
ConversationBufferMemory | Deprecated | Pass conversation history in the flow's message or parameters input |
ConversationSummaryMemory | Deprecated | Create a separate "summarize history" flow, call it before the main flow |
ChatMessageHistory | Current | Keep as-is in calling code, pass relevant messages to the flow |
Mapping Cheat Sheet
| LangChain Pattern | Noukai Equivalent |
|---|---|
LCEL pipe (a | b | c) | Sequential blocks |
RunnableParallel | Blocks in a v (parallel) container |
RunnableBranch | Router block + conditional blocks |
StateGraph nodes | Individual blocks matching the graph topology |
StateGraph conditional edges | Branching flow logic |
AgentExecutor / tool loop | Single powerful block, or decompose into specialized blocks |
create_retrieval_chain | Retrieval in calling code → LLM blocks in Noukai flow |
LLMChain (deprecated) | Single LLM block |
SequentialChain (deprecated) | Sequential blocks |
Output parsers (JsonOutputParser) | Block output schema |
| Memory classes | Calling code manages history, passes as input |