Tool Design
agentailor/fullstack-langgraph-nextjs-agent
Design and verify tools that AI agents can actually use — for any framework or language (MCP servers, LangChain/LangGraph, function-calling, raw JSON schema; TypeScript, Python, or otherwise).
INVOKE THIS SKILL when you need human-in-the-loop approval, custom middleware, or structured output.
$ npx skills add langchain-ai/langchain-skills --skill langchain-middleware -a claude-codeProject install by default; add -g for ~/.claude/skills/.
$ gh skill install langchain-ai/langchain-skills langchain-middleware --agent claude-codeProject scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).
$ git clone --depth 1 https://github.com/langchain-ai/langchain-skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/config/skills/langchain-middleware .claude/skills/langchain-middleware && rm -rf skills-srcUse ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.
Claude Code skills documentation · loads skills from .claude/skills/
Install the "langchain-middleware" agent skill from https://github.com/langchain-ai/langchain-skills/tree/main/config/skills/langchain-middleware into .claude/skills/langchain-middleware/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "langchain-middleware", then confirm the skill loads.Claude Code copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$skill-installer install https://github.com/langchain-ai/langchain-skills/tree/main/config/skills/langchain-middlewareType this inside Codex. $skill-installer <name> installs a curated skill from openai/skills. The installer writes to $CODEX_HOME/skills (default ~/.codex/skills). Restart Codex if the skill does not show up.
$ npx skills add langchain-ai/langchain-skills --skill langchain-middleware -a codexProject install goes to .agents/skills/; add -g for ~/.codex/skills/.
$ gh skill install langchain-ai/langchain-skills langchain-middleware --agent codexProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/langchain-ai/langchain-skills.git skills-src && mkdir -p .agents/skills && cp -r skills-src/config/skills/langchain-middleware .agents/skills/langchain-middleware && rm -rf skills-srcUse ~/.agents/skills/ instead of .agents/skills for a personal install.
Codex skills documentation · loads skills from .agents/skills/
Install the "langchain-middleware" agent skill from https://github.com/langchain-ai/langchain-skills/tree/main/config/skills/langchain-middleware into .agents/skills/langchain-middleware/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "langchain-middleware", then confirm the skill loads.Codex copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add langchain-ai/langchain-skills --skill langchain-middleware -a cursorProject install goes to .agents/skills/; add -g for ~/.cursor/skills/.
$ gh skill install langchain-ai/langchain-skills langchain-middleware --agent cursorProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/langchain-ai/langchain-skills.git skills-src && mkdir -p .cursor/skills && cp -r skills-src/config/skills/langchain-middleware .cursor/skills/langchain-middleware && rm -rf skills-srcUse ~/.cursor/skills/ instead of .cursor/skills for a personal install.
Cursor skills documentation · loads skills from .cursor/skills/, .agents/skills/, .claude/skills/, .codex/skills/
Install the "langchain-middleware" agent skill from https://github.com/langchain-ai/langchain-skills/tree/main/config/skills/langchain-middleware into .cursor/skills/langchain-middleware/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "langchain-middleware", then confirm the skill loads.Cursor copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ gemini skills install https://github.com/langchain-ai/langchain-skills.git --path config/skills/langchain-middleware--scope user (default) or --scope workspace; --path is the subfolder of the repo that holds the skill; --consent skips the security confirmation prompt.
$ npx skills add langchain-ai/langchain-skills --skill langchain-middleware -a gemini-cliProject install goes to .agents/skills/; add -g for ~/.gemini/skills/.
$ gh skill install langchain-ai/langchain-skills langchain-middleware --agent gemini-cliProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/langchain-ai/langchain-skills.git skills-src && mkdir -p .gemini/skills && cp -r skills-src/config/skills/langchain-middleware .gemini/skills/langchain-middleware && rm -rf skills-srcUse ~/.gemini/skills/ instead of .gemini/skills for a personal install, then run /skills reload.
Gemini CLI skills documentation · loads skills from .gemini/skills/, .agents/skills/
Install the "langchain-middleware" agent skill from https://github.com/langchain-ai/langchain-skills/tree/main/config/skills/langchain-middleware into .gemini/skills/langchain-middleware/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "langchain-middleware", then confirm the skill loads.Gemini CLI copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ gh skill install langchain-ai/langchain-skills langchain-middlewareInstalls for Copilot at project scope by default; add --scope user for a personal install. Preview a skill first with gh skill preview. Needs GitHub CLI 2.90.0 or later (public preview).
$ npx skills add langchain-ai/langchain-skills --skill langchain-middleware -a github-copilotProject install goes to .agents/skills/; add -g for ~/.copilot/skills/.
$ git clone --depth 1 https://github.com/langchain-ai/langchain-skills.git skills-src && mkdir -p .github/skills && cp -r skills-src/config/skills/langchain-middleware .github/skills/langchain-middleware && rm -rf skills-srcUse ~/.copilot/skills/ instead of .github/skills for a personal install. Commit .github/skills so cloud agent and code review can use it.
GitHub Copilot skills documentation · loads skills from .github/skills/, .claude/skills/, .agents/skills/
Install the "langchain-middleware" agent skill from https://github.com/langchain-ai/langchain-skills/tree/main/config/skills/langchain-middleware into .github/skills/langchain-middleware/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "langchain-middleware", then confirm the skill loads.GitHub Copilot copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add langchain-ai/langchain-skills --skill langchain-middleware -a opencodeOpenCode documents no install command of its own. Project install goes to .agents/skills/; add -g for ~/.config/opencode/skills/.
$ gh skill install langchain-ai/langchain-skills langchain-middleware --agent opencodeProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/langchain-ai/langchain-skills.git skills-src && mkdir -p .opencode/skills && cp -r skills-src/config/skills/langchain-middleware .opencode/skills/langchain-middleware && rm -rf skills-srcUse ~/.config/opencode/skills/ instead of .opencode/skills for a personal install.
OpenCode skills documentation · loads skills from .opencode/skills/, .claude/skills/, .agents/skills/
Install the "langchain-middleware" agent skill from https://github.com/langchain-ai/langchain-skills/tree/main/config/skills/langchain-middleware into .opencode/skills/langchain-middleware/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "langchain-middleware", then confirm the skill loads.OpenCode copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
langchain-middlewareINVOKE THIS SKILL when you need human-in-the-loop approval, custom middleware, or structured output.
Langchain Middleware is an agent skill from langchain-ai/langchain-skills, published by the product's own GitHub organization. INVOKE THIS SKILL when you need human-in-the-loop approval, custom middleware, or structured output. Covers HumanInTheLoopMiddleware for human approval of dangerous tool calls, creating custom middleware with hooks, Command resume patterns, and structured output with Pydantic/Zod.
Its SKILL.md is about 2.7k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.
It sits in AI & LLM Engineering, covering Building AI agents, Human-in-the-loop approvals and Structured output and tool calling. It works with LangChain, Pydantic, Zod and Python. The licence is MIT.
Read from SKILL.md and the folder at commit 16a992f. It shows what the files ask for, not the result of running them.
Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.
From allowed-tools in the SKILL.md frontmatter.
No scripts in the folder and no shell commands in SKILL.md (its code samples are python and typescript).
From the folder's file list and the shell code blocks in SKILL.md.
No URLs in SKILL.md.
From URLs in SKILL.md, links to its own repository left out.
Names no API keys, tokens, secrets or passwords.
From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.
Langchain Middleware loads about 2.7k tokens when it runs. Until then it costs about 76 tokens; SKILL.md has 381 words of instructions outside code blocks.
Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.
The automated check found no risky patterns in SKILL.md.
Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.
The full file from langchain-ai/langchain-skills at commit 16a992f, republished under its MIT licence (© langchain-ai). 381 words, ~2,690 tokens.
.claude/skills/langchain-middleware/SKILL.md (or your agent's skills folder).<overview>
Middleware patterns for production LangChain agents:
Requirements: Checkpointer + thread_id config for all HITL workflows.
</overview>
<ex-basic-hitl-setup>
<python>
Set up an agent with HITL middleware that pauses before sending emails for approval.
from langchain.agents import create_agent
from langchain.agents.middleware import HumanInTheLoopMiddleware
from langgraph.checkpoint.memory import MemorySaver
from langchain.tools import tool
@tool
def send_email(to: str, subject: str, body: str) -> str:
"""Send an email."""
return f"Email sent to {to}"
agent = create_agent(
model="gpt-4.1",
tools=[send_email],
checkpointer=MemorySaver(), # Required for HITL
middleware=[
HumanInTheLoopMiddleware(
interrupt_on={
"send_email": {"allowed_decisions": ["approve", "edit", "reject"]},
}
)
],
)</python>
<typescript>
Set up an agent with HITL that pauses before sending emails for human approval.
import { createAgent, humanInTheLoopMiddleware } from "langchain";
import { MemorySaver } from "@langchain/langgraph";
import { tool } from "@langchain/core/tools";
import { z } from "zod";
const sendEmail = tool(
async ({ to, subject, body }) => `Email sent to ${to}`,
{
name: "send_email",
description: "Send an email",
schema: z.object({ to: z.string(), subject: z.string(), body: z.string() }),
}
);
const agent = createAgent({
model: "anthropic:claude-sonnet-4-5",
tools: [sendEmail],
checkpointer: new MemorySaver(),
middleware: [
humanInTheLoopMiddleware({
interruptOn: { send_email: { allowedDecisions: ["approve", "edit", "reject"] } },
}),
],
});</typescript>
</ex-basic-hitl-setup>
<ex-running-with-interrupts>
<python>
Run the agent, detect an interrupt, then resume execution after human approval.
from langgraph.types import Command
config = {"configurable": {"thread_id": "session-1"}}
# Step 1: Agent runs until it needs to call tool
result1 = agent.invoke({
"messages": [{"role": "user", "content": "Send email to john@example.com"}]
}, config=config)
# Check for interrupt
if "__interrupt__" in result1:
print(f"Waiting for approval: {result1['__interrupt__']}")
# Step 2: Human approves
result2 = agent.invoke(
Command(resume={"decisions": [{"type": "approve"}]}),
config=config
)</python>
<typescript>
Run the agent, detect an interrupt, then resume execution after human approval.
import { Command } from "@langchain/langgraph";
const config = { configurable: { thread_id: "session-1" } };
// Step 1: Agent runs until it needs to call tool
const result1 = await agent.invoke({
messages: [{ role: "user", content: "Send email to john@example.com" }]
}, config);
// Check for interrupt
if (result1.__interrupt__) {
console.log(`Waiting for approval: ${result1.__interrupt__}`);
}
// Step 2: Human approves
const result2 = await agent.invoke(
new Command({ resume: { decisions: [{ type: "approve" }] } }),
config
);</typescript>
</ex-running-with-interrupts>
<ex-editing-tool-arguments>
<python>
Edit the tool arguments before approving when the original values need correction.
# Human edits the arguments — edited_action must include name + args
result2 = agent.invoke(
Command(resume={
"decisions": [{
"type": "edit",
"edited_action": {
"name": "send_email",
"args": {
"to": "alice@company.com", # Fixed email
"subject": "Project Meeting - Updated",
"body": "...",
},
},
}]
}),
config=config
)</python>
<typescript>
Edit the tool arguments before approving when the original values need correction.
// Human edits the arguments — editedAction must include name + args
const result2 = await agent.invoke(
new Command({
resume: {
decisions: [{
type: "edit",
editedAction: {
name: "send_email",
args: {
to: "alice@company.com", // Fixed email
subject: "Project Meeting - Updated",
body: "...",
},
},
}]
}
}),
config
);</typescript>
</ex-editing-tool-arguments>
<ex-rejecting-with-feedback>
<python>
Reject a tool call and provide feedback explaining why it was rejected.
# Human rejects
result2 = agent.invoke(
Command(resume={
"decisions": [{
"type": "reject",
"feedback": "Cannot delete customer data without manager approval",
}]
}),
config=config
)</python>
</ex-rejecting-with-feedback>
<ex-multiple-tools-different-policies>
<python>
Configure different HITL policies for each tool based on risk level.
agent = create_agent(
model="gpt-4.1",
tools=[send_email, read_email, delete_email],
checkpointer=MemorySaver(),
middleware=[
HumanInTheLoopMiddleware(
interrupt_on={
"send_email": {"allowed_decisions": ["approve", "edit", "reject"]},
"delete_email": {"allowed_decisions": ["approve", "reject"]}, # No edit
"read_email": False, # No HITL for reading
}
)
],
)</python>
</ex-multiple-tools-different-policies>
<boundaries>
### What You CAN Configure
before_model, after_model, wrap_tool_call, before_agent, after_agent</boundaries>
Six decorator hooks are available. Two patterns:
wrap_tool_call, wrap_model_call): (request, handler) — call handler(request) to proceed, or return early to short-circuit.before_model, after_model, before_agent, after_agent): (state, runtime) — inspect or modify state. Return None or a dict of state updates.<ex-wrap-tool-call>
<python>
`@wrap_tool_call` intercepts tool execution. **Do NOT use `yield`** — it creates a generator and causes `NotImplementedError`.
from langchain.agents.middleware import wrap_tool_call
@wrap_tool_call
def retry_middleware(request, handler):
for attempt in range(3):
try:
return handler(request)
except Exception:
if attempt == 2:
raise
@wrap_tool_call
def guard_middleware(request, handler):
if request.tool_call["name"] == "dangerous_tool":
return "This tool is disabled" # short-circuit
return handler(request)</python>
<typescript>
`createMiddleware({ wrapToolCall })` intercepts tool execution.
import { createMiddleware } from "langchain";
const retryMiddleware = createMiddleware({
wrapToolCall: async (request, handler) => {
for (let attempt = 0; attempt < 3; attempt++) {
try { return await handler(request); }
catch (e) { if (attempt === 2) throw e; }
}
},
});</typescript>
</ex-wrap-tool-call>
<ex-before-after-hooks>
<python>
`before_model` / `after_model` / `before_agent` / `after_agent` all share `(state, runtime)` signature.
from langchain.agents.middleware import before_model, after_model
@before_model
def log_calls(state, runtime):
print(f"Calling model with {len(state['messages'])} messages")
@after_model
def check_output(state, runtime):
print(f"Model responded")</python>
<typescript>
All before/after hooks share the same `(state, runtime)` signature via `createMiddleware`.
import { createMiddleware } from "langchain";
const loggingMiddleware = createMiddleware({
beforeModel: (state, runtime) => {
console.log(`Calling model with ${state.messages.length} messages`);
},
afterModel: (state, runtime) => {
console.log("Model responded");
},
});</typescript>
</ex-before-after-hooks>
<boundaries>
### What You CANNOT Configure
</boundaries>
<fix-missing-checkpointer>
<python>
HITL middleware requires a checkpointer to persist state.
# WRONG
agent = create_agent(model="gpt-4.1", tools=[send_email], middleware=[HumanInTheLoopMiddleware({...})])
# CORRECT
agent = create_agent(
model="gpt-4.1", tools=[send_email],
checkpointer=MemorySaver(), # Required
middleware=[HumanInTheLoopMiddleware({...})]
)</python>
<typescript>
HITL requires a checkpointer to persist state.
// WRONG: No checkpointer
const agent = createAgent({
model: "anthropic:claude-sonnet-4-5", tools: [sendEmail],
middleware: [humanInTheLoopMiddleware({ interruptOn: { send_email: true } })],
});
// CORRECT: Add checkpointer
const agent = createAgent({
model: "anthropic:claude-sonnet-4-5", tools: [sendEmail],
checkpointer: new MemorySaver(),
middleware: [humanInTheLoopMiddleware({ interruptOn: { send_email: true } })],
});</typescript>
</fix-missing-checkpointer>
<fix-no-thread-id>
<python>
Always provide thread_id when using HITL to track conversation state.
# WRONG
agent.invoke(input) # No config!
# CORRECT
agent.invoke(input, config={"configurable": {"thread_id": "user-123"}})</python>
</fix-no-thread-id>
<fix-wrong-resume-syntax>
<python>
Use Command class to resume execution after an interrupt.
# WRONG
agent.invoke({"resume": {"decisions": [...]}})
# CORRECT
from langgraph.types import Command
agent.invoke(Command(resume={"decisions": [{"type": "approve"}]}), config=config)</python>
<typescript>
Use Command class to resume execution after an interrupt.
// WRONG
await agent.invoke({ resume: { decisions: [...] } });
// CORRECT
import { Command } from "@langchain/langgraph";
await agent.invoke(new Command({ resume: { decisions: [{ type: "approve" }] } }), config);</typescript>
</fix-wrong-resume-syntax>
© langchain-ai, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file
Just SKILL.md in config/skills/langchain-middleware of langchain-ai/langchain-skills.
Open the folder on GitHubat commit 16a992f
We found 1 copy of this SKILL.md (exact, near-identical or edited) in other folders. This page covers the copy in langchain-ai/langchain-skills, which our catalogue first saw on October 7, 2026.
Langchain Middleware next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.
| Skill | Stars | Used in | Tokens | Auto-check | Licence | Repo updated |
|---|---|---|---|---|---|---|
| Langchain Middleware this skilllangchain-ai/langchain-skills | 1.3k | — | ~2.7k | Automated safety check: Pass | MIT | |
| Tool Designagentailor/fullstack-langgraph-nextjs-agent | 132 | — | ~3.2k | Automated safety check: Pass | MIT | |
| Building Pydantic AI Agentsdocling-project/docling | 69k | — | ~2.8k | Automated safety check: Pass | MIT | |
| Add Example AgentGetBindu/Bindu | 10k | — | ~1.1k | Automated safety check: Notes | Custom licence | |
| Failproof AI SDK IntegrationFailproofAI/failproofai | 5.3k | — | ~6k | Automated safety check: Pass | Custom licence | |
| Prompt Engineering Patternswshobson/agents | 40k | — | ~1.3k | Automated safety check: Pass | MIT |
agentailor/fullstack-langgraph-nextjs-agent
Design and verify tools that AI agents can actually use — for any framework or language (MCP servers, LangChain/LangGraph, function-calling, raw JSON schema; TypeScript, Python, or otherwise).
docling-project/docling
Patterns and tested examples for building agents with Pydantic AI: tools, capabilities, structured output, dependency injection, hooks, YAML specs, streaming and testing.
GetBindu/Bindu
Add a new self-contained example agent under examples/. An agent skill from GetBindu/Bindu.
FailproofAI/failproofai
Helps instrument a custom Python or TypeScript agent to record events for Failproof AI, verify what gets written, and run an evaluator worker that scores the runs.
wshobson/agents
Reference for designing and tuning production LLM prompts: few-shot examples, chain-of-thought, structured outputs, templates and system prompts.
langchain-ai/docs
Add, move, rename, or delete a page on the LangChain docs site.
langchain-ai/langchain-skills
Builds agent evaluations in stages: inspect the repository and traces, agree a Task Spec with you, then build, audit and run a Harbor task with an independent verifier.
langchain-ai/langchain-skills
Fans a list of independent items out to subagents in parallel, merges the results back into a table and supports retrying only the rows that failed.
langchain-ai/langchain-skills
INVOKE THIS SKILL when implementing human-in-the-loop patterns, pausing for approval, or handling errors in LangGraph.
langchain-ai/langchain-skills
Routes LangGraph agents with typed decision models that return probabilities, and finds LLM calls that only exist to produce a routing decision.
langchain-ai/langchain-skills
INVOKE THIS SKILL when your LangGraph needs to persist state, remember conversations, travel through history, or configure subgraph checkpointer scoping.
langchain-ai/langchain-skills
Explains how to build agents with the Deep Agents framework: create_deep_agent, the built-in middleware, the harness, SKILL.md format and configuration options.
Works with
Categories
INVOKE THIS SKILL when you need human-in-the-loop approval, custom middleware, or structured output. Langchain Middleware is an agent skill from langchain-ai/langchain-skills, published by the product's own GitHub organization. INVOKE THIS SKILL when you need human-in-the-loop approval, custom middleware, or structured output.
Langchain Middleware fits situations like: tasks that involve Building AI agents; tasks that involve Human-in-the-loop approvals; tasks that involve Structured output and tool calling.
Run `npx skills add langchain-ai/langchain-skills --skill langchain-middleware -a claude-code`. Or copy the skill folder (config/skills/langchain-middleware in langchain-ai/langchain-skills) into .claude/skills/langchain-middleware in your project. Claude Code loads it when a task matches its description.
Run `npx skills add langchain-ai/langchain-skills --skill langchain-middleware -a codex`. Or copy the skill folder (config/skills/langchain-middleware in langchain-ai/langchain-skills) into .agents/skills/langchain-middleware in your project. Codex loads it when a task matches its description.
Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add langchain-ai/langchain-skills --skill langchain-middleware -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/langchain-middleware, .gemini/skills/langchain-middleware, .github/skills/langchain-middleware and .opencode/skills/langchain-middleware in your project.
SKILL.md names no scripts, command-line tools or credentials: Langchain Middleware is instructions for the agent only. Our summary lists: Python 3.
SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.
Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.
Langchain Middleware is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.
About 2.7k tokens (SKILL.md is roughly 11k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.
Skills that share tags, products or a category with Langchain Middleware: Tool Design (agentailor/fullstack-langgraph-nextjs-agent, 132 stars), Building Pydantic AI Agents (docling-project/docling, 69k stars), Add Example Agent (GetBindu/Bindu, 10k stars) and Failproof AI SDK Integration (FailproofAI/failproofai, 5.3k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.
langchain-ai (a GitHub organization, an official publisher) maintains it in langchain-ai/langchain-skills, which has 1,274 GitHub stars. The repository holds 22 skills in this directory. The repository was last updated on October 8, 2026.
Source: langchain-ai/langchain-skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.