← ClaudeAtlas

building-langgraph-agentslisted

Builds stateful AI agents using LangGraph — the graph-based state machine framework for agents with complex conditional flows, retry loops, error recovery, and built-in HITL checkpoints. Covers when to choose LangGraph over LangChain or CrewAI, core concepts (StateGraph, TypedDict state, nodes, edges, conditional edges, reducers, checkpointers), and implementation patterns for production agent workflows. Use when building agents with complex branching logic, designing agents that need to loop until a condition is met, implementing state machines for agent workflows, adding error recovery to agent loops, building agents that need to pause for human approval at specific graph nodes, or migrating from sequential LangChain agents to stateful LangGraph agents. Also triggers on: LangGraph, StateGraph, stateful agent, conditional agent, agent loop, graph-based agent, agent branching, LangGraph HITL, agent checkpointer.
Krosebrook/loxihart-skills · ★ 0 · AI & Automation · score 73
Install: claude install-skill Krosebrook/loxihart-skills
# LangGraph Agent Construction LangGraph is a state machine framework for agents. It's the right choice when your agent needs explicit control over what happens next at each step. **Choose LangGraph over LangChain (sequential) or CrewAI (role-based) when:** - The agent needs to loop until a condition is met (not just chain steps) - Different tool results should route to different next actions - Error recovery requires specific retry or fallback paths - Human-in-the-loop checkpoints need to be embedded in the flow - You need to inspect or modify agent state mid-execution --- ## Core Concepts ### StateGraph The central object. Nodes process state; edges define what runs next. ```python from langgraph.graph import StateGraph, END from typing import TypedDict, Annotated import operator # 1. Define your state schema class AgentState(TypedDict): messages: Annotated[list, operator.add] # reducer: new messages append task: str tools_called: Annotated[list, operator.add] outcome: str | None error: str | None retry_count: int # 2. Create the graph graph = StateGraph(AgentState) ``` ### Nodes Functions that take state and return partial state updates. ```python async def call_model(state: AgentState) -> dict: response = await llm.ainvoke(state["messages"]) return {"messages": [response]} async def execute_tool(state: AgentState) -> dict: # Extract tool call from last message last_msg = state["messages"][-1] tool_name = last_msg.t