A practical guide to tracing and evaluating agents with LangSmith
A Juejin learning note explains how developers can connect LangChain, LangGraph, and other agent applications to LangSmith for tracing and evaluation. It covers API-key setup, automatic and manual tracing, trace-tree inspection, metadata and tags, dataset-based evaluation, and prompt iteration, recommending that beginners start with tracing. The author also describes LangSmith as LangChain's observability and evaluation platform.
The tutorial gives AI developers a concrete workflow for inspecting agent tool calls, debugging failures, and comparing prompt or model changes through traces and evaluations.
1. LangSmith 是什么
LangSmith 是 LangChain 官方推出的可观测性与评估平台,核心解决 Agent 开发中的“黑箱”问题:你不知道模型为什么选了某个工具、在哪一步出错、token 花在哪里。
它围绕三个能力展开:
| 能力 | 作用 | 你什么时候用 |
|---|---|---|
| Tracing(追踪) | 记录每一次请求的完整执行链路 | 调试 Agent,看每一步发生了什么 |
| Evaluation(评估) | 用数据集批量测试 Agent 质量 | 改 prompt/换模型后,验证是否变好 |
| Prompt Engineering | 在线创建、测试、版本化 prompt | 迭代 prompt 时 |
对 Agent 学习者来说,Tracing 是最先要用起来的功能。你前面学的 Tool Calling 闭环、Message 流转,在 LangSmith 的追踪树里都能直观看到。
2. 准备工作:账号与 API Key
注册地址:smith.langchain.com,支持 Google/GitHub/邮箱登录,无需信用卡。