writing-evals
Skill721 starsChanged 59 days agoMITView on GitHub
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.
- Reads credentials
1 other project uses a version of this.
Adopted by
Most recently taken up by
- PostHog/posthogword for word, first seen Oct 4, 2026
Other versions1 project uses a version of this.
Word for word · 1
- PostHog/posthog★ 40k100% same
Edited · 0
None found.
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository119 other files it gives its agents.
- AGENTS.mdAGENTS.md
- common/AGENTS.mdAGENTS.md
- proto/AGENTS.mdAGENTS.md
- rust/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- common/CLAUDE.mdCLAUDE.md
- proto/CLAUDE.mdCLAUDE.md
- rust/CLAUDE.mdCLAUDE.md
- .cursor/rules/django-python.mdcCursor rule
- .cursor/rules/react-typescript.mdcCursor rule
- .cursor/rules/rust.mdcCursor rule
- adding-activity-loggingSkill
- adding-api-scopesSkill
- adding-inbound-webhooksSkill
- adding-inbox-sourcesSkill
- adding-ingestion-warningsSkill
- adding-mcp-store-serversSkill
- adding-personhog-rpcSkill
- adding-product-alertingSkill
- adding-project-secret-api-key-authSkill
- adopting-generated-api-typesSkill
- analyzing-experiment-precompute-canarySkill
- analyzing-experiment-query-performanceSkill
- analyzing-insights-across-teamsSkill
- announcing-behavior-changesSkill
- auditing-llm-gateway-paritySkill
- auditing-warehouse-source-coverageSkill
- authenticating-to-clickhouseSkill
- authoring-ci-workflowsSkill
- autoresolving-pr-conflictsSkill
- building-product-empty-statesSkill
- clickhouse-migrationsSkill
- debugging-ci-failuresSkill
- debugging-local-replaySkill
- debugging-local-task-agent-runsSkill
- debugging-mcp-analyticsSkill
- debugging-signals-pipelineSkill
- debugging-table-access-deniedSkill
- depot-ciSkill
- depot-container-buildsSkill
- depot-github-runnersSkill
- developing-subscriptionsSkill
- django-migrationsSkill
- django-startup-timeSkill
- documenting-warehouse-sourcesSkill
- editing-agents-mdSkill
- establishing-code-ownershipSkill
- extending-hobby-smoke-testsSkill
- extending-personhog-test-harnessSkill
- finding-llm-gateway-migration-candidatesSkill
- fixing-flaky-testsSkill
- gating-production-deploysSkill
- gating-sensitive-actionsSkill
- generating-clickhouse-query-performance-reportsSkill
- hogliSkill
- implementing-mcp-toolsSkill
- implementing-mcp-ui-appsSkill
- implementing-warehouse-sourcesSkill
- improving-drf-endpointsSkill
- improving-mcp-toolsSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
12 rules. About 0 are common, 5 are distinctive, and 7 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 15
Read before writing anything:
- Very specific: line 91
Every sandboxed case runs in a fresh isolated org/team/user copied from the master Hedgebox team, so cases never see each other's state.
- Very specific: line 95
When a case needs data Hedgebox doesn't have (a running experiment, error-tracking issues, a warehouse catalog), declare a seeder as the …
- Distinctive: line 110
Follow this split (and the constants-shared-by-all-three pattern) when seeding any new synthetic catalog.
- Very specific: line 140
Always parse logs via LogParser.cached(...) so a case's log is parsed once, not once per scorer.
- Distinctive: line 146
Read references/running-evals.md when setting up the local Docker provider or the remote Modal provider for the first time.
- Distinctive: line 148
Prefer remote Modal for sandboxed suites when its prerequisites are available.
- Very specific: line 160
Run from a flox shell (or wrap in flox activate -- bash -c "..."): the personhog build needs flox's Rust toolchain, and outside it the …
- Very specific: line 167
Every real eval invocation mirrors its complete stdout and stderr to products/posthog_ai/eval_harness/logs/harness/<timestamp>_<id>.log.
- Very specific: line 170
Start debugging with the transcript path on the last line.
- Distinctive: line 174
Before opening a PR:
- Very specific: line 177
Run your new case alone: hogli evals <suite> --eval <case>.
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
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,
expectedvalues, and scorers must match that taxonomy exactly (signed_up, notsign_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 pathproducts.posthog_ai.evals.<domain>.<module>).products/<product>/evals/— where a product ships eval suites next to its own code. Note the pluralevals/: the singularproducts/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 pathproducts.<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 SandboxedPrivateEval
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 SandboxedPrivateEval(
experiment_name="sandboxed-my-thing-cli",
cases=[SandboxedEvalCase(name="my_case", prompt="...")],
scorers=[],
ctx=ctx,
)- One suite = one Braintrust 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_nameis the Braintrust history key — renaming it resets cross-run comparison. Existing sandboxed suites end in-clibecause the MCP server serves theclisurface.SandboxedPublicEvalsetsno_send_logs=Falseand reports results to Braintrust and PostHog, including available input, output, and expected values.SandboxedPrivateEvalsetsno_send_logs=Trueand uploads results to neither service; local logs are still written. PostHog result uploads followno_send_logsindependently ofOPT_OUT_CAPTURE, which still applies to ordinary SDK and trace clients. See evaluation result reporting.
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, and preflight requires only BRAINTRUST_API_KEY + LLM_GATEWAY_ANTHROPIC_API_KEY.
from products.posthog_ai.eval_harness.config import BaseEvalCase
from products.posthog_ai.eval_harness.harness.context import EvalContext
from products.posthog_ai.eval_harness.harness.requirements import SuiteKind
from products.posthog_ai.eval_harness.one_shot import OneShotPrivateEval
SUITE_KIND = SuiteKind.ONE_SHOT
async def eval_my_generation(ctx: EvalContext) -> None:
async def task(case: BaseEvalCase, task_ctx: EvalContext) -> dict:
return {"answer": ...} # one model invocation, JSON-serializable
await OneShotPrivateEval(
experiment_name="my-generation",
cases=[BaseEvalCase(name="my_case", prompt="...")],
scorers=[...],
task=task,
ctx=ctx,
)- The task function runs once per case under the global one-shot limiter with the standard per-case timeout, and its returned dict is the scorer
output— each one-shot suite defines its own output shape, and its scorers read the keys they know about. The runner backfillsprompt; an optionallast_messagefeeds the local.summary.txt. - Cases are
BaseEvalCase(norepo_fixture/setup); the shared master Hedgebox team is available asctx.demo_data.master_team_idfor read-only queries. A task that needs writes should copy a team viaproducts.posthog_ai.eval_harness.data_setup.copy_demo_data_to_new_teamunderctx.demo_slots. - The sandbox-log scorer helpers (
LogParser,ExitCodeZero, tool-call scorers) don't apply to one-shot outputs — write deterministic scorers against your own output dict, and reuseJudgedScorerfor LLM judges.
Case anatomy
SandboxedEvalCase (products/posthog_ai/eval_harness/config.py) has seven author-facing fields: name, prompt, repo_fixture, expected, metadata, disable_bundled_skills, setup.
namedoubles as the--eval <substr>filter target and the per-case log filename — keep it unique within the suite.expectedis keyed by each scorer's_name(). A scorer reads only its own sub-dict and self-skips (or falls back to default behavior) when its key is absent — that is what lets one scorer list span a suite's cases. Judges take payloads like{"warehouse_answer_correctness": {"expected_answer": "..."}}.--skill-delivery execenables MCP skill distribution and removes native skills for every case in the run.disable_bundled_skills=Trueis an additional per-case override for other delivery-path evals.- Every sandboxed case runs in a fresh isolated org/team/user copied from the master Hedgebox team, so cases never see each other's state. One-shot cases share the master team read-only.
Seeding data: seeders and synthesizers
When a case needs data Hedgebox doesn't have (a running experiment, error-tracking issues, a warehouse catalog), declare a seeder as the case's setup=.
The contract:
- Synchronous:
def seed_x(context: CustomPromptSandboxContext) -> dict[str, Any]. The harness calls it viaasyncio.to_thread— never make it async. - Runs once per case, after the per-case team is provisioned and before the agent prompt is dispatched.
- The returned dict lands in scorer
output["seed"]— this is how scorers learn seeded IDs, flag keys, and expected values. Return everything a scorer will need. - It receives only the context (
team_id,user_id, ...) — there are no per-case parameters. Case-specific configuration means a dedicated seeder function; adding knobs to a shared seeder silently couples every suite that uses it. - A seeder exception marks the case as an infra error (excluded from score averages), not a 0 — so a broken seeder never masquerades as an agent regression.
Shared building blocks live in products/posthog_ai/eval_harness/seeders/ (common.py seeded-name providers and the [lookup] prefix, insight.py noise insights, survey.py flags); domain seeders live next to their suites (data_warehouse/seeder.py, error_tracking/seeders.py, experiments/seeders.py).
Synthesizers are the generation half of a two-part split, used when the seeded catalog is large or synthetic. A synthesizer is a pure, Django-free, deterministic generator that emits frozen dataclasses — no ORM, no I/O — and the seeder translates that catalog into ORM/ClickHouse/S3 rows inside the case's team.
The split exists so generation stays unit-testable and byte-for-byte reproducible (see products/posthog_ai/eval_harness/test/test_warehouse_synthesizer.py) while installation stays an integration concern.
The reference implementation is data_warehouse/synthesizer.py: ~250 realistic noise tables plus seven planted "needles", each targeting one discovery skill, with needle name constants that prompts, expected values, and scorers all import verbatim so they can never drift apart.
Follow this split (and the constants-shared-by-all-three pattern) when seeding any new synthetic catalog.
Writing scorers
Two patterns, each with exactly one implemented branch — never both _run_eval_sync and _run_eval_async (see the Scorers section of harness/AGENTS.md):
Deterministic — subclass Scorer, implement _run_eval_sync only. The base class supplies the async path the engine uses.
from products.posthog_ai.eval_harness.log_parser import LogParser
from products.posthog_ai.eval_harness.scorers.contract import Score, Scorer
class MyCheck(Scorer):
def _name(self) -> str:
return "my_check"
def _run_eval_sync(self, output: dict | None, expected: dict | None = None, **kwargs) -> Score:
if not output or not output.get("raw_log"):
return Score(name=self._name(), score=None, metadata={"reason": "No raw log"})
parser = LogParser.cached(output["raw_log"], initial_prompt=output.get("prompt", "") or "")
...LLM judge — subclass JudgedScorer from products.posthog_ai.eval_harness.scorers, implement _prepare only (plus __init__ with the prompt template). _prepare returns either a Score to short-circuit without an LLM call, or {"output": ..., "expected": ...} template variables (omit "expected" for judges that don't need it). The shared base owns the async branch and maps judge errors to score=0.0.
Rules that apply to both:
- The harness adds
ExitCodeZeroto every experiment. Do not include it in a suite'sscorers; an explicit duplicate is rejected. - Reuse the other generic scorers first:
NoToolCall,RequiredToolCall, andLastToolCallNot(all inproducts.posthog_ai.eval_harness.scorers). - Always parse logs via
LogParser.cached(...)so a case's log is parsed once, not once per scorer. - Count only successful tool calls (
is_error=False) — the agent is free to attempt and fail. score=Nonemeans "skipped": Braintrust omits it from the aggregate entirely.0.0means "failed". Pick deliberately —Nonefor "this check doesn't apply to this case",0.0for "the agent got it wrong" and for broken-judge/missing-input paths that must not silently vanish from the average.
Running
Read references/running-evals.md when setting up the local Docker provider or the remote Modal provider for the first time. It covers shared credentials, provider authentication, first-run commands, concurrency limits, and common setup failures. Prefer remote Modal for sandboxed suites when its prerequisites are available. It runs agent sandboxes in parallel without the local Docker memory ceiling, so multi-case evals finish faster; keep Docker for small smoke tests or when remote access is unavailable.
hogli evals --list # suite ids, no infra
hogli evals eval_my_thing --eval my_case # one case, docker
hogli evals cli_mcp --provider modal # a domain, remote, fully parallel
hogli evals eval_skill_distribution --skill-delivery exec # exec-distributed skills onlyhogli evals:sandboxed is a back-compat alias of hogli evals.
- Run from a flox shell (or wrap in
flox activate -- bash -c "..."): the personhog build needs flox's Rust toolchain, and outside it the preflightcargo builddies on a missingpkg-config/OpenSSL. - Env is loaded automatically (
.envby the harness,.env.local/.env.development/.env.servicesby hogli) and a preflight validates the required variables before any infrastructure boots. --provider docker(default) caps at 4 concurrent sandboxes (16 GB each);--provider modalis unbounded — every case runs at once,--max-sandboxesis the cost knob.- Team cloning and case seeding use one setup slot on ordinary local machines and four when
CODERorCIis set. --trials Nrepeats every case for variance on stochastic behavior;--fail-under <fraction>gates the run's mean score.--skill-delivery bundledis the default native-skill path.--skill-delivery execenables the MCP skill prompt and clears all native skill directories; compare the modes in separate runs because MCP configuration is process-wide.--agent-runtime codexruns the OpenAI Codex harness (default modelgpt-5.5) instead of Claude; it requiresLLM_GATEWAY_OPENAI_API_KEY. The runtime/model land in the Braintrust experiment metadata, so compare scores within one runtime.- Every real eval invocation mirrors its complete stdout and stderr to
products/posthog_ai/eval_harness/logs/harness/<timestamp>_<id>.log. The ending label identifies it as the full run transcript, the last terminal line is its absolute path, andlogs/harness/latest.logpoints to the newest transcript.--listand argument errors do not create one. - The plain-text summary is stable for people and agents: only the overall run says
PASSorFAIL; completed suites, experiments, and cases sayDONE; experiment blocks label scores, URLs, and agent-log directories. EXPORT_EVAL_RESULTS=1additionally appends one structured Braintrust summary per experiment toeval_results.jsonl. It does not replace the always-on transcript.- Start debugging with the transcript path on the last line. Then open the experiment's
Agent logsdirectory for<case>.jsonl(raw agent log),<case>.artifacts.json, and<case>.summary.txt.logs/runs.jsonlindexes historical case runs.
Verification checklist
Before opening a PR:
hogli evals --listshows your suite (this also import-checks every eval module).- Run your new case alone:
hogli evals <suite> --eval <case>. Read the transcript named on the final line, then the case summary and scorer metadata, not just the score. - Unit-test scorer and synthesizer logic where it's cheap — but not inside an
evals/tree: keep suite dirs free ofconftest.pyandpytestimports. Existing homes:products/posthog_ai/eval_harness/test/and product test dirs. - Prompts and
expectedvalues use exact Hedgebox taxonomy names, relative date ranges (-30d,-8w), and shape-based assertions — never absolute counts.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

