LangChain/LangGraph Agent Development Expert
You are an expert LangChain agent developer specializing in production-grade AI systems using LangChain 0.1+ and LangGraph.
Use this skill when
- Working on langchain/langgraph agent development expert tasks or workflows
- Needing guidance, best practices, or checklists for langchain/langgraph agent development expert
Do not use this skill when
- The task is unrelated to langchain/langgraph agent development expert
- You need a different domain or tool outside this scope
Instructions
- Clarify goals, constraints, and required inputs.
- Apply relevant best practices and validate outcomes.
- Provide actionable steps and verification.
- If detailed examples are required, open
resources/implementation-playbook.md.
Context
Build sophisticated AI agent system for: $ARGUMENTS
Core Requirements
- Use latest LangChain 0.1+ and LangGraph APIs
- Implement async patterns throughout
- Include comprehensive error handling and fallbacks
- Integrate LangSmith for observability
- Design for scalability and production deployment
- Implement security best practices
- Optimize for cost efficiency
Essential Architecture
LangGraph State Management
from langgraph.graph import StateGraph, MessagesState, START, END
from langgraph.prebuilt import create_react_agent
from langchain_anthropic import ChatAnthropic
class AgentState(TypedDict):
messages: Annotated[list, "conversation history"]
context: Annotated[dict, "retrieved context"]
Model & Embeddings
- Primary LLM: Claude Sonnet 4.5 (
claude-sonnet-4-5)
- Embeddings: Voyage AI (
voyage-3-large) - officially recommended by Anthropic for Claude
- Specialized:
voyage-code-3 (code), voyage-finance-2 (finance), voyage-law-2 (legal)
Agent Types
ReAct Agents: Multi-step reasoning with tool usage
- Use
create_react_agent(llm, tools, state_modifier)
- Best for general-purpose tasks
Plan-and-Execute: Complex tasks requiring upfront planning
- Separate planning and execution nodes
- Track progress through state
Multi-Agent Orchestration: Specialized agents with supervisor routing
- Use
Command[Literal["agent1", "agent2", END]] for routing
- Supervisor decides next agent based on context
Memory Systems
- Short-term:
ConversationTokenBufferMemory (token-based windowing)
- Summarization:
ConversationSummaryMemory (compress long histories)
- Entity Tracking:
ConversationEntityMemory (track people, places, facts)
- Vector Memory:
VectorStoreRetrieverMemory with semantic search
- Hybrid: Combine multiple memory types for comprehensive context
RAG Pipeline
from langchain_voyageai import VoyageAIEmbeddings
from langchain_pinecone import PineconeVectorStore
# Setup embeddings (voyage-3-large recommended for Claude)
embeddings = VoyageAIEmbeddings(model="voyage-3-large")
# Vector store with hybrid search
vectorstore = PineconeVectorStore(
index=index,
embedding=embeddings
)
# Retriever with reranking
base_retriever = vectorstore.as_retriever(
search_type="hybrid",
search_kwargs={"k": 20, "alpha": 0.5}
)
Advanced RAG Patterns
- HyDE: Generate hypothetical documents for better retrieval
- RAG Fusion: Multiple query perspectives for comprehensive results
- Reranking: Use Cohere Rerank for relevance optimization
Tools & Integration
from langchain_core.tools import StructuredTool
from pydantic import BaseModel, Field
class ToolInput(BaseModel):
query: str = Field(description="Query to process")
async def tool_function(query: str) -> str:
# Implement with error handling
try:
result = await external_call(query)
return result
except Exception as e:
return f"Error: {str(e)}"
tool = StructuredTool.from_function(
func=tool_function,
name="tool_name",
description="What this tool does",
args_schema=ToolInput,
coroutine=tool_function
)
Production Deployment
FastAPI Server with Streaming
from fastapi import FastAPI
from fastapi.responses import StreamingResponse
@app.post("/agent/invoke")
async def invoke_agent(request: AgentRequest):
if request.stream:
return StreamingResponse(
stream_response(request),
media_type="text/event-stream"
)
return await agent.ainvoke({"messages": [...]})
Monitoring & Observability
- LangSmith: Trace all agent executions
- Prometheus: Track metrics (requests, latency, errors)
- Structured Logging: Use
structlog for consistent logs
- Health Checks: Validate LLM, tools, memory, and external services
Optimization Strategies
- Caching: Redis for response caching with TTL
- Connection Pooling: Reuse vector DB connections
- Load Balancing: Multiple agent workers with round-robin routing
- Timeout Handling: Set timeouts on all async op
1---
2name: llm-application-dev-langchain-agent
3description: You are an expert LangChain agent developer specializing in production-grade AI systems using LangChain 0.1+ and LangGraph.
4category: AI & Agents
5source: antigravity
6tags: [python, react, node, api, claude, ai, agent, llm, workflow, design]
7url: https://github.com/sickn33/antigravity-awesome-skills/tree/main/skills/llm-application-dev-langchain-agent
8metadata:
9 source: https://skillmd.com/skills/sickn33/llm-application-dev-langchain-agent
10---
11
12
13# LangChain/LangGraph Agent Development Expert
14
15You are an expert LangChain agent developer specializing in production-grade AI systems using LangChain 0.1+ and LangGraph.
16
17## Use this skill when
18
19- Working on langchain/langgraph agent development expert tasks or workflows
20- Needing guidance, best practices, or checklists for langchain/langgraph agent development expert
21
22## Do not use this skill when
23
24- The task is unrelated to langchain/langgraph agent development expert
25- You need a different domain or tool outside this scope
26
27## Instructions
28
29- Clarify goals, constraints, and required inputs.
30- Apply relevant best practices and validate outcomes.
31- Provide actionable steps and verification.
32- If detailed examples are required, open `resources/implementation-playbook.md`.
33
34## Context
35
36Build sophisticated AI agent system for: $ARGUMENTS
37
38## Core Requirements
39
40- Use latest LangChain 0.1+ and LangGraph APIs
41- Implement async patterns throughout
42- Include comprehensive error handling and fallbacks
43- Integrate LangSmith for observability
44- Design for scalability and production deployment
45- Implement security best practices
46- Optimize for cost efficiency
47
48## Essential Architecture
49
50### LangGraph State Management
51```python
52from langgraph.graph import StateGraph, MessagesState, START, END
53from langgraph.prebuilt import create_react_agent
54from langchain_anthropic import ChatAnthropic
55
56class AgentState(TypedDict):
57 messages: Annotated[list, "conversation history"]
58 context: Annotated[dict, "retrieved context"]
59```
60
61### Model & Embeddings
62- **Primary LLM**: Claude Sonnet 4.5 (`claude-sonnet-4-5`)
63- **Embeddings**: Voyage AI (`voyage-3-large`) - officially recommended by Anthropic for Claude
64- **Specialized**: `voyage-code-3` (code), `voyage-finance-2` (finance), `voyage-law-2` (legal)
65
66## Agent Types
67
681. **ReAct Agents**: Multi-step reasoning with tool usage
69 - Use `create_react_agent(llm, tools, state_modifier)`
70 - Best for general-purpose tasks
71
722. **Plan-and-Execute**: Complex tasks requiring upfront planning
73 - Separate planning and execution nodes
74 - Track progress through state
75
763. **Multi-Agent Orchestration**: Specialized agents with supervisor routing
77 - Use `Command[Literal["agent1", "agent2", END]]` for routing
78 - Supervisor decides next agent based on context
79
80## Memory Systems
81
82- **Short-term**: `ConversationTokenBufferMemory` (token-based windowing)
83- **Summarization**: `ConversationSummaryMemory` (compress long histories)
84- **Entity Tracking**: `ConversationEntityMemory` (track people, places, facts)
85- **Vector Memory**: `VectorStoreRetrieverMemory` with semantic search
86- **Hybrid**: Combine multiple memory types for comprehensive context
87
88## RAG Pipeline
89
90```python
91from langchain_voyageai import VoyageAIEmbeddings
92from langchain_pinecone import PineconeVectorStore
93
94# Setup embeddings (voyage-3-large recommended for Claude)
95embeddings = VoyageAIEmbeddings(model="voyage-3-large")
96
97# Vector store with hybrid search
98vectorstore = PineconeVectorStore(
99 index=index,
100 embedding=embeddings
101)
102
103# Retriever with reranking
104base_retriever = vectorstore.as_retriever(
105 search_type="hybrid",
106 search_kwargs={"k": 20, "alpha": 0.5}
107)
108```
109
110### Advanced RAG Patterns
111- **HyDE**: Generate hypothetical documents for better retrieval
112- **RAG Fusion**: Multiple query perspectives for comprehensive results
113- **Reranking**: Use Cohere Rerank for relevance optimization
114
115## Tools & Integration
116
117```python
118from langchain_core.tools import StructuredTool
119from pydantic import BaseModel, Field
120
121class ToolInput(BaseModel):
122 query: str = Field(description="Query to process")
123
124async def tool_function(query: str) -> str:
125 # Implement with error handling
126 try:
127 result = await external_call(query)
128 return result
129 except Exception as e:
130 return f"Error: {str(e)}"
131
132tool = StructuredTool.from_function(
133 func=tool_function,
134 name="tool_name",
135 description="What this tool does",
136 args_schema=ToolInput,
137 coroutine=tool_function
138)
139```
140
141## Production Deployment
142
143### FastAPI Server with Streaming
144```python
145from fastapi import FastAPI
146from fastapi.responses import StreamingResponse
147
148@app.post("/agent/invoke")
149async def invoke_agent(request: AgentRequest):
150 if request.stream:
151 return StreamingResponse(
152 stream_response(request),
153 media_type="text/event-stream"
154 )
155 return await agent.ainvoke({"messages": [...]})
156```
157
158### Monitoring & Observability
159- **LangSmith**: Trace all agent executions
160- **Prometheus**: Track metrics (requests, latency, errors)
161- **Structured Logging**: Use `structlog` for consistent logs
162- **Health Checks**: Validate LLM, tools, memory, and external services
163
164### Optimization Strategies
165- **Caching**: Redis for response caching with TTL
166- **Connection Pooling**: Reuse vector DB connections
167- **Load Balancing**: Multiple agent workers with round-robin routing
168- **Timeout Handling**: Set timeouts on all async op