Skip to content
langchain-agents logo

LangChain Agents

langchain-agents

Building LLM agents with LangChain and LangGraph, covering tool-calling model initialization, state management, and observability with LangSmith. Triggers: langchain, langgraph, langsmith, agent-executor, chat-model-tools.

SKILL.md

Full skill instructions

LangChain Agents

Overview

LangChain provides a standard interface for building LLM agents that can use tools. Modern agent development is moving toward LangGraph to handle stateful, multi-turn, and non-linear logic that simple loops cannot capture.

When to Use

  • Multi-Provider Apps: When you want to swap between OpenAI, Anthropic, and local models without changing business logic.
  • Stateful Agents: When you need human-in-the-loop, long-term persistence, or complex execution graphs.
  • Observability: Using LangSmith to debug exactly where an agentic chain failed.

Decision Tree

  1. Is it a simple tool-calling loop?
    • YES: Use the create_agent abstraction.
  2. Does it require cycles, complex state transitions, or human approval?
    • YES: Build using LangGraph.
  3. Do you need to track exactly how much an agent run cost or where it halluncinated?
    • YES: Enable LangSmith tracing.

Workflows

1. Creating a Simple Tool-Enabled Agent

  1. Define a Python function with a docstring to serve as a tool.
  2. Initialize a ChatModel (e.g., ChatAnthropic).
  3. Call create_agent(model, tools=[...]) to generate the agent.
  4. Execute the agent using agent.invoke({"messages": [...]}).

2. Debugging with LangSmith

  1. Enable LangSmith environment variables (LANGSMITH_API_KEY, LANGSMITH_TRACING).
  2. Run the agent as usual; traces are automatically captured.
  3. Visualize the execution path and captured state transitions in the LangSmith UI to identify where the agent went wrong.

3. Adding Memory to an Agent

  1. Initialize a Checkpointer or Memory object.
  2. Pass the memory to the agent's invoke call to maintain state across turns.
  3. The agent will automatically append tool outputs and model responses to the conversation thread.

Non-Obvious Insights

  • Abstraction Layer: LangChain's primary value is standardizing the interface across providers, preventing vendor lock-in.
  • Simple vs. Complex: For many basic tasks, you don't need LangGraph; the high-level agent_executor is often enough for under 10 lines of code.
  • Durable Execution: Using LangGraph allows for "checkpoints," meaning an agent can stop, wait for human input, and resume hours later without losing state.

Evidence

  • "Standardizes how you interact with models so that you can seamlessly swap providers..." - LangChain Docs
  • "LangChain agents are built on top of LangGraph in order to provide durable execution, streaming... persistence." - LangChain Docs
  • "You do not need to know LangGraph for basic LangChain agent usage." - LangChain Docs

Scripts

  • scripts/​langchain-agents_tool.py: Python script for tool definition and agent invocation.
  • scripts/​langchain-agents_tool.js: Equivalent logic using LangChain.js.

Dependencies

  • langchain
  • langgraph
  • langsmith

References

More skills from majiayu000

xiaohongshu logo
majiayu000/claude-arsenal

xiaohongshu

xiaohongshu

286 148
View
agent-task-conductor logo
majiayu000/claude-skill-registry

agent-task-conductor

Conduct multi-agent task orchestration and workflow coordination.

663 1
View
conductor-setup logo
majiayu000/claude-skill-registry

conductor-setup

Initialize project with Conductor artifacts (product definition,

663 1
View
animation-designer logo
majiayu000/claude-skill-registry

animation-designer

Expert in web animations, transitions, and motion design using Framer Motion and CSS

663 1
View
diagramming logo
majiayu000/claude-skill-registry

diagramming

Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...

663 1
View
h3-pg logo
majiayu000/claude-skill-registry-data

h3-pg

PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.

23 1
View
conductor-development logo
majiayu000/claude-skill-registry

conductor-development

Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...

663 1
View
conductor-status logo
majiayu000/claude-skill-registry

conductor-status

Display project status, active tracks, and next actions

663 1
View
dockerization logo
majiayu000/claude-skill-registry

dockerization

Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.

663 1
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View