LangSmith Fetch - Agent Debugging Skill
Debug LangChain and LangGraph agents by fetching execution traces directly from LangSmith Studio in your terminal.
When to Use This Skill
Automatically activate when user mentions:
- 🐛 "Debug my agent" or "What went wrong?"
- 🔍 "Show me recent traces" or "What happened?"
- ❌ "Check for errors" or "Why did it fail?"
- 💾 "Analyze memory operations" or "Check LTM"
- 📊 "Review agent performance" or "Check token usage"
- 🔧 "What tools were called?" or "Show execution flow"
Prerequisites
1. Install langsmith-fetch
2. Set Environment Variables
Verify setup:
Core Workflows
Workflow 1: Quick Debug Recent Activity
When user asks: "What just happened?" or "Debug my agent"
Execute:
Analyze and report:
- ✅ Number of traces found
- ⚠️ Any errors or failures
- 🛠️ Tools that were called
- ⏱️ Execution times
- 💰 Token usage
Example response format:
Workflow 2: Deep Dive Specific Trace
When user provides: Trace ID or says "investigate that error"
Execute:
Analyze JSON and report:
- 🎯 What the agent was trying to do
- 🛠️ Which tools were called (in order)
- ✅ Tool results (success/failure)
- ❌ Error messages (if any)
- 💡 Root cause analysis
- 🔧 Suggested fix
Example response format:
Workflow 3: Export Debug Session
When user says: "Save this session" or "Export traces"
Execute:
Report:
Workflow 4: Error Detection
When user asks: "Show me errors" or "What's failing?"
Execute:
Analyze and report:
- 📊 Total errors found
- ❌ Error types and frequency
- 🕐 When errors occurred
- 🎯 Which agents/tools failed
- 💡 Common patterns
Example response format:
Common Use Cases
Use Case 1: "Agent Not Responding"
User says: "My agent isn't doing anything"
Steps:
-
Check if traces exist:
-
If NO traces found:
- Tracing might be disabled
- Check:
LANGCHAIN_TRACING_V2=truein environment - Check:
LANGCHAIN_API_KEYis set - Verify agent actually ran
-
If traces found:
- Review for errors
- Check execution time (hanging?)
- Verify tool calls completed
Use Case 2: "Wrong Tool Called"
User says: "Why did it use the wrong tool?"
Steps:
- Get the specific trace
- Review available tools at execution time
- Check agent's reasoning for tool selection
- Examine tool descriptions/instructions
- Suggest prompt or tool config improvements
Use Case 3: "Memory Not Working"
User says: "Agent doesn't remember things"
Steps:
-
Search for memory operations:
-
Check:
- Were memory tools called?
- Did recall return results?
- Were memories actually stored?
- Are retrieved memories being used?
Use Case 4: "Performance Issues"
User says: "Agent is too slow"
Steps:
-
Export with metadata:
-
Analyze:
- Execution time per trace
- Tool call latencies
- Token usage (context size)
- Number of iterations
- Slowest operations
-
Identify bottlenecks and suggest optimizations
Output Format Guide
Pretty Format (Default)
Use for: Quick visual inspection, showing to users
JSON Format
Use for: Detailed analysis, syntax-highlighted review
Raw Format
Use for: Piping to other commands, automation
Advanced Features
Time-Based Filtering
Include Metadata
Concurrent Fetching (Faster)
Troubleshooting
"No traces found matching criteria"
Possible causes:
- No agent activity in the timeframe
- Tracing is disabled
- Wrong project name
- API key issues
Solutions:
"Project not found"
Solution:
Environment variables not persisting
Solution:
Best Practices
1. Regular Health Checks
2. Organized Storage
3. Document Findings
When you find bugs:
- Export the problematic trace
- Save to
error-cases/folder - Note what went wrong in a README
- Share trace ID with team
4. Integration with Development
Quick Reference
Resources
- LangSmith Fetch CLI: https://github.com/langchain-ai/langsmith-fetch
- LangSmith Studio: https://smith.langchain.com/
- LangChain Docs: https://docs.langchain.com/
- This Skill Repo: https://github.com/OthmanAdi/langsmith-fetch-skill
Notes for Claude
- Always check if
langsmith-fetchis installed before running commands - Verify environment variables are set
- Use
--format prettyfor human-readable output - Use
--format jsonwhen you need to parse and analyze data - When exporting sessions, create organized folder structures
- Always provide clear analysis and actionable insights
- If commands fail, help troubleshoot configuration issues
Version: 0.1.0 Author: Ahmad Othman Ammar Adi License: MIT Repository: https://github.com/OthmanAdi/langsmith-fetch-skill


