Architecture & Core Concepts

This chapter covers LangChain 1.0 layering, the agent loop, and when to use LangGraph.


Layered stack

┌─────────────────────────────────────────┐
│  Your app: API, UI, jobs                │
├─────────────────────────────────────────┤
│  LangChain: create_agent, middleware    │
├─────────────────────────────────────────┤
│  LangGraph: StateGraph, checkpointer    │
├─────────────────────────────────────────┤
│  langchain-core: messages, tools, Runnable│
├─────────────────────────────────────────┤
│  Integrations: openai, anthropic, …     │
└─────────────────────────────────────────┘
  • langchain-core: vendor-neutral abstractions
  • LangGraph: stateful, loop-capable runtime with persistence
  • LangChain 1.0: standard agent loop + middleware on top of LangGraph

Agent = Model + Harness

The harness delivers the right context at the right time.

PieceRole
ModelReasoning and tool calling
ToolsExternal capabilities
System promptBehavior and boundaries
MiddlewareHooks in the loop
StateMessages and custom fields
CheckpointerCross-turn persistence
from langchain.agents import create_agent

agent = create_agent(
    model="openai:gpt-4.1",
    tools=[...],
    system_prompt="...",
    middleware=[...],
    checkpointer=...,
)

Loop on LangGraph

create_agent builds a LangGraph graph:

  • model node: LLM call, may emit tool_calls
  • tools node: run tools, append results to messages

Middleware wraps model entry/exit like web middleware.


LangChain vs LangGraph

create_agentCustom LangGraph
OnboardingLowMedium
FlexibilityMiddleware + subgraphsFull topology
Best forStandard tool agentsMixed deterministic + agentic flows
PersistencePass checkpointerNative

Guidance: start with LangChain; drop to LangGraph for custom orchestration; embed create_agent as a subgraph when needed.


Workflows vs agents

WorkflowAgent
ControlPredetermined code pathsModel decides
PredictabilityHighMedium
Exampletranslate → polish → QAsearch → read → search again

See LangGraph Workflows for patterns.


Runnable & LCEL

Pre-1.0 LCEL composed Runnables with |. Runnables remain the low-level protocol; agents are the main 1.0 path via create_agent. Integration classes like ChatOpenAI are still Runnables usable in graph nodes.


Versions

  • Align langchain 1.x with langgraph 1.x
  • Avoid legacy AgentExecutor / initialize_agent in new projects
  • Docs: docs.langchain.com

Next steps