langchain-fundamentals

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

Updated May 1, 2026
One-click install
npx skills add https://github.com/ricardoo022/4dill --skill langchain-fundamentals-ricardoo022
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: langchain-fundamentals
Source: https://github.com/ricardoo022/4dill/tree/main/.gemini/skills/langchain-fundamentals
Command: npx skills add https://github.com/ricardoo022/4dill --skill langchain-fundamentals-ricardoo022

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Building LangChain agents often leads to outdated patterns, missing memory, runaway loops, and incorrect result handling. This Skill provides the current canonical patterns for creating agents with create_agent, defining tools, adding middleware, and avoiding common mistakes. ## Core Features & Use Cases - Agent Creation: Build agents with create_agent using model strings or instances, system prompts, tools, and checkpointers in both Python and TypeScript. - Middleware & Human-in-the-Loop: Add HumanInTheLoopMiddleware for approval workflows and custom hooks via wrap_tool_call or createMiddleware. - Structured Output & Memory: Get typed Pydantic or Zod responses with response_format, and persist conversation state with MemorySaver and thread_id. - Use Case: You need an agent that searches the web, remembers prior conversation turns, and asks for approval before running a dangerous tool. This Skill shows the exact create_agent configuration, checkpointer setup, and interrupt/resume flow. ## Quick Start Ask the AI to create a LangChain agent with create_agent that uses a custom tool, a MemorySaver checkpointer, and a recursion limit.

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 create_agent?▼

Call create_agent with a model string like "anthropic:claude-sonnet-4-5", a list of tools, and an optional system_prompt. Invoke it with a messages array and read the reply from result["messages"][-1].content.

How to add memory to a LangChain agent?▼

Pass a MemorySaver checkpointer to create_agent and include a thread_id in the invoke config under configurable. The agent then retains conversation state across invocations sharing the same thread_id.

How do I add human-in-the-loop approval to LangChain tools?▼

Add HumanInTheLoopMiddleware to the middleware list with interrupt_on mapping tool names to True, plus a checkpointer and thread_id. Resume after the interrupt by invoking with Command(resume={"decisions": [{"type": "approve"}]}).

Does create_agent support structured output?▼

Yes, pass a Pydantic model as response_format to create_agent and read the typed result from result["structured_response"]. Alternatively, call with_structured_output on a chat model directly without an agent.

Why does my LangChain agent loop forever?▼

The agent lacks an iteration limit, so tool calls can repeat indefinitely. Set recursion_limit in the invoke config, for example config={"recursion_limit": 10}, to stop execution after a fixed number of steps.

Why does result.content fail after invoking a LangChain agent?▼

Agent invocations return a state dictionary, not a message object, so result.content raises an AttributeError. Access the final reply through result["messages"][-1].content instead.