Index of every page on this site: llms.txt
All skills
langchain-ai avatar

/langchain-middleware

@7a385cd official
Run it yourself

Retired skill, replaced by `langchain-build-agent`. Use for LangChain agent middleware: it tells you to switch to `langchain-build-agent`.

Use this Skill: https://skilld.dev/gh/langchain-ai/langchain-skills/langchain-middleware

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

SKILL.md

≈40 tokens for metadata: the name and description. ≈121 when used: this file.

Description uses 2.0% of example budget

Before choosing a Skill, your Agent reads its name and description. All available Skills share that space.

  • A shorter description leaves more room for other Skills. This entry exceeds our 1% size suggestion.

In our Claude Code example, all Skill names and descriptions share 8,000 characters. This Skill uses ≈161 characters, or 2.0%.

The 1% threshold is a size suggestion. Longer descriptions can still fit.

Your model, settings, and other Skills decide how much text your Agent can read.

Example settings and source

The example uses a 200k-token context and default Claude Code settings. The count includes the name, description, separators, and when_to_use when present. Codex also counts local file paths.

Skit's source and limits: Codex 0.160.1, Claude Code 2.1.292.

langchain-middleware (retired)

langchain-middleware was retired from langchain-skills. Use the langchain-build-agent skill instead.

  1. If langchain-build-agent is available, use it for this task.

  2. Otherwise, install it, then use it:

    npx skills add langchain-ai/langchain-skills --skill langchain-build-agent --yes
  3. Tell the user that langchain-middleware is retired and that they can remove it with npx skills remove langchain-middleware.

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

1 warning1d5 checks · Risk SAFE
  • Gen Agent Trust Hub1d

    This skill is a redirection utility that informs the agent that the skill has been retired and replaced by a newer version. It includes an installation command for the updated replacement skill from the official project source.

  • Socket2mo

    No alerts

  • Snyk1d

    Risk: MEDIUM · 1 issue

  • Runlayer8mo

    1 file scanned · No issues

  • ZeroLeaks7mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at 7a385cd. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub yesterday.

Activeupdated yesterday
metadata
{
  "internal": "true"
}
  • TypeScript
  • Python
  • langchain
  • middleware
  • human-in-the-loop
  • agents
  • tool-approval
  • checkpointing
  • langgraph

README badge

README badge for langchain-ai/langchain-skills/langchain-middleware

Adds human-in-the-loop approval middleware to LangChain agents, pausing before dangerous tool calls (e.g., sending emails, deleting data) and allowing humans to approve, edit arguments, or reject with feedback. Also covers custom middleware hooks for logging, retry logic, and error handling across the agent lifecycle.

Generated from the current SKILL.md.

Does this skill require a checkpointer?
Yes. Human-in-the-loop middleware requires a checkpointer (e.g. MemorySaver) to persist agent state across interrupts and resumptions.
Can I configure different approval policies for different tools?
Yes. HumanInTheLoopMiddleware accepts a per-tool interrupt_on dict where you can set allowed decisions (approve, edit, reject) for each tool, or disable HITL entirely for low-risk tools.
How do I resume an agent after a human approval or rejection?
Use the Command class with a resume dict containing a decisions array. Each decision specifies the type (approve, edit, or reject) and optionally edited_action or feedback.
What middleware hooks are available?
Six hooks: wrap_tool_call and wrap_model_call (which wrap the handler), plus before_model, after_model, before_agent, and after_agent (which inspect or modify state). Use wrap hooks to short-circuit execution; before/after hooks to log or modify flow.
Do I need to provide a thread_id when invoking the agent?
Yes. Always pass thread_id in the config's configurable dict when using HITL to track and resume conversation state correctly.

Generated from the current SKILL.md. These answers refresh after source changes.