| name | langgraph |
| description | You are an expert in building production-grade AI agents with LangGraph. You understand that agents need explicit structure - graphs make the flow visible and debuggable. You design state carefully, use reducers appropriately, and always consider persistence for production. |
| risk | unknown |
| source | vibeship-spawner-skills (Apache 2.0) |
| date_added | 2026-02-27 |
LangGraph
Role: LangGraph Agent Architect
You are an expert in building production-grade AI agents with LangGraph. You
understand that agents need explicit structure - graphs make the flow visible
and debuggable. You design state carefully, use reducers appropriately, and
always consider persistence for production. You know when cycles are needed
and how to prevent infinite loops.
Capabilities
- Graph construction (StateGraph)
- State management and reducers
- Node and edge definitions
- Conditional routing
- Checkpointers and persistence
- Human-in-the-loop patterns
- Tool integration
- Streaming and async execution
Requirements
- Python 3.9+
- langgraph package
- LLM API access (OpenAI, Anthropic, etc.)
- Understanding of graph concepts
Patterns
Basic Agent Graph
Simple ReAct-style agent with tools
When to use: Single agent with tool calling
from typing import Annotated, TypedDict
from langgraph.graph import StateGraph, START, END
from langgraph.graph.message import add_messages
from langgraph.prebuilt import ToolNode
from langchain_openai import ChatOpenAI
from langchain_core.tools import tool
class AgentState(TypedDict):
messages: Annotated[list, add_messages]
@tool
def search(query: str) -> str:
"""Search the web for information."""
return f"Results for: {query}"
@tool
def calculator(expression: str) -> str:
"""Evaluate a math expression."""
return str(eval(expression))
tools = [search, calculator]
llm = ChatOpenAI(model="gpt-4o").bind_tools(tools)
def agent(state: AgentState) -> dict:
"""The agent node - calls LLM."""
response = llm.invoke(state["messages"])
return {"messages": [response]}
tool_node = ToolNode(tools)
def should_continue(state: AgentState) -> str:
"""Route based on whether tools were called."""
last_message = state["messages"][-1]
if last_message.tool_calls:
return "tools"
return END
graph = StateGraph(AgentState)
graph.add_node("agent", agent)
graph.add_node("tools", tool_node)
graph.add_edge(START, "agent")
graph.add_conditional_edges("agent", should_continue, ["tools", END])
graph.add_edge("tools", "agent")
app = graph.compile()
result = app.invoke({
"messages": [("user", "What is 25 * 4?")]
})
State with Reducers
Complex state management with custom reducers
When to use: Multiple agents updating shared state
from typing import Annotated, TypedDict
from operator import add
from langgraph.graph import StateGraph
def merge_dicts(left: dict, right: dict) -> dict:
return {**left, **right}
class ResearchState(TypedDict):
messages: Annotated[list, add_messages]
findings: Annotated[dict, merge_dicts]
sources: Annotated[list[str], add]
current_step: str
errors: Annotated[int, lambda a, b: a + b]
def researcher(state: ResearchState) -> dict:
return {
"findings": {"topic_a": "New finding"},
"sources": ["source1.com"],
"current_step": "researching"
}
def writer(state: ResearchState) -> dict:
all_findings = state["findings"]
all_sources = state["sources"]
return {
"messages": [("assistant", f"Report based on {len(all_sources)} sources")],
"current_step": "writing"
}
graph = StateGraph(ResearchState)
graph.add_node("researcher", researcher)
graph.add_node("writer", writer)
Conditional Branching
Route to different paths based on state
When to use: Multiple possible workflows
from langgraph.graph import StateGraph, START, END
class RouterState(TypedDict):
query: str
query_type: str
result: str
def classifier(state: RouterState) -> dict:
"""Classify the query type."""
query = state["query"].lower()
if "code" in query or "program" in query:
return {"query_type": "coding"}
elif "search" in query or "find" in query:
return {"query_type": "search"}
else:
return {"query_type": "chat"}
def coding_agent(state: RouterState) -> dict:
return {"result": "Here's your code..."}
def search_agent(state: RouterState) -> dict:
return {"result": "Search results..."}
def chat_agent(state: RouterState) -> dict:
return {"result": "Let me help..."}
def route_query(state: RouterState) -> str:
"""Route to appropriate agent."""
query_type = state["query_type"]
return query_type
graph = StateGraph(RouterState)
graph.add_node("classifier", classifier)
graph.add_node("coding", coding_agent)
graph.add_node("search", search_agent)
graph.add_node("chat", chat_agent)
graph.add_edge(START, "classifier")
graph.add_conditional_edges(
"classifier",
route_query,
{
"coding": "coding",
"search": "search",
"chat": "chat"
}
)
graph.add_edge("coding", END)
graph.add_edge("search", END)
graph.add_edge("chat", END)
app = graph.compile()
Anti-Patterns
❌ Infinite Loop Without Exit
Why bad: Agent loops forever.
Burns tokens and costs.
Eventually errors out.
Instead: Always have exit conditions:
- Max iterations counter in state
- Clear END conditions in routing
- Timeout at application level
def should_continue(state):
if state["iterations"] > 10:
return END
if state["task_complete"]:
return END
return "agent"
❌ Stateless Nodes
Why bad: Loses LangGraph's benefits.
State not persisted.
Can't resume conversations.
Instead: Always use state for data flow.
Return state updates from nodes.
Use reducers for accumulation.
Let LangGraph manage state.
❌ Giant Monolithic State
Why bad: Hard to reason about.
Unnecessary data in context.
Serialization overhead.
Instead: Use input/output schemas for clean interfaces.
Private state for internal data.
Clear separation of concerns.
Limitations
- Python-only (TypeScript in early stages)
- Learning curve for graph concepts
- State management complexity
- Debugging can be challenging
Related Skills
Works well with: crewai, autonomous-agents, langfuse, structured-output
When to Use
This skill is applicable to execute the workflow or actions described in the overview.
AGI Framework Integration
Adapted for @techwavedev/agi-agent-kit
Original source: antigravity-awesome-skills
Memory-First Protocol
Retrieve prior agent configurations, team compositions, and orchestration patterns. Critical for multi-agent system consistency.
python3 execution/memory_manager.py auto --query "agent patterns and orchestration strategies for Langgraph"
Storing Results
After completing work, store AI agent orchestration decisions for future sessions:
python3 execution/memory_manager.py store \
--content "Agent pattern: hierarchical orchestration with Control Tower dispatcher, 3 specialist sub-agents" \
--type decision --project <project> \
--tags langgraph ai-agents
Multi-Agent Collaboration
This skill is inherently multi-agent. Use cross-agent context to coordinate task distribution and avoid duplicate work.
python3 execution/cross_agent_context.py store \
--agent "<your-agent>" \
--action "Agent architecture designed — Control Tower + specialist agents with shared Qdrant memory" \
--project <project>
Control Tower Integration
Register agents and tasks with the Control Tower (execution/control_tower.py) for centralized orchestration across machines and LLM providers.
Blockchain Identity
Each agent has a cryptographic Ed25519 identity. All memory writes are signed — enabling trust verification in multi-agent systems.