{"data":{"slug":"github-composiohq-awesome-claude-skills-langsmith-fetch-df40649896f4","title":"Debug LangChain Agents with LangSmith Traces","summary":"Fetch and analyze execution traces from LangSmith Studio to debug LangChain and LangGraph agents. Receive detailed reports on tool calls, errors, performance, and execution patterns.","url":"https:\/\/skillshunter.net\/skills\/github-composiohq-awesome-claude-skills-langsmith-fetch-df40649896f4","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/github-composiohq-awesome-claude-skills-langsmith-fetch-df40649896f4","markdown_url":"https:\/\/skillshunter.net\/skills\/github-composiohq-awesome-claude-skills-langsmith-fetch-df40649896f4.md","download_url":"https:\/\/skillshunter.net\/skills\/github-composiohq-awesome-claude-skills-langsmith-fetch-df40649896f4\/download","category":{"slug":"software-development","name":"Software & Development"},"editor_note":"Install the `langsmith-fetch` CLI before running commands. Set the `LANGSMITH_API_KEY` and `LANGSMITH_PROJECT` environment variables. Use `--format pretty` for human-readable output or `--format json` for parsing and analysis.","instructions":"---\nname: langsmith-fetch\ndescription: 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.\n---\n\n# LangSmith Fetch - Agent Debugging Skill\n\nDebug LangChain and LangGraph agents by fetching execution traces directly from LangSmith Studio in your terminal.\n\n## When to Use This Skill\n\nAutomatically activate when user mentions:\n- \ud83d\udc1b \"Debug my agent\" or \"What went wrong?\"\n- \ud83d\udd0d \"Show me recent traces\" or \"What happened?\"\n- \u274c \"Check for errors\" or \"Why did it fail?\"\n- \ud83d\udcbe \"Analyze memory operations\" or \"Check LTM\"\n- \ud83d\udcca \"Review agent performance\" or \"Check token usage\"\n- \ud83d\udd27 \"What tools were called?\" or \"Show execution flow\"\n\n## Prerequisites\n\n### 1. Install langsmith-fetch\n```bash\npip install langsmith-fetch\n```\n\n### 2. Set Environment Variables\n```bash\nexport LANGSMITH_API_KEY=\"your_langsmith_api_key\"\nexport LANGSMITH_PROJECT=\"your_project_name\"\n```\n\n**Verify setup:**\n```bash\necho $LANGSMITH_API_KEY\necho $LANGSMITH_PROJECT\n```\n\n## Core Workflows\n\n### Workflow 1: Quick Debug Recent Activity\n\n**When user asks:** \"What just happened?\" or \"Debug my agent\"\n\n**Execute:**\n```bash\nlangsmith-fetch traces --last-n-minutes 5 --limit 5 --format pretty\n```\n\n**Analyze and report:**\n1. \u2705 Number of traces found\n2. \u26a0\ufe0f Any errors or failures\n3. \ud83d\udee0\ufe0f Tools that were called\n4. \u23f1\ufe0f Execution times\n5. \ud83d\udcb0 Token usage\n\n**Example response format:**\n```\nFound 3 traces in the last 5 minutes:\n\nTrace 1: \u2705 Success\n- Agent: memento\n- Tools: recall_memories, create_entities\n- Duration: 2.3s\n- Tokens: 1,245\n\nTrace 2: \u274c Error\n- Agent: cypher\n- Error: \"Neo4j connection timeout\"\n- Duration: 15.1s\n- Failed at: search_nodes tool\n\nTrace 3: \u2705 Success\n- Agent: memento\n- Tools: store_memory\n- Duration: 1.8s\n- Tokens: 892\n\n\ud83d\udca1 Issue found: Trace 2 failed due to Neo4j timeout. Recommend checking database connection.\n```\n\n---\n\n### Workflow 2: Deep Dive Specific Trace\n\n**When user provides:** Trace ID or says \"investigate that error\"\n\n**Execute:**\n```bash\nlangsmith-fetch trace <trace-id> --format json\n```\n\n**Analyze JSON and report:**\n1. \ud83c\udfaf What the agent was trying to do\n2. \ud83d\udee0\ufe0f Which tools were called (in order)\n3. \u2705 Tool results (success\/failure)\n4. \u274c Error messages (if any)\n5. \ud83d\udca1 Root cause analysis\n6. \ud83d\udd27 Suggested fix\n\n**Example response format:**\n```\nDeep Dive Analysis - Trace abc123\n\nGoal: User asked \"Find all projects in Neo4j\"\n\nExecution Flow:\n1. \u2705 search_nodes(query: \"projects\")\n   \u2192 Found 24 nodes\n\n2. \u274c get_node_details(node_id: \"proj_123\")\n   \u2192 Error: \"Node not found\"\n   \u2192 This is the failure point\n\n3. \u23f9\ufe0f Execution stopped\n\nRoot Cause:\nThe search_nodes tool returned node IDs that no longer exist in the database,\npossibly due to recent deletions.\n\nSuggested Fix:\n1. Add error handling in get_node_details tool\n2. Filter deleted nodes in search results\n3. Update cache invalidation strategy\n\nToken Usage: 1,842 tokens ($0.0276)\nExecution Time: 8.7 seconds\n```\n\n---\n\n### Workflow 3: Export Debug Session\n\n**When user says:** \"Save this session\" or \"Export traces\"\n\n**Execute:**\n```bash\n# Create session folder with timestamp\nSESSION_DIR=\"langsmith-debug\/session-$(date +%Y%m%d-%H%M%S)\"\nmkdir -p \"$SESSION_DIR\"\n\n# Export traces\nlangsmith-fetch traces \"$SESSION_DIR\/traces\" --last-n-minutes 30 --limit 50 --include-metadata\n\n# Export threads (conversations)\nlangsmith-fetch threads \"$SESSION_DIR\/threads\" --limit 20\n```\n\n**Report:**\n```\n\u2705 Session exported successfully!\n\nLocation: langsmith-debug\/session-20251224-143022\/\n- Traces: 42 files\n- Threads: 8 files\n\nYou can now:\n1. Review individual trace files\n2. Share folder with team\n3. Analyze with external tools\n4. Archive for future reference\n\nSession size: 2.3 MB\n```\n\n---\n\n### Workflow 4: Error Detection\n\n**When user asks:** \"Show me errors\" or \"What's failing?\"\n\n**Execute:**\n```bash\n# Fetch recent traces\nlangsmith-fetch traces --last-n-minutes 30 --limit 50 --format json > recent-traces.json\n\n# Search for errors\ngrep -i \"error\\|failed\\|exception\" recent-traces.json\n```\n\n**Analyze and report:**\n1. \ud83d\udcca Total errors found\n2. \u274c Error types and frequency\n3. \ud83d\udd50 When errors occurred\n4. \ud83c\udfaf Which agents\/tools failed\n5. \ud83d\udca1 Common patterns\n\n**Example response format:**\n```\nError Analysis - Last 30 Minutes\n\nTotal Traces: 50\nFailed Traces: 7 (14% failure rate)\n\nError Breakdown:\n1. Neo4j Connection Timeout (4 occurrences)\n   - Agent: cypher\n   - Tool: search_nodes\n   - First occurred: 14:32\n   - Last occurred: 14:45\n   - Pattern: Happens during peak load\n\n2. Memory Store Failed (2 occurrences)\n   - Agent: memento\n   - Tool: store_memory\n   - Error: \"Pinecone rate limit exceeded\"\n   - Occurred: 14:38, 14:41\n\n3. Tool Not Found (1 occurrence)\n   - Agent: sqlcrm\n   - Attempted tool: \"export_report\" (doesn't exist)\n   - Occurred: 14:35\n\n\ud83d\udca1 Recommendations:\n1. Add retry logic for Neo4j timeouts\n2. Implement rate limiting for Pinecone\n3. Fix sqlcrm tool configuration\n```\n\n---\n\n## Common Use Cases\n\n### Use Case 1: \"Agent Not Responding\"\n\n**User says:** \"My agent isn't doing anything\"\n\n**Steps:**\n1. Check if traces exist:\n   ```bash\n   langsmith-fetch traces --last-n-minutes 5 --limit 5\n   ```\n\n2. **If NO traces found:**\n   - Tracing might be disabled\n   - Check: `LANGCHAIN_TRACING_V2=true` in environment\n   - Check: `LANGCHAIN_API_KEY` is set\n   - Verify agent actually ran\n\n3. **If traces found:**\n   - Review for errors\n   - Check execution time (hanging?)\n   - Verify tool calls completed\n\n---\n\n### Use Case 2: \"Wrong Tool Called\"\n\n**User says:** \"Why did it use the wrong tool?\"\n\n**Steps:**\n1. Get the specific trace\n2. Review available tools at execution time\n3. Check agent's reasoning for tool selection\n4. Examine tool descriptions\/instructions\n5. Suggest prompt or tool config improvements\n\n---\n\n### Use Case 3: \"Memory Not Working\"\n\n**User says:** \"Agent doesn't remember things\"\n\n**Steps:**\n1. Search for memory operations:\n   ```bash\n   langsmith-fetch traces --last-n-minutes 10 --limit 20 --format raw | grep -i \"memory\\|recall\\|store\"\n   ```\n\n2. Check:\n   - Were memory tools called?\n   - Did recall return results?\n   - Were memories actually stored?\n   - Are retrieved memories being used?\n\n---\n\n### Use Case 4: \"Performance Issues\"\n\n**User says:** \"Agent is too slow\"\n\n**Steps:**\n1. Export with metadata:\n   ```bash\n   langsmith-fetch traces .\/perf-analysis --last-n-minutes 30 --limit 50 --include-metadata\n   ```\n\n2. Analyze:\n   - Execution time per trace\n   - Tool call latencies\n   - Token usage (context size)\n   - Number of iterations\n   - Slowest operations\n\n3. Identify bottlenecks and suggest optimizations\n\n---\n\n## Output Format Guide\n\n### Pretty Format (Default)\n```bash\nlangsmith-fetch traces --limit 5 --format pretty\n```\n**Use for:** Quick visual inspection, showing to users\n\n### JSON Format\n```bash\nlangsmith-fetch traces --limit 5 --format json\n```\n**Use for:** Detailed analysis, syntax-highlighted review\n\n### Raw Format\n```bash\nlangsmith-fetch traces --limit 5 --format raw\n```\n**Use for:** Piping to other commands, automation\n\n---\n\n## Advanced Features\n\n### Time-Based Filtering\n```bash\n# After specific timestamp\nlangsmith-fetch traces --after \"2025-12-24T13:00:00Z\" --limit 20\n\n# Last N minutes (most common)\nlangsmith-fetch traces --last-n-minutes 60 --limit 100\n```\n\n### Include Metadata\n```bash\n# Get extra context\nlangsmith-fetch traces --limit 10 --include-metadata\n\n# Metadata includes: agent type, model, tags, environment\n```\n\n### Concurrent Fetching (Faster)\n```bash\n# Speed up large exports\nlangsmith-fetch traces .\/output --limit 100 --concurrent 10\n```\n\n---\n\n## Troubleshooting\n\n### \"No traces found matching criteria\"\n\n**Possible causes:**\n1. No agent activity in the timeframe\n2. Tracing is disabled\n3. Wrong project name\n4. API key issues\n\n**Solutions:**\n```bash\n# 1. Try longer timeframe\nlangsmith-fetch traces --last-n-minutes 1440 --limit 50\n\n# 2. Check environment\necho $LANGSMITH_API_KEY\necho $LANGSMITH_PROJECT\n\n# 3. Try fetching threads instead\nlangsmith-fetch threads --limit 10\n\n# 4. Verify tracing is enabled in your code\n# Check for: LANGCHAIN_TRACING_V2=true\n```\n\n### \"Project not found\"\n\n**Solution:**\n```bash\n# View current config\nlangsmith-fetch config show\n\n# Set correct project\nexport LANGSMITH_PROJECT=\"correct-project-name\"\n\n# Or configure permanently\nlangsmith-fetch config set project \"your-project-name\"\n```\n\n### Environment variables not persisting\n\n**Solution:**\n```bash\n# Add to shell config file (~\/.bashrc or ~\/.zshrc)\necho 'export LANGSMITH_API_KEY=\"your_key\"' >> ~\/.bashrc\necho 'export LANGSMITH_PROJECT=\"your_project\"' >> ~\/.bashrc\n\n# Reload shell config\nsource ~\/.bashrc\n```\n\n---\n\n## Best Practices\n\n### 1. Regular Health Checks\n```bash\n# Quick check after making changes\nlangsmith-fetch traces --last-n-minutes 5 --limit 5\n```\n\n### 2. Organized Storage\n```\nlangsmith-debug\/\n\u251c\u2500\u2500 sessions\/\n\u2502   \u251c\u2500\u2500 2025-12-24\/\n\u2502   \u2514\u2500\u2500 2025-12-25\/\n\u251c\u2500\u2500 error-cases\/\n\u2514\u2500\u2500 performance-tests\/\n```\n\n### 3. Document Findings\nWhen you find bugs:\n1. Export the problematic trace\n2. Save to `error-cases\/` folder\n3. Note what went wrong in a README\n4. Share trace ID with team\n\n### 4. Integration with Development\n```bash\n# Before committing code\nlangsmith-fetch traces --last-n-minutes 10 --limit 5\n\n# If errors found\nlangsmith-fetch trace <error-id> --format json > pre-commit-error.json\n```\n\n---\n\n## Quick Reference\n\n```bash\n# Most common commands\n\n# Quick debug\nlangsmith-fetch traces --last-n-minutes 5 --limit 5 --format pretty\n\n# Specific trace\nlangsmith-fetch trace <trace-id> --format pretty\n\n# Export session\nlangsmith-fetch traces .\/debug-session --last-n-minutes 30 --limit 50\n\n# Find errors\nlangsmith-fetch traces --last-n-minutes 30 --limit 50 --format raw | grep -i error\n\n# With metadata\nlangsmith-fetch traces --limit 10 --include-metadata\n```\n\n---\n\n## Resources\n\n- **LangSmith Fetch CLI:** https:\/\/github.com\/langchain-ai\/langsmith-fetch\n- **LangSmith Studio:** https:\/\/smith.langchain.com\/\n- **LangChain Docs:** https:\/\/docs.langchain.com\/\n- **This Skill Repo:** https:\/\/github.com\/OthmanAdi\/langsmith-fetch-skill\n\n---\n\n## Notes for Claude\n\n- Always check if `langsmith-fetch` is installed before running commands\n- Verify environment variables are set\n- Use `--format pretty` for human-readable output\n- Use `--format json` when you need to parse and analyze data\n- When exporting sessions, create organized folder structures\n- Always provide clear analysis and actionable insights\n- If commands fail, help troubleshoot configuration issues\n\n---\n\n**Version:** 0.1.0\n**Author:** Ahmad Othman Ammar Adi\n**License:** MIT\n**Repository:** https:\/\/github.com\/OthmanAdi\/langsmith-fetch-skill\n","use_cases":["Debug agent behavior and errors","Investigate tool call failures","Analyze memory operations","Check agent performance","Review execution patterns"],"limitations":[],"compatibility":[],"setup_tip":null,"sample_input":null,"sample_output":null,"source_url":"https:\/\/github.com\/ComposioHQ\/awesome-claude-skills\/blob\/be2a406907dbc61b73e6827ded415c96139d13a2\/langsmith-fetch\/SKILL.md","source_commit":"be2a406907dbc61b73e6827ded415c96139d13a2","license":null,"version":null,"listing_approved_at":"2026-11-21","created_at":"2026-11-20T13:17:32.000000Z","updated_at":"2026-11-21T09:43:53.000000Z","seo_title":"Debug LangChain Agents with LangSmith Traces","seo_description":"Debug LangChain and LangGraph agents by fetching execution traces from LangSmith Studio. Analyze tool calls, errors, and performance with detailed reports.","seo_keywords":["debug LangChain agents","analyze LangSmith traces","check agent errors","trace execution patterns","LangGraph debugging"]}}