LangChain Fundamentals

Create and configure LangChain agents with tools, middleware, and checkpointers.

1.1k|86|Updated Jan 22, 2026
One-click install
npx skills add https://github.com/langchain-ai/langchain-skills --skill langchain-fundamentals
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: LangChain Fundamentals
Source: https://github.com/langchain-ai/langchain-skills/tree/main/config/skills/langchain-fundamentals
Command: npx skills add https://github.com/langchain-ai/langchain-skills --skill langchain-fundamentals

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill provides the foundational knowledge and tools to build robust, production-ready AI agents using LangChain's create_agent function, enabling custom workflows and reliable operation.

Core Features & Use Cases

  • Agent Creation: Learn to use create_agent() for building agents with LLMs, tools, and system prompts.
  • Tool Definition: Define custom functions as tools for agents using @tool (Python) or tool() (TypeScript).
  • Middleware Integration: Implement middleware for human-in-the-loop approvals, error handling, and custom logic.
  • Persistence: Configure checkpointers for maintaining conversation state and memory.
  • Structured Output: Ensure agents return data in a predictable, typed format.
  • Use Case: Develop an agent that can search the web, perform calculations, and ask for user confirmation before executing a critical action, ensuring both efficiency and safety.

Quick Start

Create a basic agent that can get the weather for a given location using the create_agent function and the @tool decorator.

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 custom tools?

Create LangChain agents using the `create_agent` function, defining custom tools with the `@tool` decorator in Python or `tool()` in TypeScript to enable specific workflows and operations.

What is middleware in LangChain and when should I use it?

Middleware in LangChain provides advanced control flow for agents, enabling human-in-the-loop approvals, custom logic, and error handling during execution to ensure safe and reliable operation.

How do I add memory and persistence to a LangChain agent?

Add persistence to LangChain agents by configuring checkpointers, which maintain conversation state and memory across interactions for continuous, stateful workflows.

Why does my LangChain agent return untyped or incorrect results?

LangChain agents return untyped results when structured output is not configured, or when tool descriptions are missing, causing the agent to misinterpret available functions and access results incorrectly.

Can I stop a LangChain agent from running into infinite loops?

Yes, this Skill addresses common LangChain agent issues like infinite loops by guiding proper configuration of tools, persistence, and middleware to establish reliable execution boundaries.

How do I generate structured output from a LangChain agent?

Generate structured output from LangChain agents by configuring the agent to return data in a predictable, typed format, ensuring downstream applications receive consistent, structured responses.