level-up
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseTake Your Agent to the Next Level
将你的Agent提升到新高度
This skill sets up your agent with the full LangWatch stack: tracing, prompt versioning, evaluation experiments, and agent simulation tests. Each step builds on the previous one.
本技能为你的Agent搭建完整的LangWatch技术栈:追踪、提示版本控制、评估实验以及Agent模拟测试。每个步骤都基于前一步构建。
Plan Limits
计划限制
LangWatch's free plan has limits on prompts, scenarios, evaluators, experiments, and datasets. When you hit a limit, the API returns with an upgrade link.
"Free plan limit of N reached..."How to handle:
- Work within the limits. If 3 resources of the relevant type are allowed, create 3 meaningful ones, not 10.
- Make every creation count: each one should demonstrate clear value.
- Show what works FIRST. If you hit a limit, summarize what was accomplished and note that upgrading the plan raises it — point to the subscription settings on the platform (license settings instead, if is set — self-hosted).
LANGWATCH_ENDPOINT - Do NOT delete existing resources to make room or repurpose an existing resource to evade the limit.
LangWatch的免费计划在提示词、场景、评估器、实验和数据集方面有使用限制。当达到限制时,API会返回并附带升级链接。
"Free plan limit of N reached..."处理方式:
- 在限制范围内操作。如果允许创建3个相关类型的资源,请创建3个有实际意义的资源,而非10个。
- 让每个资源都发挥价值:每个资源都应展示明确的作用。
- 先展示可行的内容。如果达到限制,总结已完成的工作,并说明升级计划可提升限制——指向平台的订阅设置(如果设置了即自托管版本,则指向许可证设置)。
LANGWATCH_ENDPOINT - 请勿删除现有资源腾出空间,或重新利用现有资源规避限制。
Prerequisites
前提条件
Use to read documentation as Markdown. Some useful entry points:
langwatch docs <path>bash
langwatch docs # Docs index
langwatch docs integration/python/guide # Python integration
langwatch docs integration/typescript/guide # TypeScript integration
langwatch docs prompt-management/cli # Prompts CLI
langwatch scenario-docs # Scenario docs indexDiscover commands with and . List and get commands accept for machine-readable output. Read the docs first instead of guessing SDK APIs or CLI flags.
langwatch --helplangwatch <subcommand> --help--format jsonIf no shell is available, fetch the same Markdown over plain HTTP. Append to any docs path (e.g. https://langwatch.ai/docs/integration/python/guide.md). Index: https://langwatch.ai/docs/llms.txt. Scenario index: https://langwatch.ai/scenario/llms.txt
.mdIf anything fails or confuses you while following this skill (broken commands, docs that do not match reality, errors you had to work around), ask the user for permission and run with a and (or ) to send it to the LangWatch team. No login needed, secrets and personal data are redacted locally, and it directly shapes what gets fixed. explains the options.
npx langwatch report --user-approved--title--summary--session <transcript.jsonl>npx langwatch report --helpProjects and API keys: target a real project, not a personal one.
LangWatch has two kinds of project:
- Team / shared projects: real projects inside an organization. Evaluations, experiments, prompts, datasets, simulations and instrumentation must always target one of these.
- Personal projects: a private "My Workspace" scratch space tied to a single user. Never send a user's evaluations, experiments or production traces here: it is for personal exploration only and is easily confused with a real project.
And two ways to authenticate:
- A project API key in (
.env): the credential everything in these skills uses. It is scoped to one real project. This is the default; prefer it unless the user explicitly asks for something else.LANGWATCH_API_KEY - (AI-tools / SSO): a personal device session for wrapping coding assistants (
langwatch login --device,langwatch claude, …). It is NOT for evaluations, prompts, datasets, scenarios or SDK instrumentation, and it points at a personal workspace. Do not run it to set up the work in these skills.langwatch codex
So for anything in these skills: make sure for a real, shared project is in the project's — most environments already have this provisioned. Do NOT run to pick a project, and never default to a personal project. If is set, they are self-hosted, use that endpoint instead of app.langwatch.ai.
LANGWATCH_API_KEY.envlangwatch loginLANGWATCH_ENDPOINT使用命令以Markdown格式阅读文档。以下是一些实用的入口:
langwatch docs <path>bash
langwatch docs # 文档索引
langwatch docs integration/python/guide # Python集成指南
langwatch docs integration/typescript/guide # TypeScript集成指南
langwatch docs prompt-management/cli # 提示词CLI管理文档
langwatch scenario-docs # 场景文档索引通过和查看可用命令。列表和获取类命令支持参数以输出机器可读格式。编写代码前请先阅读文档,不要猜测SDK API或CLI参数。
langwatch --helplangwatch <subcommand> --help--format json如果没有Shell环境,可以通过普通HTTP获取相同的Markdown文档。在任意文档路径后添加即可(例如:https://langwatch.ai/docs/integration/python/guide.md)。文档索引:https://langwatch.ai/docs/llms.txt。场景文档索引:https://langwatch.ai/scenario/llms.txt
.md如果在使用本技能过程中遇到任何问题或困惑(命令失效、文档与实际不符、需要解决的错误),请先征得用户许可,然后运行命令,附带和参数(或)将问题反馈给LangWatch团队。无需登录,机密信息和个人数据会在本地脱敏,反馈内容将直接用于问题修复。可查看详细选项。
npx langwatch report --user-approved--title--summary--session <transcript.jsonl>npx langwatch report --help项目与API密钥:请针对真实项目,而非个人项目。
LangWatch有两种类型的项目:
- 团队/共享项目:组织内的真实项目。评估、实验、提示词、数据集、模拟和工具集成必须始终指向此类项目。
- 个人项目:绑定单个用户的私有“我的工作区”临时空间。请勿将用户的评估、实验或生产追踪数据发送到此处:它仅用于个人探索,容易与真实项目混淆。
有两种认证方式:
- 文件中的项目API密钥(
.env):本技能所有操作使用的凭证。它仅作用于一个真实项目。这是默认方式,除非用户明确要求其他方式,否则优先使用此方式。LANGWATCH_API_KEY - (AI工具/单点登录):用于包裹编码助手(
langwatch login --device、langwatch claude等)的个人设备会话。它不适用于评估、提示词、数据集、场景或SDK工具集成,且指向个人工作区。请勿使用它来完成本技能中的设置工作。langwatch codex
因此,对于本技能中的所有操作:确保真实共享项目的已添加到项目的文件中——大多数环境已预先配置此密钥。请勿运行命令选择项目,且永远不要默认使用个人项目。如果设置了,说明是自托管版本,请使用该端点而非app.langwatch.ai。
LANGWATCH_API_KEY.envlangwatch loginLANGWATCH_ENDPOINTConsultant Mode
顾问模式
After completing all steps, don't just stop — summarize everything you set up and suggest 2-3 ways to go deeper based on what you learned about the codebase. Detailed guidance:
After delivering initial results, transition to consultant mode to help the user get maximum value.
Phase 1: read first. Before generating ANY content: read the codebase end-to-end (every system prompt, function, tool definition), study git history for agent-related changes (, then drill into prompt/agent/eval-related commits because the WHY in commit messages matters more than the WHAT), and read READMEs and comments for domain context.
git log --oneline -30Phase 2: quick wins. Generate best-effort content based on what you learned. Run everything, iterate until green. Show the user what works and create the a-ha moment.
Phase 3: go deeper. Once Phase 2 lands, summarize what you delivered, then suggest 2-3 specific improvements grounded in the codebase: domain edge cases, areas that need expert terminology or real data, integration points (APIs, databases, file uploads), or regression patterns from git history that deserve test coverage. Ask light questions with options, not open-ended ("Want scenarios for X or Y?", "I noticed Z was a recurring issue. Add a regression test?", "Do you have real customer queries I could use?"). Respect "that's enough" and wrap up cleanly.
Do NOT ask permission before Phase 1 and 2. Deliver value first. Do NOT ask generic questions or overwhelm with too many suggestions. Do NOT generate generic datasets. Everything must reflect the actual domain.
完成所有步骤后,不要直接结束——总结所有已设置的内容,并根据对代码库的了解,提出2-3种深入优化的方向。详细指导:
交付初步成果后,切换到顾问模式,帮助用户获取最大价值。
阶段1:先阅读。在生成任何内容之前:完整阅读代码库(所有系统提示词、函数、工具定义),研究与Agent相关的Git历史记录(,然后深入查看与提示词/Agent/评估相关的提交,因为提交信息中的“原因”比“内容”更重要),并阅读README和注释以了解领域上下文。
git log --oneline -30阶段2:快速见效。根据所学内容生成最佳内容。运行所有步骤,迭代直到成功。向用户展示可行的结果,创造“恍然大悟”的时刻。
阶段3:深入优化。当阶段2的成果落地后,总结已交付的内容,然后基于代码库提出2-3个具体的改进建议:领域边缘案例、需要专业术语或真实数据的领域、集成点(API、数据库、文件上传),或Git历史记录中值得添加测试覆盖的回归模式。提出带有选项的轻量问题,而非开放式问题(比如“需要为X还是Y创建场景?”、“我注意到Z是一个反复出现的问题,是否添加回归测试?”、“你有真实的客户查询可以使用吗?”)。尊重用户“足够了”的反馈,并干净利落地结束工作。
在阶段1和阶段2之前无需征得许可。先交付价值。不要提出通用问题或给出过多建议。不要生成通用数据集。所有内容必须反映实际领域。
Step 1: Add Tracing
步骤1:添加追踪功能
Add LangWatch tracing to capture all LLM calls, costs, and latency.
- Read the integration guide for this project's framework:
bash
langwatch docs # Browse the index to find the right page langwatch docs integration/python/guide # Python (or pick your framework) langwatch docs integration/typescript/guide # TypeScript (or pick your framework) - Install the LangWatch SDK (or
pip install langwatch)npm install langwatch - Add instrumentation following the framework-specific guide
- Add to
LANGWATCH_API_KEY.env
Verify: Run the application briefly and confirm traces appear:
bash
langwatch trace search --limit 5 --format json添加LangWatch追踪以捕获所有LLM调用、成本和延迟数据。
- 阅读对应项目框架的集成指南:
bash
langwatch docs # 浏览索引找到对应页面 langwatch docs integration/python/guide # Python(或选择你的框架) langwatch docs integration/typescript/guide # TypeScript(或选择你的框架) - 安装LangWatch SDK(或
pip install langwatch)npm install langwatch - 按照框架专属指南添加工具集成代码
- 将添加到
LANGWATCH_API_KEY文件中.env
验证:短暂运行应用程序,确认追踪数据已生成:
bash
langwatch trace search --limit 5 --format jsonStep 2: Version Your Prompts
步骤2:版本化你的提示词
Move hardcoded prompts to LangWatch Prompts CLI for version control and collaboration.
- Read the Prompts CLI docs:
bash
langwatch docs prompt-management/cli - Initialize:
langwatch prompt init - Create prompts: for each prompt in the code
langwatch prompt create <name> - Update application code to use instead of hardcoded strings
langwatch.prompts.get("name") - Sync:
langwatch prompt sync
Verify: (or check the Prompts section at https://app.langwatch.ai).
langwatch prompt listDo NOT hardcode prompts in code. Do NOT add try/catch fallbacks around .
prompts.get()将硬编码的提示词迁移到LangWatch Prompts CLI进行版本控制和协作。
- 阅读Prompts CLI文档:
bash
langwatch docs prompt-management/cli - 初始化:
langwatch prompt init - 创建提示词:对代码中的每个提示词运行
langwatch prompt create <name> - 更新应用代码,使用替代硬编码字符串
langwatch.prompts.get("name") - 同步:
langwatch prompt sync
验证:运行(或查看https://app.langwatch.ai的提示词板块)。
langwatch prompt list请勿在代码中硬编码提示词。请勿在周围添加try/catch回退逻辑。
prompts.get()Step 3: Create an Evaluation Experiment
步骤3:创建评估实验
Build a batch evaluation to measure your agent's quality across many examples.
- Read the experiments SDK docs:
bash
langwatch docs evaluations/experiments/sdk - Analyze the agent's code to understand what it does
- Generate a dataset of 10-20 examples tailored to the agent's domain (NOT generic examples)
- Create an experiment file:
- Python: Jupyter notebook with , evaluation loop, and evaluators
langwatch.experiment.init() - TypeScript: Script with and
langwatch.experiments.init()evaluation.run()
- Python: Jupyter notebook with
- Include at least one evaluator (LLM-as-judge for quality is a good default)
Verify: Run the experiment ( or ) and check results appear in the LangWatch Experiments view.
jupyter nbconvert --to notebook --execute experiment.ipynbnpx tsx experiment.ts构建批量评估,在多个示例中衡量Agent的质量。
- 阅读实验SDK文档:
bash
langwatch docs evaluations/experiments/sdk - 分析Agent代码以了解其功能
- 生成10-20个针对Agent领域的数据集示例(请勿使用通用示例)
- 创建实验文件:
- Python:包含、评估循环和评估器的Jupyter笔记本
langwatch.experiment.init() - TypeScript:包含和
langwatch.experiments.init()的脚本evaluation.run()
- Python:包含
- 至少包含一个评估器(默认使用LLM作为质量评判器是不错的选择)
验证:运行实验(或),并确认结果已显示在LangWatch实验视图中。
jupyter nbconvert --to notebook --execute experiment.ipynbnpx tsx experiment.tsStep 4: Add Agent Simulation Tests
步骤4:添加Agent模拟测试
Create scenario tests to validate agent behavior in realistic multi-turn conversations.
- Read the Scenario docs:
bash
langwatch scenario-docs # Browse the index langwatch scenario-docs getting-started # Getting Started guide langwatch scenario-docs agent-integration - Install the Scenario SDK (or
pip install langwatch-scenario)npm install @langwatch/scenario - Write scenario tests with ,
AgentAdapter, andUserSimulatorAgentJudgeAgent - Use semantic criteria in JudgeAgent (NOT regex matching)
Verify: Run the tests ( or ) and confirm they pass.
pytest -snpx vitest runNEVER invent your own testing framework. Use / .
@langwatch/scenariolangwatch-scenario创建场景测试,验证Agent在真实多轮对话中的行为。
- 阅读场景文档:
bash
langwatch scenario-docs # 浏览索引 langwatch scenario-docs getting-started # 入门指南 langwatch scenario-docs agent-integration - 安装Scenario SDK(或
pip install langwatch-scenario)npm install @langwatch/scenario - 使用、
AgentAdapter和UserSimulatorAgent编写场景测试JudgeAgent - 在JudgeAgent中使用语义判定标准(请勿使用正则匹配)
验证:运行测试(或)并确认测试通过。
pytest -snpx vitest run切勿自行开发测试框架。请使用 / 。
@langwatch/scenariolangwatch-scenarioCommon Mistakes
常见错误
- Do NOT skip any step -- each builds on the previous
- Do NOT use generic datasets in the experiment -- tailor them to the agent's domain
- Do NOT hardcode prompts -- use the Prompts CLI
- Do NOT invent testing frameworks -- use Scenario
- Do NOT skip verification steps -- run the application/experiment/tests after each step
- Always read docs via /
langwatch docs ...before writing code; do not work from memory of past framework versionslangwatch scenario-docs ...
- 请勿跳过任何步骤——每个步骤都基于前一步构建
- 请勿在实验中使用通用数据集——请针对Agent领域定制
- 请勿硬编码提示词——使用Prompts CLI
- 请勿自行开发测试框架——使用Scenario
- 请勿跳过验证步骤——每个步骤完成后运行应用/实验/测试
- 编写代码前请始终通过/
langwatch docs ...阅读文档;请勿依赖过往框架版本的记忆langwatch scenario-docs ...