← 返回列表
全部 Skill›数据与AI Data & AI›writing-evals

writing-evals

作者 @PostHog · 语言 en
Teaches how to write and run evals on the `products/posthog_ai/eval_harness/` harness — sandboxed agent suites that execute the real coding agent in a Docker or Modal sandbox against a seeded Hedgebox project, and one-shot suites that score a single in-process model invocation per case. Use when adding or changing eval suites, cases, scorers, seeders, or synthesizers under `products/posthog_ai/evals/` or `products/*/evals/`, when touching the harness under `products/posthog_ai/eval_harness/`, or when running or debugging those evals (`hogli evals`). Covers suite kinds and discovery, case anatomy, the seeder/synthesizer split, the one-branch scorer patterns, and how to read results. Not for `ee/hogai/eval/ci/` pytest evals, and not for the LLM Analytics product's evaluation features.
数据与AI Data & AILLM 与 AI通用执行命令读写文件敏感路径待翻译
最近源活动
—
检测 SKILL.md 语言
en
星标 ★
39,613
分支 Fork
0
安装选项
提示
指令
使用 AI 助手安装
将下面的提示复制到你正在使用的 AI 助手中。
下载完整 Skill 目录(含全部配套文件)。 下载压缩包 ↓
SKILL.md 原文预览

Writing and running evals

The harness under products/posthog_ai/eval_harness/ runs two kinds of suites: sandboxed suites execute the real coding agent inside a real sandbox against a seeded Hedgebox project and score what it did, and one-shot suites score a single in-process model invocation per case.

Neither runs under pytest — the standalone harness boots the shared infrastructure the selected suites need (for sandboxed suites: test DB, Django live server, LLM gateway, MCP server, Temporal, personhog; for one-shot suites: just the test DB, personhog, and demo data) and runs every selected suite concurrently, with Braintrust as the eval engine.

Read before writing anything:

  • products/posthog_ai/eval_harness/README.md — usage, CLI flags, providers.
  • products/posthog_ai/evals/AGENTS.md — the Hedgebox dataset reference. Your prompts, expected values, and scorers must match that taxonomy exactly (signed_up, not sign_up).
  • products/posthog_ai/eval_harness/harness/AGENTS.md — invariants when touching the harness itself.

Field-level API detail (case fields, the output dict, LogParser, seeder inventory) lives in references/authoring-reference.md.

Writing a suite

Suites are discovered by convention, not registered: any coroutine named eval_* in a file named eval_*.py, taking a single ctx: EvalContext and returning None.

The harness discovers suites from two root sets:

  • products/posthog_ai/evals/<domain>/ — the built-in tree, reserved for Max and other agent suites. The directory is the domain; the suite id is <domain>/<module>::<fn> (import path products.posthog_ai.evals.<domain>.<module>).
  • products/<product>/evals/ — where a product ships eval suites next to its own code. Note the plural evals/: the singular products/signals/eval/ is an existing pytest tree and is not collected by the harness. The product is the domain; the suite id is <product>/<module>::<fn> (import path products.<product>.evals.<module>).

New product-owned evals belong under products/<product>/evals/. Both root sets use the same conventions (the eval_*-coroutine-in-eval_*.py rule, the SUITE_KIND marker, and substring selectors).

No evals/ tree needs a pytest-collection exclusion: pytest's default python_files matches test_*.py, so eval_*.py files there are never collected as tests. Do not add a conftest.py under an evals/ tree.

from products.posthog_ai.eval_harness.base import SandboxedEval
from products.posthog_ai.eval_harness.config import SandboxedEvalCase
from products.posthog_ai.eval_harness.harness.context import EvalContext


async def eval_my_thing(ctx: EvalContext) -> None:
    await SandboxedEval(
        experiment_name="sandboxed-my-thing-cli",
        cases=[SandboxedEvalCase(name="my_case", prompt="...")],
        scorers=[],
        ctx=ctx,
    )
  • One suite = one experiment. Bundle related cases into one suite; split only when the scorecard would be heterogeneous (self-skipping scorers stretch a shared scorer list across mildly different cases, but a scorecard where half the scorers skip half the cases is a sign to split).
  • experiment_name identifies local and PostHog runs — keep it stable for cross-run comparison. Existing sandboxed suites end in -cli because the MCP server serves the cli surface.
  • SandboxedEval and OneShotEval always run Braintrust locally without uploading to it. With offline_suite and a publishing credential, results publish to PostHog by default. Set send_to_posthog=False for local-only results; local logs are always written. Ordinary SDK and trace clients still honor OPT_OUT_CAPTURE. See evaluation result reporting.
  • To enroll a suite in PostHog reporting, register its scorer kinds and immutable version UUIDs in the owning offline_config.py catalog, then pass offline_suite=offline_suite("<domain>/<module>::<function>", metrics=[...]) to the runner. Use the PostHog AI catalog for built-in suites and the Slack app catalog for Slack suites. List every explicit scorer's _name() in metrics; the catalog adds exit_code_zero only for sandboxed suites. For one-shot suites, pass suite_kind=SUITE_KIND. The enrollment test discovers catalog-using modules and checks every suite function against its scorer list.
  • Uploading and tagging require POSTHOG_OFFLINE_EVAL_API_KEY to be a personal key with offline_evaluation_ingestion:write and evaluation:write. Ingestion-only personal or project secret keys can upload without tags. Upload success is recorded before the separate, bounded tag update, so a tagging failure or interruption keeps the results link.

One-shot suites

A module-level SUITE_KIND declares how a module's suites execute; absent means sandboxed, so existing suites need nothing.

SuiteKind.ONE_SHOT suites skip the sandbox entirely: the harness boots only the test DB, personhog, and demo data for them, a

评论
PPostHog
PostHog
PostHog/posthog
查看 GitHub 仓库 查看作者的其他 Skill
来源信息
作者@PostHog
所属大类数据与AI Data & AI / LLM 与 AI
国内可用性通用
最近源活动—
风险提示执行命令、读写文件、敏感路径
提示:风险标签为程序静态扫描结果,仅作提示,不代表安全认证。安装前请阅读 SKILL.md 及其引用的脚本、权限,自行判断是否可信。