langsmith-fetch
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.
What this skill does
# 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 ```bash pip install langsmith-fetch ``` ### 2. Set Environment Variables ```bash export LANGSMITH_API_KEY="your_langsmith_api_key" export LANGSMITH_PROJECT="your_project_name" ``` **Verify setup:** ```bash echo $LANGSMITH_API_KEY echo $LANGSMITH_PROJECT ``` ## Core Workflows ### Workflow 1: Quick Debug Recent Activity **When user asks:** "What just happened?" or "Debug my agent" **Execute:** ```bash langsmith-fetch traces --last-n-minutes 5 --limit 5 --format pretty ``` **Analyze and report:** 1. โ Number of traces found 2. โ ๏ธ Any errors or failures 3. ๐ ๏ธ Tools that were called 4. โฑ๏ธ Execution times 5. ๐ฐ Token usage **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. ``` --- ### Workflow 2: Deep Dive Specific Trace **When user provides:** Trace ID or says "investigate that error" **Execute:** ```bash langsmith-fetch trace <trace-id> --format json ``` **Analyze JSON and report:** 1. ๐ฏ What the agent was trying to do 2. ๐ ๏ธ Which tools were called (in order) 3. โ Tool results (success/failure) 4. โ Error messages (if any) 5. ๐ก Root cause analysis 6. ๐ง Suggested fix **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 seconds ``` --- ### Workflow 3: Export Debug Session **When user says:** "Save this session" or "Export traces" **Execute:** ```bash # 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 20 ``` **Report:** ``` โ 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 MB ``` --- ### Workflow 4: Error Detection **When user asks:** "Show me errors" or "What's failing?" **Execute:** ```bash # 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.json ``` **Analyze and report:** 1. ๐ Total errors found 2. โ Error types and frequency 3. ๐ When errors occurred 4. ๐ฏ Which agents/tools failed 5. ๐ก Common patterns **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 configuration ``` --- ## Common Use Cases ### Use Case 1: "Agent Not Responding" **User says:** "My agent isn't doing anything" **Steps:** 1. Check if traces exist: ```bash langsmith-fetch traces --last-n-minutes 5 --limit 5 ``` 2. **If NO traces found:** - Tracing might be disabled - Check: `LANGCHAIN_TRACING_V2=true` in environment - Check: `LANGCHAIN_API_KEY` is set - Verify agent actually ran 3. **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:** 1. Get the specific trace 2. Review available tools at execution time 3. Check agent's reasoning for tool selection 4. Examine tool descriptions/instructions 5. Suggest prompt or tool config improvements --- ### Use Case 3: "Memory Not Working" **User says:** "Agent doesn't remember things" **Steps:** 1. Search for memory operations: ```bash langsmith-fetch traces --last-n-minutes 10 --limit 20 --format raw | grep -i "memory\|recall\|store" ``` 2. 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:** 1. Export with metadata: ```bash langsmith-fetch traces ./perf-analysis --last-n-minutes 30 --limit 50 --include-metadata ``` 2. Analyze: - Execution time per trace - Tool call latencies - Token usage (context size) - Number of iterations - Slowest operations 3. Identify bottlenecks and suggest optimizations --- ## Output Format Guide ### Pretty Format (Default) ```bash langsmith-fetch traces --limit 5 --format pretty ``` **Use for:** Quick visual inspection, showing to users ### JSON Format ```bash langsmith-fetch traces --limit 5 --format json ``` **Use for:** Detailed analysis, syntax-highlighted review ### Raw Format ```bash langsmith-fetch traces --limit 5 --format raw ``` **Use for:** Piping to other commands, automation --- ## Advanced Features ### Time-Based Filtering ```bash # 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 ``` ### Include Metadata ```bash # Get extra context langsmith-fetch traces --limit 10 --include-metadata # Metadata includes: agent type, model, tags, environment ``` ### Concurrent Fetching (Faster) ```bash # Speed up large exports langsmith-fetch traces ./output --limit 100 --concurrent 10 ``` --- ## Troubleshooting ### "No traces found matching criteria" **Possible causes:** 1. No agent activity in the timeframe 2. Tracing is disabled 3. Wrong project name 4. API key issues **Solutions:** ```bash # 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=true ``` ### "Project not found" **Solution:** ```bash # View current config langsmith-fetch config show # Se
Related in AI Agents
skill-development
IncludedComprehensive meta-skill for creating, managing, validating, auditing, and distributing Claude Code skills and slash commands (unified in v2.1.3+). Provides skill templates, creation workflows, validation patterns, audit checklists, naming conventions, YAML frontmatter guidance, progressive disclosure examples, and best practices lookup. Use when creating new skills, validating existing skills, auditing skill quality, understanding skill architecture, needing skill templates, learning about YAML frontmatter requirements, progressive disclosure patterns, tool restrictions (allowed-tools), skill composition, skill naming conventions, troubleshooting skill activation issues, creating custom slash commands, configuring command frontmatter, using command arguments ($ARGUMENTS, $1, $2), bash execution in commands, file references in commands, command namespacing, plugin commands, MCP slash commands, Skill tool configuration, or deciding between skills vs slash commands. Delegates to docs-management skill for official documentation.
reprompter
IncludedTransform messy prompts into well-structured, effective prompts โ single or multi-agent. Use when: "reprompt", "reprompt this", "clean up this prompt", "structure my prompt", rough text needing XML tags and best practices, "reprompter teams", "repromptception", "run with quality", "smart run", "smart agents", multi-agent tasks, audits, parallel work, anything going to agent teams. Don't use when: simple Q&A, pure chat, immediate execution-only tasks. See "Don't Use When" section for details. Outputs: Structured XML/Markdown prompt, quality score (before/after), optional team brief + per-agent sub-prompts, agent team output files. Success criteria: Single mode quality score โฅ 7/10; Repromptception per-agent prompt quality score 8+/10; all required sections present, actionable and specific.
adaptive-compaction
IncludedAdaptive add-on policy and recovery layer that decides WHEN to compact, prune, snapshot, or fork -- replacing fixed-percent auto-compaction across Claude Code, Codex, and MCP-capable hosts. Trigger on auto-compact timing or damage: "when should I compact", "is it safe to compact now or start a fresh session", "auto-compact fires too early/mid-task", "switching to an unrelated task but the window still has space", "context rot", "answers get worse the longer the session runs", "the agent forgot the plan or my decisions after it summarized", "add a layer on top that manages context without changing the agent", raising autoCompactWindow to give the policy room, or installing/tuning a cross-tool compaction policy or PreCompact hook -- even when "compaction" is never said but the problem is context-window pressure or post-summarization memory loss. Do NOT use to summarize a conversation, build RAG, write a summarization prompt (decides WHEN not HOW), or answer max-context-length trivia.
agent-skill-creator
IncludedCreate cross-platform agent skills from workflow descriptions. Activates when users ask to create an agent, automate a repetitive workflow, create a custom skill, or need advanced agent creation. Triggers on phrases like create agent for, automate workflow, create skill for, every day I have to, daily I need to, turn process into agent, need to automate, create a cross-platform skill, validate this skill, export this skill, migrate this skill. Supports single skills, multi-agent suites, transcript processing, template-based creation, interactive configuration, cross-platform export, and spec validation.
llm-wiki
IncludedUse when building or maintaining a persistent personal knowledge base (second brain) in Obsidian where an LLM incrementally ingests sources, updates entity/concept pages, maintains cross-references, and keeps a synthesis current. Triggers include "second brain", "Obsidian wiki", "personal knowledge management", "ingest this paper/article/book", "build a research wiki", "compound knowledge", "Memex", or whenever the user wants knowledge to accumulate across sessions instead of being re-derived by RAG on every query.
skill-master
IncludedAgent Skills authoring, evaluation, and optimization. Create, edit, validate, benchmark, and improve skills following the agentskills.io specification. Use when designing SKILL.md files, structuring skill folders (references, scripts, assets), ingesting external documentation into skills, running trigger evals, benchmarking skill quality, optimizing descriptions, or performing blind A/B comparisons. Keywords: agentskills.io, SKILL.md, skill authoring, eval, benchmark, trigger optimization.