langsmith-code-eval

作者: langchain-ai

为LangSmith追踪的智能体创建基于代码的评估器。在构建自定义评估逻辑、测试工具使用模式或对智能体输出进行评分时使用…

npx skills add https://github.com/langchain-ai/lca-skills --skill langsmith-code-eval

LangSmith Code Evaluator Creation

Creates evaluators for LangSmith experiments through structured inspection and implementation.

Prerequisites

  • langsmith Python package installed
  • LANGSMITH_API_KEY environment variable set (check project's .env file)

Workflow

Copy this checklist and track progress:

Evaluator Creation Progress:
- [ ] Step 1: Gather info from user
- [ ] Step 2: Inspect trace and dataset structure
- [ ] Step 3: Read agent code
- [ ] Step 4: Write evaluator
- [ ] Step 5: Write experiment runner
- [ ] Step 6: Run and iterate

Step 1: Gather Info from User

IMPORTANT: Do NOT search or explore the codebase. Ask the user all of these questions upfront using AskUserQuestion before doing anything else.

Ask the user the following in a single AskUserQuestion call:

  1. Python command: How do you run Python in this project? (e.g., python, python3, uv run python, poetry run python)
  2. Agent file path: What is the path to your agent file?
  3. LangSmith project name: What is your LangSmith project name (where traces are logged)?
  4. LangSmith dataset name: What is the name of the dataset to evaluate against?
  5. Evaluation goal: What behavior should pass vs fail? Common types:
    • Tool usage: Did the agent call the correct tool?
    • Output correctness: Does output match expected format/content?
    • Policy compliance: Did it follow specific rules?
    • Classification: Did it categorize correctly?

Step 2: Inspect Trace and Dataset Structure

Using the info from Step 1, run the inspection scripts located in this skill's directory:

{python_cmd} {skill_dir}/scripts/inspect_trace.py PROJECT_NAME [RUN_ID]
{python_cmd} {skill_dir}/scripts/inspect_dataset.py DATASET_NAME

Replace {python_cmd} with the command from Step 1, and {skill_dir} with this skill's directory path.

Verify the trace matches the agent:

  • Does the trace type match? (e.g., OpenAI trace for OpenAI agent)
  • Does it contain the data needed for evaluation?
  • If mismatched, clarify before proceeding.

From the dataset inspection, note:

  • Input schema (what gets passed to the agent)
  • Output schema (reference/expected outputs)
  • Metadata fields (e.g., expected_tool, difficulty, labels)

The dataset metadata often contains ground truth for evaluation (e.g., which tool should be called, expected classification).

Step 3: Read Agent Code

Read the agent file provided in Step 1 to identify:

  • Entry point function (look for @traceable decorator)
  • Available tools
  • Output format (what the function returns)

Step 4: Write the Evaluator

Create evaluator functions based on trace and dataset structure. See EVALUATOR_REFERENCE.md for function signatures and return formats.

Step 5: Write Experiment Runner

Create a script that:

  1. Imports the agent's entry function
  2. Wraps it as a target function
  3. Runs evaluate() or aevaluate() against the dataset

See EVALUATOR_REFERENCE.md for evaluate() usage.

Step 6: Run and Iterate

Execute the experiment, review results in LangSmith, refine evaluators as needed.

来自 langchain-ai 的更多技能

langgraph-docs
langchain-ai
访问LangGraph文档,构建有状态代理和多代理工作流。获取官方LangGraph Python文档,涵盖状态机、基于图的代理设计以及人机协同模式。根据查询类型优先提供相关文档:实现指南解答操作问题,概念页面讲解理论,教程提供端到端示例,API参考提供技术细节。自动选择2–4个最相关的文档URL并检索其内容以回答...
official
langgraph-human-in-the-loop
langchain-ai
暂停图执行以进行人工审查、批准或验证,随后根据其输入恢复执行。需要三个组件:检查点存储器(InMemorySaver 或 PostgresSaver)、配置中的线程 ID 以及 JSON 可序列化的中断负载。interrupt(value) 暂停执行并展示数据;Command(resume=value) 恢复执行并将该值返回给暂停的节点。恢复时,interrupt() 之前的所有代码会重新执行,因此副作用必须具有幂等性(使用 upsert 而非 insert)。支持审批工作流,...
official
web-research
langchain-ai
用于处理与网络研究相关的请求;它提供了一种结构化的方法来进行全面的网络研究
official
langchain-oss-primer
langchain-ai
任何LangChain、Deep Agents或LangGraph代理构建项目都请始终从这里开始。在选择其他技能或编写任何内容之前,这是必需的起点。
official
skill-creator
langchain-ai
创建有效技能的指南,通过专业知识、工作流程或工具集成来扩展代理能力。当用户……时使用此技能。
official
social-media
langchain-ai
根据研究内容起草特定平台的社交媒体帖子,并生成配套图片。支持领英帖子(1300字符,专业语气)和推特/X话题(每条推文280字符,采用1/🧵格式)。需在撰写前将研究任务委托给子代理,随后阅读研究结果以确保准确性和相关性。使用generate_social_image工具自动生成引人注目的社交图片,采用粗体高对比度构图,针对小屏幕进行优化...
official
deep-agents-memory
langchain-ai
为Deep Agents提供可插拔的内存与文件后端,支持临时、持久化和混合路由选项。四种后端类型:StateBackend(线程作用域,临时)、StoreBackend(跨会话持久化)、FilesystemBackend(本地开发时真实磁盘访问)和CompositeBackend(将不同路径路由到不同后端)。FilesystemMiddleware提供六种文件操作工具:ls、read_file、write_file、edit_file、glob、grep。CompositeBackend使用最长前缀匹配进行路由...
official
deep-agents-orchestration
langchain-ai
编排子代理,规划多步骤任务,并对敏感操作要求人工审批。通过任务工具将工作委派给专业子代理;自定义子代理支持独立的工具集和系统提示,而默认的“通用”子代理继承主代理配置。使用write_todos规划并跟踪复杂工作流,将任务组织为待处理、进行中和已完成状态;需要thread_id以实现跨调用的持久化。实现...
official