Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
wshobson avatar

Langchain Architecture

  • 10.6k installs
  • 38.3k repo stars
  • Updated July 22, 2026
  • wshobson/agents

How to architect LLM applications with LangChain 1.x and LangGraph using StateGraph for state management, tool integration via Pydantic schemas, memory systems (buffer, summary, vector-based), document processing pipelin

About

This skill teaches building production-grade LLM applications using LangChain 1.x and LangGraph for explicit agent orchestration, state management, and tool integration. Developers use it when creating autonomous AI agents with memory, implementing complex multi-step workflows, managing conversation state across sessions, and integrating LLMs with external APIs and document stores. Core workflows include designing StateGraph agents with typed state, implementing ReAct and Plan-and-Execute patterns, managing short and long-term memory via checkpointers, loading and chunking documents, and observing applications with LangSmith tracing.

  • LangGraph StateGraph with typed state for explicit, durable agent execution and human-in-the-loop inspection
  • Memory systems including ConversationBufferMemory, ConversationSummaryMemory, and persistent checkpointers across sessio
  • Tool-calling with Pydantic schemas and structured invocation patterns (ReAct, Plan-and-Execute, multi-agent supervisor r
  • Document processing pipeline with loaders, text splitters, vector stores, and semantic retrievers
  • Performance optimization via Redis caching, async batch processing, and connection pooling

Langchain Architecture by the numbers

  • 10,599 all-time installs (skills.sh)
  • +198 installs in the week ending Jul 28, 2026 (Skillselion tracking)
  • Ranked #76 of 16,659 AI & Agent Building skills by installs in the Skillselion catalog
  • Security screen: HIGH risk (skills.sh audit)
  • Data as of Jul 28, 2026 (Skillselion catalog sync)
At a glance

langchain-architecture capabilities & compatibility

Per-token LLM costs (OpenAI, Anthropic); optional Redis/Pinecone hosting

Capabilities
agent orchestration with langgraph stategraph · tool calling with structured pydantic schemas · memory systems (buffer, summary, vector based, c · document loading, chunking, and retrieval · async batch processing and caching · request/response tracing and observability
Works with
openai · anthropic · redis
Use cases
orchestration · api development · memory · token optimization
Platforms
macOS · Windows · Linux · WSL
Runs
Runs locally
Pricing
Free
npx skills add https://github.com/wshobson/agents --skill langchain-architecture

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs10.6k
repo stars38.3k
Security audit2 / 3 scanners passed
Last updatedJuly 22, 2026
Repositorywshobson/agents

What it does

Design and deploy LLM agents with LangChain 1.x and LangGraph for multi-step workflows, tool integration, and persistent memory.

Who is it for?

Engineers building autonomous agents, multi-step LLM workflows, chat applications with memory, retrieval-augmented generation (RAG) systems, and agentic tools requiring tool access and state persistence.

Skip if: Simple single-turn LLM completions, rule-based chatbots, or applications not requiring tool access or multi-step reasoning.

When should I use this skill?

Designing an agent architecture, integrating external tools and APIs, implementing conversation memory, building document-aware systems, or debugging agent behavior.

What you get

Developers can design and deploy production-grade LLM agents with explicit state, reliable tool access, conversation memory, document retrieval, and full traceability via LangSmith.

  • StateGraph-based agent with typed state
  • Tool definitions with Pydantic schemas
  • Memory system (buffer, summary, or retriever-based)

By the numbers

  • LangChain 1.2.x is the current production version
  • LangGraph is the standard for agents in 2026
  • Supports memory across sessions via checkpointers

Files

SKILL.mdMarkdownGitHub ↗

LangChain & LangGraph Architecture

Master modern LangChain 1.x and LangGraph for building sophisticated LLM applications with agents, state management, memory, and tool integration.

When to Use This Skill

  • Building autonomous AI agents with tool access
  • Implementing complex multi-step LLM workflows
  • Managing conversation memory and state
  • Integrating LLMs with external data sources and APIs
  • Creating modular, reusable LLM application components
  • Implementing document processing pipelines
  • Building production-grade LLM applications

Package Structure (LangChain 1.x)

langchain (1.2.x)         # High-level orchestration
langchain-core (1.2.x)    # Core abstractions (messages, prompts, tools)
langchain-community       # Third-party integrations
langgraph                 # Agent orchestration and state management
langchain-openai          # OpenAI integrations
langchain-anthropic       # Anthropic/Claude integrations
langchain-voyageai        # Voyage AI embeddings
langchain-pinecone        # Pinecone vector store

Core Concepts

1. LangGraph Agents

LangGraph is the standard for building agents in 2026. It provides:

Key Features:

  • StateGraph: Explicit state management with typed state
  • Durable Execution: Agents persist through failures
  • Human-in-the-Loop: Inspect and modify state at any point
  • Memory: Short-term and long-term memory across sessions
  • Checkpointing: Save and resume agent state

Agent Patterns:

  • ReAct: Reasoning + Acting with create_react_agent
  • Plan-and-Execute: Separate planning and execution nodes
  • Multi-Agent: Supervisor routing between specialized agents
  • Tool-Calling: Structured tool invocation with Pydantic schemas

2. State Management

LangGraph uses TypedDict for explicit state:

from typing import Annotated, TypedDict
from langgraph.graph import MessagesState

# Simple message-based state
class AgentState(MessagesState):
    """Extends MessagesState with custom fields."""
    context: Annotated[list, "retrieved documents"]

# Custom state for complex agents
class CustomState(TypedDict):
    messages: Annotated[list, "conversation history"]
    context: Annotated[dict, "retrieved context"]
    current_step: str
    results: list

3. Memory Systems

Modern memory implementations:

  • ConversationBufferMemory: Stores all messages (short conversations)
  • ConversationSummaryMemory: Summarizes older messages (long conversations)
  • ConversationTokenBufferMemory: Token-based windowing
  • VectorStoreRetrieverMemory: Semantic similarity retrieval
  • LangGraph Checkpointers: Persistent state across sessions

4. Document Processing

Loading, transforming, and storing documents:

Components:

  • Document Loaders: Load from various sources
  • Text Splitters: Chunk documents intelligently
  • Vector Stores: Store and retrieve embeddings
  • Retrievers: Fetch relevant documents

5. Callbacks & Tracing

LangSmith is the standard for observability:

  • Request/response logging
  • Token usage tracking
  • Latency monitoring
  • Error tracking
  • Trace visualization

Quick Start

Modern ReAct Agent with LangGraph

from langgraph.prebuilt import create_react_agent
from langgraph.checkpoint.memory import MemorySaver
from langchain_anthropic import ChatAnthropic
from langchain_core.tools import tool
import ast
import operator

# Initialize LLM (Claude Sonnet 4.6 recommended)
llm = ChatAnthropic(model="claude-sonnet-4-6", temperature=0)

# Define tools with Pydantic schemas
@tool
def search_database(query: str) -> str:
    """Search internal database for information."""
    # Your database search logic
    return f"Results for: {query}"

@tool
def calculate(expression: str) -> str:
    """Safely evaluate a mathematical expression.

    Supports: +, -, *, /, **, %, parentheses
    Example: '(2 + 3) * 4' returns '20'
    """
    # Safe math evaluation using ast
    allowed_operators = {
        ast.Add: operator.add,
        ast.Sub: operator.sub,
        ast.Mult: operator.mul,
        ast.Div: operator.truediv,
        ast.Pow: operator.pow,
        ast.Mod: operator.mod,
        ast.USub: operator.neg,
    }

    def _eval(node):
        if isinstance(node, ast.Constant):
            return node.value
        elif isinstance(node, ast.BinOp):
            left = _eval(node.left)
            right = _eval(node.right)
            return allowed_operators[type(node.op)](left, right)
        elif isinstance(node, ast.UnaryOp):
            operand = _eval(node.operand)
            return allowed_operators[type(node.op)](operand)
        else:
            raise ValueError(f"Unsupported operation: {type(node)}")

    try:
        tree = ast.parse(expression, mode='eval')
        return str(_eval(tree.body))
    except Exception as e:
        return f"Error: {e}"

tools = [search_database, calculate]

# Create checkpointer for memory persistence
checkpointer = MemorySaver()

# Create ReAct agent
agent = create_react_agent(
    llm,
    tools,
    checkpointer=checkpointer
)

# Run agent with thread ID for memory
config = {"configurable": {"thread_id": "user-123"}}
result = await agent.ainvoke(
    {"messages": [("user", "Search for Python tutorials and calculate 25 * 4")]},
    config=config
)

Detailed patterns and worked examples

Detailed pattern documentation lives in references/details.md. Read that file when the navigation tier above is insufficient.

Testing Strategies

import pytest
from unittest.mock import AsyncMock, patch

@pytest.mark.asyncio
async def test_agent_tool_selection():
    """Test agent selects correct tool."""
    with patch.object(llm, 'ainvoke') as mock_llm:
        mock_llm.return_value = AsyncMock(content="Using search_database")

        result = await agent.ainvoke({
            "messages": [("user", "search for documents")]
        })

        # Verify tool was called
        assert "search_database" in str(result)

@pytest.mark.asyncio
async def test_memory_persistence():
    """Test memory persists across invocations."""
    config = {"configurable": {"thread_id": "test-thread"}}

    # First message
    await agent.ainvoke(
        {"messages": [("user", "Remember: the code is 12345")]},
        config
    )

    # Second message should remember
    result = await agent.ainvoke(
        {"messages": [("user", "What was the code?")]},
        config
    )

    assert "12345" in result["messages"][-1].content

Performance Optimization

1. Caching with Redis

from langchain_community.cache import RedisCache
from langchain_core.globals import set_llm_cache
import redis

redis_client = redis.Redis.from_url("redis://localhost:6379")
set_llm_cache(RedisCache(redis_client))

2. Async Batch Processing

import asyncio
from langchain_core.documents import Document

async def process_documents(documents: list[Document]) -> list:
    """Process documents in parallel."""
    tasks = [process_single(doc) for doc in documents]
    return await asyncio.gather(*tasks)

async def process_single(doc: Document) -> dict:
    """Process a single document."""
    chunks = text_splitter.split_documents([doc])
    embeddings = await embeddings_model.aembed_documents(
        [c.page_content for c in chunks]
    )
    return {"doc_id": doc.metadata.get("id"), "embeddings": embeddings}

3. Connection Pooling

from langchain_pinecone import PineconeVectorStore
from pinecone import Pinecone

# Reuse Pinecone client
pc = Pinecone(api_key=os.environ["PINECONE_API_KEY"])
index = pc.Index("my-index")

# Create vector store with existing index
vectorstore = PineconeVectorStore(index=index, embedding=embeddings)

Related skills

How it compares

Pick langchain-architecture when you need end-to-end LangGraph graph structure and RAG wiring examples rather than generic LLM prompt tips.

FAQ

What is the difference between LangGraph and the deprecated AgentExecutor?

LangGraph is the standard for agents in 2026, providing explicit state management with TypedDict, durable execution with checkpointing, human-in-the-loop inspection, and reliable tool-calling. AgentExecutor is deprecated in favor of LangGraph's StateGraph for explicit control.

How do I persist agent memory across separate conversations?

Use LangGraph's MemorySaver checkpointer and pass a configurable thread_id to agent.ainvoke(). This saves and resumes typed state (messages, context, custom fields) across invocations without losing conversation history.

What memory system should I use for long conversations?

For long conversations, use ConversationSummaryMemory which summarizes older messages, ConversationTokenBufferMemory for token-based windowing, or VectorStoreRetrieverMemory for semantic retrieval. LangGraph checkpointers handle session-level persistence.

Is Langchain Architecture safe to install?

skills.sh reports 2 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.

AI & Agent Buildingagentsllmautomation

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.