Per-Cohort Baselines: Why Aggregate Scores Break With Multiple Agent Personas
If you're running tests across multiple agent personas — customer support, code review, onboarding — a single aggregate baseline will lie to you. Here's how to detect drift at the cohort level before it ships.
← Back to Blogpublish-blog-post-v1| When | Run | Score | Drift | Pass |
|---|---|---|---|---|
| Loading… | ||||
The Aggregate Baseline Problem
Most agent evaluation setups start with a single baseline: run your test suite once, capture the average score, and use that as your quality gate. This works fine when you have one agent persona. It completely falls apart the moment you introduce a second.
Here's why. Say you have two cohorts:
- support-tier-1 — Simple FAQ, sentiment classification. Average score: 87.
- code-review — Multi-file analysis, architecture critique. Average score: 64.
Aggregate across both: 75.5. Now push a code-change that improves code-review by 3 points (64 → 67) but degrades support-tier-1 by 1 point (87 → 86). Your aggregate moves to 76.5 — a 1-point improvement that masks a regression in the exact cohort you care most about for customer-facing quality.
The aggregate score improved. Both individual cohorts regressed. You would have caught this if you tracked per-cohort baselines. You didn't — so you shipped a degraded experience to 100% of your support users.
The same problem hits when you have internal vs external personas, different language markets, or any scenario where your test suites measure fundamentally different behavior. Aggregate baselines hide exactly the signal you need most.
Per-Cohort Baseline Architecture
AssayKit's solution is a cohort-scoped baseline model. Instead of one baseline per suite, you have one baseline per suite per cohort. Each baseline captures a complete snapshot: scores for every scenario in that cohort at the time you pinned it.
The schema is straightforward:
baselines
id uuid
suite_id uuid
cohort_name text -- e.g. "support-tier-1"
snapshot_scores jsonb -- { "scenario_id": score, ... }
run_id uuid -- which run this baseline came from
created_at timestamptz
active boolean -- only one active baseline per cohort
When you pin a baseline, you're saying: "the last run under cohort X is now my quality reference point." Every subsequent run for that cohort gets compared against it, not against some aggregate average.
Pinning a Baseline
After a run completes successfully, pin it as your active baseline for its cohort:
POST /api/suites/{suite_id}/baselines
Authorization: Bearer {api_key}
X-Cohort: support-tier-1
→ 201 Created
{
"id": "baseline_01",
"cohort_name": "support-tier-1",
"scenarios_count": 24,
"run_id": "run_42",
"active": true,
"created_at": "2026-05-22T10:00:00Z"
}
Subsequent runs automatically compare against the active baseline for their cohort. If a run has no matching cohort baseline, it compares against the legacy flat baseline (if one exists), or skips comparison and records no drift.
Listing Baselines by Cohort
Query baselines filtered to a specific cohort:
GET /api/suites/{suite_id}/baselines?cohort=support-tier-1
→ 200 OK
{
"baselines": [
{
"id": "baseline_02",
"cohort_name": "support-tier-1",
"active": true,
"created_at": "2026-05-22T14:30:00Z",
"snapshot_scores": {
"s_smtp_connect": 0.91,
"s_sentiment_classify": 0.88,
"s_kb_retrieval": 0.84
}
},
{
"id": "baseline_01",
"cohort_name": "support-tier-1",
"active": false,
"created_at": "2026-05-21T09:00:00Z",
"snapshot_scores": {
"s_smtp_connect": 0.89,
"s_sentiment_classify": 0.86,
"s_kb_retrieval": 0.82
}
}
]
}
Switch active baselines by pinning a new run. Deactivate the old one. Your quality gate always uses the most recent pinned state for each cohort.
Drift Detection and the Scoring Formula
Each run result gets a drift_score — a measure of how much this run's scores have shifted from the active baseline for that cohort. A drift_score of 0 means perfect match. A drift_score of 1 means complete deviation.
The drift_score is a weighted combination of per-scenario score deltas:
Per-Scenario Score Calculation
For each scenario in the run, the individual score is:
scenario_score =
(0.60 × semantic_similarity) +
(0.25 × lexical_f1) +
(0.15 × length_ratio_penalty)
The length_ratio_penalty normalizes for response verbosity: overly short or overly long responses get penalized relative to the baseline's typical output length. This catches hallucinations that ramble and terse responses that skip steps.
Drift Thresholds
| Drift Score | Classification | Action |
|---|---|---|
0.00 – 0.05 |
Stable | Green — no action needed |
0.05 – 0.15 |
Minor drift | Yellow flag — log, investigate |
0.15 – 0.30 |
Significant drift | Orange — review output, assess |
> 0.30 |
Critical regression | Red — block deployment |
Reading Drift in Run Results
GET /api/runs/{run_id}
→ 200 OK
{
"id": "run_43",
"suite_id": "suite_01",
"cohort_name": "support-tier-1",
"status": "completed",
"baseline_id": "baseline_02",
"drift_score": 0.23,
"scenarios_compared": 24,
"has_regressions": true,
"regressions": [
{
"scenario_id": "s_sentiment_classify",
"baseline_score": 0.88,
"run_score": 0.71,
"delta": -0.17,
"threshold": 0.15
},
{
"scenario_id": "s_kb_retrieval",
"baseline_score": 0.84,
"run_score": 0.69,
"delta": -0.15,
"threshold": 0.15
}
]
}
The has_regressions boolean tells you immediately whether any scenario dropped below the threshold. The regressions array names each one so your CI job can log and block accordingly.
Baseline pinning is intentionally manual. You pin a baseline when you've verified the output quality is acceptable, not automatically on every run. This keeps baselines as quality reference points, not just the most recent run.
CI/CD Integration with GitHub Actions
The full workflow lives in a YAML file you check into the repo. AssayKit provides a copy-paste template that handles suite sync, run execution, and quality gating:
name: Agent Quality Gate
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
assaykit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Sync suite definition
run: |
npx assaykit push --file .assaykit/suite.yaml --api-key ${{ secrets.ASSAYKIT_API_KEY }}
- name: Run evaluation
run: |
npx assaykit run --suite ${{ vars.ASSAYKIT_SUITE_ID }} --json > results.json
- name: Check for regressions
run: |
# Exit 1 if any regressions detected
if grep -q '"has_regressions": true' results.json; then
echo "::error::Regressions detected — see assaykit.polsia.app/app"
exit 1
fi
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: assaykit-results
path: results.json
The npx assaykit run command exits 0 when all scenarios pass, 1 when any fail. It prints regressions to stderr so your CI logs capture the details without noise in the stdout.
Re-pinning After a Valid Run
After you've verified a run's output quality, pin it as the new baseline:
# After manually reviewing results.json and approving
curl -X POST "https://assaykit.polsia.app/api/suites/{SUITE_ID}/baselines" \\
-H "X-API-Key: {API_KEY}" \\
-H "Content-Type: application/json" \\
-d "{\"run_id\": \"run_43\"}"
# Response: baseline pinned, active flag updated
This moves the quality reference forward. Your next CI run will compare against the newly pinned state — so a 1-point degradation on the next commit will actually register as a regression, not be absorbed by the baseline.
Baseline Pinning Workflow
The recommended cadence:
- Check in suite YAML with your agent code. Each agent persona gets its own cohort in the suite definition.
- CI runs on every push, executing all scenarios across all cohorts. Results artifact uploaded.
- Review failed scenarios in the dashboard. If failures are expected (e.g., known regression in a feature branch), proceed with a manual override.
- Pin the baseline after a clean run that you've verified manually. Promote it to active.
- Next run uses the new baseline. Regressions are now measured against your verified quality bar.
Don't pin every run. Pin representative runs after you've confirmed the output quality is acceptable. The baseline is a reference point, not a moving average.
Real API Examples
Creating a Suite with Cohorts
POST /api/suites
X-API-Key: ak_live_...
{
"name": "Support Quality Suite",
"cohort": "support-tier-1"
}
→ 201 Created
{
"id": "suite_01",
"name": "Support Quality Suite",
"cohort": "support-tier-1",
"created_at": "2026-05-22T10:00:00Z"
}
Importing a Suite from YAML
POST /api/suites/import
Content-Type: text/yaml
X-API-Key: ak_live_...
cohort: code-review
name: Code Review Suite
scenarios:
- id: cr_arch_check
prompt: "Review the following code for architectural issues..."
expected: "Clean architecture with proper separation..."
target_url: "https://api.example.com/analyze"
threshold: 0.75
- id: cr_security_scan
prompt: "Identify security vulnerabilities in..."
expected: "No critical issues found..."
target_url: "https://api.example.com/security"
threshold: 0.80
→ 201 Created
{
"id": "suite_05",
"scenarios_count": 2,
"cohort": "code-review"
}
Running an Evaluation
POST /api/runs
X-API-Key: ak_live_...
X-Cohort: code-review
{
"suite_id": "suite_05"
}
→ 202 Accepted
{
"run_id": "run_44",
"cohort_name": "code-review",
"status": "pending"
}
Poll GET /api/runs/{run_id}/progress for SSE-based progress streaming, or poll GET /api/runs/{run_id} for the final result object with full drift analysis.
Why This Matters for Distribution
Self-hosting the blog at assaykit.polsia.app/blog isn't just about SEO. It's about owning the complete customer journey: from first-touch blog post to sign-up to API key to evaluating your agents in CI. Every step stays on your domain.
When you link to dev.to from Show HN or Reddit, you're sending traffic to a third-party domain that competes with your brand in the browser's URL bar. When the link is assaykit.polsia.app/blog, the visitor is already on your property — they sign up at the same domain, not a different one.
The per-cohort baseline system is the technical foundation that makes this worth distributing. It's not just "we have a blog." It's a technical deep-dive that demonstrates exactly how the product handles the multi-cohort regression problem that everyone running multiple agent personas faces. That's what earns the HN upvote.
Evaluate your agents against cohort-specific baselines
Define scenarios per persona, pin baselines after verified runs, and gate your CI on per-cohort drift — not aggregate averages.
Get your API key →Free tier. No credit card. Runs in under 60 seconds.