CodeVetter · Repo Unpack · Feature catalog
langchain-ai/langchain
User-facing surface: agent construction (create_agent with middleware, structured output, persistence, interrupts), model/embeddings factories (init_chat_model, init_embeddings), tool authoring (@tool, BaseTool, ToolRuntime injection), a large built-in middleware catalog (HITL, summarization, PII, retries, limits, shell tool, file search, todo lists, tool selection/emulation), MCP server tool adaptation, and message/rate-limiter re-exports. langchain-classic preserves the legacy chains/agents API. langchain-tests ships a conformance suite for partner authors; langchain-profiles ships a CLI for model capability data.
- `create_agent(model, tools, system_prompt, middleware, response_format, state_schema, context_schema, checkpointer, store, interrupt_before, interrupt_after, debug, name, cache, transformers)` returns a `CompiledStateGraph` implementing the model->tools loop until no tool_calls remain.
- `init_chat_model` supports string specs ('provider:model'), explicit model_provider, configurable_fields producing a deferred `_ConfigurableModel`, and a special 'langsmith' provider that routes ChatOpenAI through the LangSmith gateway (LANGSMITH_GATEWAY_API_KEY / gateway.smith.langchain.com).
- `init_embeddings` provides the same lazy provider-registry pattern for ~10 embeddings providers (azure_openai, bedrock, cohere, google_genai, huggingface, mistralai, ollama, openai, ...).
- Tools are authored via the `@tool` decorator (langchain_core.tools.convert) or BaseTool subclasses; langchain.tools re-exports these plus ToolRuntime, InjectedState, and InjectedStore for runtime/state injection into tool functions.
- The built-in middleware catalog includes: SummarizationMiddleware, HumanInTheLoopMiddleware, PIIMiddleware, TodoListMiddleware, ModelRetryMiddleware, ModelFallbackMiddleware, ModelCallLimitMiddleware, ToolRetryMiddleware, ToolCallLimitMiddleware, ToolErrorMiddleware, LLMToolSelectorMiddleware, LLMToolEmulator, ContextEditingMiddleware, FilesystemFileSearchMiddleware, ProviderToolSearchMiddleware, and ShellToolMiddleware.
- Structured output is configured via `response_format` accepting a raw Pydantic/dataclass/TypedDict/JSON-schema or explicit ToolStrategy/ProviderStrategy/AutoStrategy; AutoStrategy picks provider-native output when `_supports_provider_strategy` says the model supports it.
- HumanInTheLoopMiddleware pauses tool calls via langgraph `interrupt()` with ReviewConfig policies allowing approve/edit/reject/respond decisions, and annotates edited calls with an `_EDIT_NOTICE` so the model knows the call was replaced.
- ShellToolMiddleware exposes a persistent `shell` tool executing commands under pluggable policies: HostExecutionPolicy (direct subprocess), DockerExecutionPolicy, and CodexSandboxExecutionPolicy, with output redaction via RedactionRule.
- PIIMiddleware detects emails/credit cards/IPs/MACs/URLs via `_redaction` helpers and can mutate streaming deltas in flight through `_PIIStreamTransformer` (a 128-char lookback buffer catches patterns straddling token boundaries).
- `MCPAdapter` converts FastMCP targets (URL, Path, transport, MCPConfig, in-process server, client/group) into LangChain tools via `list_tools()`, and arms clients so server elicitation requests become LangGraph interrupts answered by humans.
- langchain.messages re-exports the canonical message model (AIMessage, ToolMessage, HumanMessage, SystemMessage, content-block types, ToolCall, trim_messages) from langchain-core.
- BaseRateLimiter/InMemoryRateLimiter are re-exported from langchain.rate_limiters and are honored by BaseChatModel._generate_with_cache which acquires the limiter before hitting the provider API (but after cache lookup).
- langchain-tests (standard-tests) ships reusable conformance suites — unit_tests/chat_models.py, embeddings.py, tools.py and integration_tests/{chat_models,vectorstores,retrievers,indexer,cache,sandboxes}.py — that partner packages subclass to prove compliance.
- langchain-model-profiles ships a `langchain-profiles` CLI that generates per-model capability profile data consumed by partners' data/ dirs.
- langchain-classic retains the legacy feature surface: AgentExecutor, agent types (react, conversational, structured_chat, tool_calling_agent, openai_functions_*), and the full chains/ tree (retrieval, combine_documents, graph_qa, etc.).