langchain-fundamentals

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

Updated Jul 16, 2026
One-click install
npx skills add https://github.com/flemx/salesforce-langgraph-agent --skill langchain-fundamentals-flemx
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: langchain-fundamentals
Source: https://github.com/flemx/salesforce-langgraph-agent/tree/main/.agents/skills/langchain-fundamentals
Command: npx skills add https://github.com/flemx/salesforce-langgraph-agent --skill langchain-fundamentals-flemx

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Building production agents with LangChain requires knowing the current recommended patterns, and outdated approaches lead to broken loops, lost conversation state, and missing human approval controls. This Skill provides the canonical patterns for creating agents with create_agent, defining tools, and adding middleware. ## Core Features & Use Cases - Agent Creation: Build agents with create_agent using model strings or configured model instances, system prompts, and tool lists in Python or TypeScript. - Middleware & Human-in-the-Loop: Add HumanInTheLoopMiddleware for approval workflows, custom wrap_tool_call hooks, and resume interrupts with Command objects. - State & Reliability Fixes: Apply checkpointers with thread_id for memory, recursion_limit for loop control, and correct result message access patterns. - Use Case: A developer building a customer support agent can define Salesforce lookup tools, require human approval before issuing refunds, and persist conversation state across sessions. ## Quick Start Create a LangChain agent with create_agent that uses a weather lookup tool and remembers the conversation across invocations.

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 an optional system prompt. Define tools with the @tool decorator in Python or the tool() function with a zod schema in TypeScript, then invoke the agent with a messages array.

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

Add HumanInTheLoopMiddleware to the middleware list with interrupt_on mapping tool names to approval requirements. This requires a checkpointer and thread_id, and you resume execution by invoking 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. Pass a MemorySaver checkpointer to create_agent and include a thread_id in the invoke config to maintain conversation memory across calls.

How do I get structured output from a LangChain agent?

Pass a Pydantic model as response_format to create_agent and read result["structured_response"], or call with_structured_output on a chat model directly. TypeScript uses zod schemas with withStructuredOutput for typed, validated responses.

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 config={"recursion_limit": 10}. In TypeScript, pass recursionLimit as the second argument to agent.invoke.