langgraph-tutor

LangGraph Tutor Skill

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "langgraph-tutor" with this command: npx skills add timothywarner-org/agents2/timothywarner-org-agents2-langgraph-tutor

LangGraph Tutor Skill

Expert guidance for building production AI agents with LangGraph.

Quick Start

from langgraph.graph import StateGraph, START, END from typing import Annotated from typing_extensions import TypedDict from langgraph.graph.message import add_messages

class State(TypedDict): messages: Annotated[list, add_messages]

def chatbot(state: State): return {"messages": [llm.invoke(state["messages"])]}

graph = StateGraph(State) graph.add_node("chatbot", chatbot) graph.add_edge(START, "chatbot") graph.add_edge("chatbot", END) app = graph.compile()

Core Concepts

  1. State Definition

State flows through the graph. Use TypedDict with optional reducers:

class State(TypedDict): messages: Annotated[list, add_messages] # Accumulates context: str # Overwrites count: Annotated[int, operator.add] # Sums

  1. Nodes

Functions that receive state and return updates:

def my_node(state: State) -> dict: # Read from state messages = state["messages"] # Return updates (don't mutate!) return {"context": "new value"}

  1. Edges

Connect nodes in the graph:

graph.add_edge(START, "node_a") # Entry point graph.add_edge("node_a", "node_b") # Linear flow graph.add_edge("node_b", END) # Exit point

  1. Conditional Routing

Route based on state:

def router(state: State) -> Literal["path_a", "path_b"]: if condition: return "path_a" return "path_b"

graph.add_conditional_edges("source", router)

  1. Memory/Checkpointing

Persist state across invocations:

from langgraph.checkpoint.memory import InMemorySaver

memory = InMemorySaver() app = graph.compile(checkpointer=memory)

config = {"configurable": {"thread_id": "user-123"}} result = app.invoke({"messages": [msg]}, config)

  1. Human-in-the-Loop

Pause for human input:

from langgraph.types import interrupt

def approval_node(state): response = interrupt({"question": "Approve?"}) return {"approved": response["answer"]}

Common Patterns

ReAct Agent (Reasoning + Acting)

See references/patterns.md for full implementation.

Supervisor Multi-Agent

See references/multi-agent.md for patterns.

Tool Calling

See references/tools.md for integration.

Validation

Run the validation script to check your graph:

python scripts/validate_graph.py your_graph.py

Examples

Working examples in examples/:

  • simple_chatbot.py

  • Minimal chatbot

  • tool_agent.py

  • Agent with tools

  • multi_agent.py

  • Supervisor pattern

Common Errors

Error Cause Fix

"Node has no outgoing edge" Missing edge Add edge to END or next node

"State key not found" Accessing undefined key Check State TypedDict

"Cannot serialize" Complex objects in state Use JSON-serializable types

Resources

  • LangGraph Docs

  • Tutorials

  • API Reference

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Automation

Memory

Infinite organized memory that complements your agent's built-in memory with unlimited categorized storage.

Archived SourceRecently Updated
Automation

find-skills

Helps users discover and install agent skills when they ask questions like "how do I do X", "find a skill for X", "is there a skill that can...", or express interest in extending capabilities. This skill should be used when the user is looking for functionality that might exist as an installable skill.

Archived SourceRecently Updated
Automation

My Browser Agent

# my-browser-agent

Archived SourceRecently Updated
Automation

Skrape

Ethical web data extraction with robots exclusion protocol adherence, throttled scraping requests, and privacy-compliant handling ("Scrape responsibly!").

Archived SourceRecently Updated