SuperAPI AI 工具集

langsmith-fetch

智能体与模型

查看项目

更新于 10-15 15:35

技能介绍

用途

langsmith-fetch 用于获取 LangSmith 追踪(traces),以便调试智能体(agent)的行为。当你在排查智能体问题、回顾对话历史,或调查工具调用时,可以使用该工具。

前置条件

使用前需要满足两项要求:

  • 项目依赖中已安装 langsmith-fetch。
  • 在 .env 文件中配置了 LANGSMITH_API_KEY。

使用方式

查找 .env 文件

首先定位包含 LANGSMITH_API_KEY 的 .env 文件:

find . -name ".env" -type f 2>/dev/null | head -5

获取追踪记录

所有命令都需要配合 --env-file <path-to-.env> 使用。

获取最近的追踪记录(默认使用 .env 中的 LANGSMITH_PROJECT,也可通过 --project-uuid 指定):

uv run --env-file <path> langsmith-fetch traces ./traces --limit 10
uv run --env-file <path> langsmith-fetch traces ./traces --project-uuid <uuid> --limit 10

按 ID 获取单条追踪:

uv run --env-file <path> langsmith-fetch trace <id>

包含元数据(时间、token、成本):

uv run --env-file <path> langsmith-fetch trace <id> --include-metadata

输出格式

  • --format pretty:人类可读(默认)。
  • --format json:格式化 JSON。
  • --format raw:紧凑 JSON,便于管道处理。

排查工作流

  1. 查找 .env:find . -name ".env" -type f 2>/dev/null
  2. 获取最近的追踪记录:uv run --env-file <path> langsmith-fetch traces ./debug --limit 10
  3. 在保存的 JSON 文件中找到相关的追踪记录。
  4. 检查:调用了哪些工具?它们返回了什么?结果是否正确或符合预期?

适用场景

适用于调试智能体行为、排查智能体问题、回顾对话历史以及调查工具调用。

限制

资料中未提供关于平台支持、收费、价格或效果等方面的信息,暂未提供。