tessl install github:ComposioHQ/awesome-claude-skills --skill langsmith-fetchgithub.com/ComposioHQ/awesome-claude-skills
Debug LangChain and LangGraph agents by fetching execution traces from LangSmith Studio. Use when debugging agent behavior, investigating errors, analyzing tool calls, checking memory operations, or examining agent performance. Automatically fetches recent traces and analyzes execution patterns. Requires langsmith-fetch CLI installed.
Review Score
71%
Validation Score
14/16
Implementation Score
42%
Activation Score
100%
Debug LangChain and LangGraph agents by fetching execution traces directly from LangSmith Studio in your terminal.
Automatically activate when user mentions:
pip install langsmith-fetchexport LANGSMITH_API_KEY="your_langsmith_api_key"
export LANGSMITH_PROJECT="your_project_name"Verify setup:
echo $LANGSMITH_API_KEY
echo $LANGSMITH_PROJECTWhen user asks: "What just happened?" or "Debug my agent"
Execute:
langsmith-fetch traces --last-n-minutes 5 --limit 5 --format prettyAnalyze and report:
Example response format:
Found 3 traces in the last 5 minutes:
Trace 1: β
Success
- Agent: memento
- Tools: recall_memories, create_entities
- Duration: 2.3s
- Tokens: 1,245
Trace 2: β Error
- Agent: cypher
- Error: "Neo4j connection timeout"
- Duration: 15.1s
- Failed at: search_nodes tool
Trace 3: β
Success
- Agent: memento
- Tools: store_memory
- Duration: 1.8s
- Tokens: 892
π‘ Issue found: Trace 2 failed due to Neo4j timeout. Recommend checking database connection.When user provides: Trace ID or says "investigate that error"
Execute:
langsmith-fetch trace <trace-id> --format jsonAnalyze JSON and report:
Example response format:
Deep Dive Analysis - Trace abc123
Goal: User asked "Find all projects in Neo4j"
Execution Flow:
1. β
search_nodes(query: "projects")
β Found 24 nodes
2. β get_node_details(node_id: "proj_123")
β Error: "Node not found"
β This is the failure point
3. βΉοΈ Execution stopped
Root Cause:
The search_nodes tool returned node IDs that no longer exist in the database,
possibly due to recent deletions.
Suggested Fix:
1. Add error handling in get_node_details tool
2. Filter deleted nodes in search results
3. Update cache invalidation strategy
Token Usage: 1,842 tokens ($0.0276)
Execution Time: 8.7 secondsWhen user says: "Save this session" or "Export traces"
Execute:
# Create session folder with timestamp
SESSION_DIR="langsmith-debug/session-$(date +%Y%m%d-%H%M%S)"
mkdir -p "$SESSION_DIR"
# Export traces
langsmith-fetch traces "$SESSION_DIR/traces" --last-n-minutes 30 --limit 50 --include-metadata
# Export threads (conversations)
langsmith-fetch threads "$SESSION_DIR/threads" --limit 20Report:
β
Session exported successfully!
Location: langsmith-debug/session-20251224-143022/
- Traces: 42 files
- Threads: 8 files
You can now:
1. Review individual trace files
2. Share folder with team
3. Analyze with external tools
4. Archive for future reference
Session size: 2.3 MBWhen user asks: "Show me errors" or "What's failing?"
Execute:
# Fetch recent traces
langsmith-fetch traces --last-n-minutes 30 --limit 50 --format json > recent-traces.json
# Search for errors
grep -i "error\|failed\|exception" recent-traces.jsonAnalyze and report:
Example response format:
Error Analysis - Last 30 Minutes
Total Traces: 50
Failed Traces: 7 (14% failure rate)
Error Breakdown:
1. Neo4j Connection Timeout (4 occurrences)
- Agent: cypher
- Tool: search_nodes
- First occurred: 14:32
- Last occurred: 14:45
- Pattern: Happens during peak load
2. Memory Store Failed (2 occurrences)
- Agent: memento
- Tool: store_memory
- Error: "Pinecone rate limit exceeded"
- Occurred: 14:38, 14:41
3. Tool Not Found (1 occurrence)
- Agent: sqlcrm
- Attempted tool: "export_report" (doesn't exist)
- Occurred: 14:35
π‘ Recommendations:
1. Add retry logic for Neo4j timeouts
2. Implement rate limiting for Pinecone
3. Fix sqlcrm tool configurationUser says: "My agent isn't doing anything"
Steps:
Check if traces exist:
langsmith-fetch traces --last-n-minutes 5 --limit 5If NO traces found:
LANGCHAIN_TRACING_V2=true in environmentLANGCHAIN_API_KEY is setIf traces found:
User says: "Why did it use the wrong tool?"
Steps:
User says: "Agent doesn't remember things"
Steps:
Search for memory operations:
langsmith-fetch traces --last-n-minutes 10 --limit 20 --format raw | grep -i "memory\|recall\|store"Check:
User says: "Agent is too slow"
Steps:
Export with metadata:
langsmith-fetch traces ./perf-analysis --last-n-minutes 30 --limit 50 --include-metadataAnalyze:
Identify bottlenecks and suggest optimizations
langsmith-fetch traces --limit 5 --format prettyUse for: Quick visual inspection, showing to users
langsmith-fetch traces --limit 5 --format jsonUse for: Detailed analysis, syntax-highlighted review
langsmith-fetch traces --limit 5 --format rawUse for: Piping to other commands, automation
# After specific timestamp
langsmith-fetch traces --after "2025-12-24T13:00:00Z" --limit 20
# Last N minutes (most common)
langsmith-fetch traces --last-n-minutes 60 --limit 100# Get extra context
langsmith-fetch traces --limit 10 --include-metadata
# Metadata includes: agent type, model, tags, environment# Speed up large exports
langsmith-fetch traces ./output --limit 100 --concurrent 10Possible causes:
Solutions:
# 1. Try longer timeframe
langsmith-fetch traces --last-n-minutes 1440 --limit 50
# 2. Check environment
echo $LANGSMITH_API_KEY
echo $LANGSMITH_PROJECT
# 3. Try fetching threads instead
langsmith-fetch threads --limit 10
# 4. Verify tracing is enabled in your code
# Check for: LANGCHAIN_TRACING_V2=trueSolution:
# View current config
langsmith-fetch config show
# Set correct project
export LANGSMITH_PROJECT="correct-project-name"
# Or configure permanently
langsmith-fetch config set project "your-project-name"Solution:
# Add to shell config file (~/.bashrc or ~/.zshrc)
echo 'export LANGSMITH_API_KEY="your_key"' >> ~/.bashrc
echo 'export LANGSMITH_PROJECT="your_project"' >> ~/.bashrc
# Reload shell config
source ~/.bashrc# Quick check after making changes
langsmith-fetch traces --last-n-minutes 5 --limit 5langsmith-debug/
βββ sessions/
β βββ 2025-12-24/
β βββ 2025-12-25/
βββ error-cases/
βββ performance-tests/When you find bugs:
error-cases/ folder# Before committing code
langsmith-fetch traces --last-n-minutes 10 --limit 5
# If errors found
langsmith-fetch trace <error-id> --format json > pre-commit-error.json# Most common commands
# Quick debug
langsmith-fetch traces --last-n-minutes 5 --limit 5 --format pretty
# Specific trace
langsmith-fetch trace <trace-id> --format pretty
# Export session
langsmith-fetch traces ./debug-session --last-n-minutes 30 --limit 50
# Find errors
langsmith-fetch traces --last-n-minutes 30 --limit 50 --format raw | grep -i error
# With metadata
langsmith-fetch traces --limit 10 --include-metadatalangsmith-fetch is installed before running commands--format pretty for human-readable output--format json when you need to parse and analyze dataVersion: 0.1.0 Author: Ahmad Othman Ammar Adi License: MIT Repository: https://github.com/OthmanAdi/langsmith-fetch-skill