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 的更多技能

arxiv-search
langchain-ai
透過主題搜尋arXiv上的預印本與學術論文,並可擷取摘要。支援物理、數學、電腦科學、生物學、統計學及相關領域的查詢式搜尋。可設定結果數量上限(預設為10篇論文),結果依相關性排序。回傳每篇符合論文的標題與摘要。需使用arxiv Python套件;若尚未安裝,請透過pip進行安裝。
official
blog-post
langchain-ai
長篇部落格文章撰寫,包含研究委派、結構化內容模板及AI生成封面圖片。在寫作前將研究委派給子代理,並將發現儲存為Markdown格式以供參考與上下文。強制採用五部分文章結構:鉤子、背景、主要內容(3-5個章節)、實際應用,以及附帶行動呼籲的結論。透過涵蓋主題、風格、構圖、色彩與光線的詳細提示,生成SEO優化的封面圖片。將文章輸出至...
official
code-review
langchain-ai
對變更進行結構化的程式碼審查,檢查正確性、風格、測試及潛在問題。
official
coding-prefs
langchain-ai
在做出非平凡的風格決策前,先從 /memory/coding-prefs.md 讀取使用者的編碼偏好,並在使用者提供新偏好時將其附加至該檔案。
official
competitor-analysis
langchain-ai
當被要求分析競爭對手時:
official
cudf-analytics
langchain-ai
用於在資料集、CSV或表格資料上進行GPU加速的資料分析,使用NVIDIA cuDF。當任務涉及groupby聚合、統計…時觸發。
official
cuml-machine-learning
langchain-ai
用於在表格數據上進行GPU加速的機器學習,使用NVIDIA cuML。當任務涉及分類、回歸、聚類、降維…時觸發。
official
data-visualization
langchain-ai
用於建立符合出版品質的圖表與多面板分析摘要。當任務涉及資料視覺化、繪製結果、建立…時觸發。
official