Open-Source Wikis

/

LangChain

/

Features

langchain-ai/langchain

Features

Cross-cutting capabilities built on top of the primitives. These are the features users build agents and applications around.

Feature Page
Agentscreate_agent, the langgraph-backed agent factory agents
Middleware — composable hooks around the agent loop middleware
Structured output — strategies for shaping a model's response into a typed schema structured-output

Features in this section live primarily in libs/langchain_v1/langchain/. They build on the abstractions in primitives and the implementations in partners.

How they fit together

graph TD
    User[User app]
    Create[create_agent]
    MW[Middleware chain]
    Model[BaseChatModel]
    Tools[ToolNode]
    SO[Structured output strategy]

    User --> Create
    Create --> MW
    Create --> Model
    Create --> Tools
    Create --> SO
    MW -.intercepts.-> Model
    MW -.intercepts.-> Tools
    SO -.shapes.-> Model

A typical user invocation:

from langchain.agents import create_agent
from langchain.agents.middleware import (
    SummarizationMiddleware,
    HumanInTheLoopMiddleware,
    PIIMiddleware,
)

agent = create_agent(
    model="openai:gpt-5",
    tools=[search, write_file, run_python],
    middleware=[
        PIIMiddleware(),
        SummarizationMiddleware(max_tokens_to_summarize=4_000),
        HumanInTheLoopMiddleware(interrupt_on={"run_python": True}),
    ],
    response_format=AnalysisReport,  # structured output schema
)

result = agent.invoke({"messages": [{"role": "user", "content": "..."}]})

This builds a langgraph graph that runs each middleware around every model and tool call, applies the structured-output strategy at the end, and returns a typed AnalysisReport.

Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.

Features – LangChain wiki | Factory