Prompts2026年4月8日·1 分钟阅读

LangSmith — Prompt Debugging and LLM Observability

Debug, test, and monitor LLM applications in production. LangSmith provides trace visualization, prompt playground, dataset evaluation, and regression testing for AI.

Agent 就绪

这个资产会安全暂存

这个资产会先安全暂存。复制的指令会要求 Agent 读取暂存文件,并在激活脚本、MCP 配置或全局配置前先确认。

Stage only · 27/100策略:需暂存
Agent 入口
任意 MCP/CLI Agent
类型
Prompt
安装
Stage only
信任
信任等级:Community
入口
LangSmith — Prompt Debugging and LLM Observability
安全暂存命令
npx -y tokrepo@latest install 4d9432ea-330f-44b6-a629-5b29627f746a --target codex

先暂存文件;激活前需要读取暂存 README 和安装计划。

TL;DR
LangSmith provides tracing, prompt testing, and evaluation tools for LLM app debugging.
§01

What it is

LangSmith is LangChain's observability and evaluation platform for LLM applications. It provides trace visualization for every LLM call, a prompt playground for rapid iteration, dataset-driven evaluation, and regression testing. You see exactly what prompts were sent, what the model returned, how long it took, and how many tokens it consumed.

This tool is for developers building LLM-powered applications who need visibility into model behavior. It works with LangChain, LangGraph, and standalone LLM calls.

§02

How it saves time or tokens

Without observability, debugging LLM applications is guesswork. LangSmith shows the full trace of every chain, agent, or tool call, making it easy to spot where things go wrong. The prompt playground lets you test variations without redeploying. Dataset evaluation automates regression testing across model or prompt changes. The estimated token cost for the monitoring workflow is around 4,100 tokens.

§03

How to use

  1. Create a LangSmith account and get an API key.
  2. Set the environment variables in your application.
  3. Traces are automatically captured for LangChain applications.
  4. View traces, run evaluations, and iterate in the dashboard.
# Set environment variables
export LANGCHAIN_TRACING_V2=true
export LANGCHAIN_API_KEY='your-langsmith-api-key'
export LANGCHAIN_PROJECT='my-project'

# Your LangChain code is now automatically traced
python my_app.py

# Open LangSmith dashboard to view traces
# https://smith.langchain.com
§04

Example

Adding custom tracing to non-LangChain code:

from langsmith import traceable
import openai

client = openai.OpenAI()

@traceable(name='generate_summary')
def summarize(text: str) -> str:
    response = client.chat.completions.create(
        model='gpt-4',
        messages=[{'role': 'user', 'content': f'Summarize: {text}'}]
    )
    return response.choices[0].message.content

# Every call is now traced in LangSmith
result = summarize('Long article text here...')
§05

Related on TokRepo

§06

Common pitfalls

  • LangSmith sends trace data to LangChain's servers. Ensure your security policy allows this for the data being processed.
  • The free tier has trace retention limits. High-volume applications may need a paid plan for full trace history.
  • Automatic tracing only works with LangChain. For other frameworks, use the @traceable decorator or manual trace API.
  • Evaluation datasets need curation. Poor-quality test cases lead to misleading evaluation results.
  • LangSmith is a separate service from LangChain the library. You need an account even if you already use LangChain.
  • Review the official documentation before deploying to production to ensure compatibility with your specific environment and requirements.
  • Start with default settings and customize incrementally. Changing too many configuration options at once makes debugging harder.

常见问题

Does LangSmith work without LangChain?+

Yes. LangSmith provides a Python SDK with @traceable decorators that work with any LLM provider. You can trace OpenAI, Anthropic, or custom model calls without using LangChain as a framework.

What does a trace show?+

A trace shows the complete execution path: input prompts, model outputs, token usage, latency per step, tool calls, intermediate results, and errors. For chains and agents, you see each step in a timeline view.

How much does LangSmith cost?+

LangSmith offers a free tier suitable for development and small projects. Paid plans scale with trace volume and add features like longer retention, team collaboration, and higher rate limits.

Can I run evaluations automatically?+

Yes. LangSmith supports dataset-driven evaluation where you define test cases with expected outputs. Run evaluations on prompt changes, model switches, or code updates to catch regressions before deployment.

Is LangSmith an alternative to Langfuse?+

Both provide LLM observability. LangSmith is built by the LangChain team with tight LangChain integration. Langfuse is open-source and self-hostable. Choose based on your integration needs and self-hosting requirements.

引用来源 (3)
🙏

来源与感谢

smith.langchain.com — by LangChain

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产