langchain-fundamentals

Create LangChain agents with create_agent, tools, middleware, and structured output.

Updated Jan 10, 2026
One-click install
npx skills add https://github.com/orezek/monorepo_template --skill langchain-fundamentals-orezek
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: langchain-fundamentals
Source: https://github.com/orezek/monorepo_template/tree/main/.agents/skills/langchain-fundamentals
Command: npx skills add https://github.com/orezek/monorepo_template --skill langchain-fundamentals-orezek

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Building production agents with LangChain requires knowing the current recommended APIs and avoiding common pitfalls like missing persistence, runaway loops, and vague tool descriptions. This Skill provides the canonical patterns for creating agents with create_agent, defining tools, adding middleware, and handling errors in both Python and TypeScript. ## Core Features & Use Cases - Agent Creation with create_agent: Configure models, tools, system prompts, checkpointers, and middleware using the recommended API. - Middleware Patterns: Implement human-in-the-loop approval workflows and custom tool-call hooks with HumanInTheLoopMiddleware and wrap_tool_call. - Common Fixes: Resolve missing tool descriptions, absent checkpointers, infinite loops via recursion_limit, and incorrect result access. - Use Case: You need a support agent that remembers conversation context, requires human approval before executing dangerous tools, and returns typed structured responses. This Skill gives you the exact code patterns for all three requirements. ## Quick Start Create a LangChain agent with create_agent that uses a weather tool, persists state with MemorySaver, and requires human approval for dangerous actions.

Frequently Asked Questions about langchain-fundamentals

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create a LangChain agent with tools?▼

Use create_agent with a model string, a list of tools, and a system prompt. Define tools with the @tool decorator in Python or the tool() function with a zod schema in TypeScript, then pass them to the tools parameter.

How to add human-in-the-loop approval to a LangChain agent?▼

Add HumanInTheLoopMiddleware (Python) or humanInTheLoopMiddleware (TypeScript) to the middleware list with interrupt_on specifying which tools need approval. This requires a checkpointer and thread_id, and you resume with Command(resume={"decisions": [{"type": "approve"}]}).

Why does my LangChain agent forget previous messages?▼

The agent lacks a checkpointer, so state is not persisted between invocations. Add MemorySaver as the checkpointer and pass a consistent thread_id in the config so the agent maintains conversation memory across calls.

How do I stop a LangChain agent from looping forever?▼

Set recursion_limit in the invoke config to cap the number of agent steps. For example, pass config={"recursion_limit": 10} in Python or { recursionLimit: 10 } in TypeScript to halt execution after 10 iterations.

Does create_agent support structured output?▼

Yes, pass a Pydantic model or zod schema as response_format to create_agent, and the result includes a structured_response field. Alternatively, call with_structured_output directly on a chat model when no agent loop is needed.