langsmith-fetch by aaaaqwq/agi-super-skills
npx skills add https://github.com/aaaaqwq/agi-super-skills --skill langsmith-fetch直接在终端中从 LangSmith Studio 获取执行轨迹,以调试 LangChain 和 LangGraph 智能体。
当用户提及以下内容时自动激活:
pip install langsmith-fetch
export LANGSMITH_API_KEY="your_langsmith_api_key"
export LANGSMITH_PROJECT="your_project_name"
验证设置:
echo $LANGSMITH_API_KEY
echo $LANGSMITH_PROJECT
当用户询问: "刚才发生了什么?" 或 "调试我的智能体"
执行:
langsmith-fetch traces --last-n-minutes 5 --limit 5 --format pretty
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
分析并报告:
示例响应格式:
在过去 5 分钟内找到 3 条轨迹:
轨迹 1:✅ 成功
- 智能体:memento
- 工具:recall_memories, create_entities
- 持续时间:2.3 秒
- 令牌:1,245
轨迹 2:❌ 错误
- 智能体:cypher
- 错误:"Neo4j 连接超时"
- 持续时间:15.1 秒
- 失败于:search_nodes 工具
轨迹 3:✅ 成功
- 智能体:memento
- 工具:store_memory
- 持续时间:1.8 秒
- 令牌:892
💡 发现问题:轨迹 2 因 Neo4j 超时而失败。建议检查数据库连接。
当用户提供: 轨迹 ID 或说 "调查那个错误"
执行:
langsmith-fetch trace <trace-id> --format json
分析 JSON 并报告:
示例响应格式:
深度分析 - 轨迹 abc123
目标:用户询问 "在 Neo4j 中查找所有项目"
执行流程:
1. ✅ search_nodes(query: "projects")
→ 找到 24 个节点
2. ❌ get_node_details(node_id: "proj_123")
→ 错误:"未找到节点"
→ 这是失败点
3. ⏹️ 执行停止
根本原因:
search_nodes 工具返回的节点 ID 在数据库中已不存在,
可能是由于最近删除了节点。
建议修复:
1. 在 get_node_details 工具中添加错误处理
2. 在搜索结果中过滤已删除的节点
3. 更新缓存失效策略
令牌使用情况:1,842 个令牌 ($0.0276)
执行时间:8.7 秒
当用户说: "保存此会话" 或 "导出轨迹"
执行:
# 创建带时间戳的会话文件夹
SESSION_DIR="langsmith-debug/session-$(date +%Y%m%d-%H%M%S)"
mkdir -p "$SESSION_DIR"
# 导出轨迹
langsmith-fetch traces "$SESSION_DIR/traces" --last-n-minutes 30 --limit 50 --include-metadata
# 导出线程(对话)
langsmith-fetch threads "$SESSION_DIR/threads" --limit 20
报告:
✅ 会话导出成功!
位置:langsmith-debug/session-20251224-143022/
- 轨迹:42 个文件
- 线程:8 个文件
您现在可以:
1. 查看单个轨迹文件
2. 与团队共享文件夹
3. 使用外部工具分析
4. 存档以供将来参考
会话大小:2.3 MB
当用户询问: "显示错误" 或 "什么失败了?"
执行:
# 获取最近的轨迹
langsmith-fetch traces --last-n-minutes 30 --limit 50 --format json > recent-traces.json
# 搜索错误
grep -i "error\|failed\|exception" recent-traces.json
分析并报告:
示例响应格式:
错误分析 - 过去 30 分钟
总轨迹数:50
失败轨迹数:7 (14% 失败率)
错误细分:
1. Neo4j 连接超时 (4 次)
- 智能体:cypher
- 工具:search_nodes
- 首次发生:14:32
- 最后发生:14:45
- 模式:发生在高峰负载期间
2. 内存存储失败 (2 次)
- 智能体:memento
- 工具:store_memory
- 错误:"Pinecone 速率限制超限"
- 发生时间:14:38, 14:41
3. 未找到工具 (1 次)
- 智能体:sqlcrm
- 尝试的工具:"export_report" (不存在)
- 发生时间:14:35
💡 建议:
1. 为 Neo4j 超时添加重试逻辑
2. 为 Pinecone 实施速率限制
3. 修复 sqlcrm 工具配置
用户说: "我的智能体没有任何反应"
步骤:
检查是否存在轨迹:
langsmith-fetch traces --last-n-minutes 5 --limit 5
如果未找到轨迹:
LANGCHAIN_TRACING_V2=trueLANGCHAIN_API_KEY如果找到轨迹:
用户说: "为什么它使用了错误的工具?"
步骤:
用户说: "智能体不记得事情"
步骤:
搜索内存操作:
langsmith-fetch traces --last-n-minutes 10 --limit 20 --format raw | grep -i "memory\|recall\|store"
检查:
用户说: "智能体太慢了"
步骤:
导出包含元数据:
langsmith-fetch traces ./perf-analysis --last-n-minutes 30 --limit 50 --include-metadata
分析:
识别瓶颈并建议优化方案
langsmith-fetch traces --limit 5 --format pretty
用于: 快速视觉检查,向用户展示
langsmith-fetch traces --limit 5 --format json
用于: 详细分析,语法高亮审查
langsmith-fetch traces --limit 5 --format raw
用于: 管道传输到其他命令,自动化
# 特定时间戳之后
langsmith-fetch traces --after "2025-12-24T13:00:00Z" --limit 20
# 最近 N 分钟 (最常用)
langsmith-fetch traces --last-n-minutes 60 --limit 100
# 获取额外上下文
langsmith-fetch traces --limit 10 --include-metadata
# 元数据包括:智能体类型、模型、标签、环境
# 加速大型导出
langsmith-fetch traces ./output --limit 100 --concurrent 10
可能原因:
解决方案:
# 1. 尝试更长的时间范围
langsmith-fetch traces --last-n-minutes 1440 --limit 50
# 2. 检查环境
echo $LANGSMITH_API_KEY
echo $LANGSMITH_PROJECT
# 3. 尝试获取线程
langsmith-fetch threads --limit 10
# 4. 验证代码中是否启用了追踪
# 检查:LANGCHAIN_TRACING_V2=true
解决方案:
# 查看当前配置
langsmith-fetch config show
# 设置正确的项目
export LANGSMITH_PROJECT="correct-project-name"
# 或永久配置
langsmith-fetch config set project "your-project-name"
解决方案:
# 添加到 shell 配置文件 (~/.bashrc 或 ~/.zshrc)
echo 'export LANGSMITH_API_KEY="your_key"' >> ~/.bashrc
echo 'export LANGSMITH_PROJECT="your_project"' >> ~/.bashrc
# 重新加载 shell 配置
source ~/.bashrc
# 更改后进行快速检查
langsmith-fetch traces --last-n-minutes 5 --limit 5
langsmith-debug/
├── sessions/
│ ├── 2025-12-24/
│ └── 2025-12-25/
├── error-cases/
└── performance-tests/
当发现错误时:
error-cases/ 文件夹# 提交代码前
langsmith-fetch traces --last-n-minutes 10 --limit 5
# 如果发现错误
langsmith-fetch trace <error-id> --format json > pre-commit-error.json
# 最常用命令
# 快速调试
langsmith-fetch traces --last-n-minutes 5 --limit 5 --format pretty
# 特定轨迹
langsmith-fetch trace <trace-id> --format pretty
# 导出会话
langsmith-fetch traces ./debug-session --last-n-minutes 30 --limit 50
# 查找错误
langsmith-fetch traces --last-n-minutes 30 --limit 50 --format raw | grep -i error
# 包含元数据
langsmith-fetch traces --limit 10 --include-metadata
langsmith-fetch--format pretty 获取人类可读的输出--format json版本: 0.1.0 作者: Ahmad Othman Ammar Adi 许可证: MIT 仓库: https://github.com/OthmanAdi/langsmith-fetch-skill
每周安装次数
1
仓库
GitHub 星标
11
首次出现
4 天前
安全审计
安装于
amp1
cline1
openclaw1
opencode1
cursor1
kimi-cli1
Debug LangChain and LangGraph agents by fetching execution traces directly from LangSmith Studio in your terminal.
Automatically activate when user mentions:
pip install langsmith-fetch
export LANGSMITH_API_KEY="your_langsmith_api_key"
export LANGSMITH_PROJECT="your_project_name"
Verify setup:
echo $LANGSMITH_API_KEY
echo $LANGSMITH_PROJECT
When user asks: "What just happened?" or "Debug my agent"
Execute:
langsmith-fetch traces --last-n-minutes 5 --limit 5 --format pretty
Analyze 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 json
Analyze 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 seconds
When 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 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
When 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.json
Analyze 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 configuration
User says: "My agent isn't doing anything"
Steps:
Check if traces exist:
langsmith-fetch traces --last-n-minutes 5 --limit 5
If 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-metadata
Analyze:
Identify bottlenecks and suggest optimizations
langsmith-fetch traces --limit 5 --format pretty
Use for: Quick visual inspection, showing to users
langsmith-fetch traces --limit 5 --format json
Use for: Detailed analysis, syntax-highlighted review
langsmith-fetch traces --limit 5 --format raw
Use 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 10
Possible 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=true
Solution:
# 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 5
langsmith-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-metadata
langsmith-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
Weekly Installs
1
Repository
GitHub Stars
11
First Seen
4 days ago
Security Audits
Gen Agent Trust HubFailSocketPassSnykWarn
Installed on
amp1
cline1
openclaw1
opencode1
cursor1
kimi-cli1
Azure Data Explorer (Kusto) 查询技能:KQL数据分析、日志遥测与时间序列处理
114,200 周安装