langchain-middleware

Community

Build LangChain Python middleware workflows.

Authorchristian-bromann
Version1.0.0
Installs0

System Documentation

What problem does it solve?

Middleware provides extensibility to customize LangChain agent behavior by injecting logic at key execution points such as before_model, after_model, wrap_model_call, and wrap_tool_call.

Core Features & Use Cases

  • Hook-based customization: run code before and after model/tool calls for validation, logging, or input shaping.
  • Wrap methods: intercept and modify requests and responses to route through dynamic logic or guardrails.
  • Composability: chain multiple middleware components into a single, flexible workflow.
  • Flexible definitions: implement as a class-based middleware or decorator-based hooks, with support for async operation and context.
  • Real-world scenarios: enforce guardrails, dynamically switch models, or filter available tools based on user context.

Quick Start

Create a simple LoggingMiddleware class extending AgentMiddleware and attach it to your agent to observe before_model behavior.

Dependency Matrix

Required Modules

None required

Components

Standard package

💻 Claude Code Installation

Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.

Please help me install this Skill:
Name: langchain-middleware
Download link: https://github.com/christian-bromann/langchain-skills/archive/main.zip#langchain-middleware

Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
View Source Repository

Agent Skills Search Helper

Install a tiny helper to your Agent, search and equip skill from 471,000+ vetted skills library on demand.