guide
LLM-as-judge evals
From “traces are landing” to “every hour, an LLM judge scores my new traffic and I get a webhook when quality drops.” Judge calls run with your own provider key, stored encrypted and used only for the judging you configure — AgentSentri makes no other outbound LLM calls and does not phone-home for judging.
Two principles
- Your key, your models
- Judge calls use a provider connection you configure (Anthropic or any OpenAI-compatible endpoint). The key is stored encrypted, never returned by any API, and used only for the judging you ask for — no competitor phone-home.
- Bounded by design
- Runs are capped per execution, schedules never backfill history, lookback is bounded, and a broken connection pauses the schedule visibly instead of failing silently.
The walkthrough
1.Connect a judge model (once per project)
the Evals tab → LLM connection, or via the API. provider is anthropic or openai-compatible (the latter takes a baseUrl, which must be an https address on a public host: private, loopback and metadata targets are rejected). Reads return a masked key hint only. Auth everywhere: Bearer project API key.
curl -X PUT $HOST/api/public/llm-connection \ -H "Authorization: Bearer $AGENTSENTRI_SECRET_KEY" \ -H "Content-Type: application/json" \ -d '{"provider": "anthropic", "defaultModel": "claude-sonnet-5", "apiKey": "sk-ant-..."}'2.Define an evaluator
A judge prompt template plus the score it writes. Templates bind {{input}}, {{output}}, {{metadata}}, {{expected_output}}, and {{trace_name}} per target. Verdicts land as scores with an LLM-judge badge — visible everywhere manual scores are. Pin defaultModel on the connection; first-class version metadata on each score is planned in Story D.
sentri.create_evaluator( name="helpfulness", template=( "Rate how helpful this answer is from 0 to 1.\n" "Question: {{input}}\nAnswer: {{output}}\n" 'Reply as JSON: {"verdict": <number>, "comment": "<why>"}' ), score_name="helpfulness", data_type="NUMERIC", min_value=0, max_value=1, )3.Run it on demand
Judge a selection — recent traffic, named traces/observations (traceIds / observationIds), or a whole experiment. The run executes inside the request today (no background job queue) and returns finished with per-item outcomes; selections above the per-run cap are rejected up front.
curl -X POST $HOST/api/public/eval-runs \ -H "Authorization: Bearer $AGENTSENTRI_SECRET_KEY" \ -H "Content-Type: application/json" \ -d '{"evaluatorId": "EVALUATOR_ID", "traceIds": ["TRACE_ID"]}' run = sentri.trigger_eval_run( evaluator["id"], recent_hours=24, recent_limit=50 ) print(run["run"]["scoredCount"], "scored")4.Schedule it — continuous quality monitoring
A schedule judges NEW traces on a cadence. The watermark starts at creation, so enabling one never backfills history (use on-demand runs for that); each tick takes at most max_items_per_run of the newest unjudged traces; failed items are recorded, not retried; a missing connection pauses visibly. This is not async batch over a filter/queue slice — that is Story D.
sentri.create_eval_schedule( evaluator_id=evaluator["id"], cadence="hourly", # or "daily" max_items_per_run=25, # hard cap per execution )5.Alert when quality drops
Add an alert rule on metric Avg score (score name helpfulness, e.g. < 0.6 over 24h). Optional channels: email recipients (needs SMTP_URL) and HTTPS webhooks signed with HMAC-SHA256 in the X-AgentSentri-Signature header. Deliveries dedupe per rule (default 6h) and every attempt is listed on the dashboard.
// webhook receiver: verify the signature over the RAW body import { createHmac, timingSafeEqual } from "node:crypto"; const expected = Buffer.from( createHmac("sha256", secret).update(rawBody).digest("hex") ); const received = Buffer.from(headerValue); // timingSafeEqual THROWS on length mismatch — guard first. const ok = expected.length === received.length && timingSafeEqual(expected, received);
Controlling judge spend
| Per-run caps | max_items_per_run bounds every execution — hourly × 25 is at most 600 judge calls/day per schedule. |
| Activation watermark | Enabling a schedule never judges history; re-enabling skips the disabled gap. |
| Metered like any key | Judge token/cost usage flows into key monitoring — a runaway judge trips your own cost-spike alerts. |
| Hard stops | Delete the schedule or disable the LLM connection; everything pauses visibly. |
Human override (shipped)
| Judge badge | Eval runs write scores with source llm_judge. |
| Human override | Manual POST/PATCH for the same name+target sets source to manual — LD-6 override path today. |
| Scores guide | Full create/upsert/PATCH/DELETE details live in the manual scores guide. |
LLM-as-judge hooks (Story D)
Versioned model+prompt metadata on judge writes, on-demand runs (including annotation-queue slices), and optional async batch via the pg-boss job system. Online-on-ingest is opt-in per evaluator (default OFF).
| On-demand hooks | POST /api/public/eval-runs — trace/observation/recent/experiment/queue; scores carry judgeModel + promptVersion. |
| Optional batch | POST /api/public/eval-runs/batch — filter or annotation-queue slice via pg-boss (not route timers). |
| Versioned model + prompt | Evaluators store promptVersion; runs and scores persist model + prompt version + score config. |
| Human override | Manual POST/PATCH clears the LLM-judge badge and judge metadata. |
| Online-on-ingest | Opt-in per evaluator (runOnIngest, default OFF). Async enqueue after ingest via pg-boss; never LLM-inline on the request path. |
Troubleshooting
| Paused — no LLM connection | Reconnect or re-enable the connection; the schedule resumes next tick without judging the gap. |
| Items skipped | Template variables didn't resolve — check traces carry input/output where the template expects them. |
| “no JSON object” verdict errors | The judge ignored the format instruction. Tighten the template; smaller models need blunter phrasing. |
| Run item: “Provider returned HTTP 401 (invalid_api_key)” | The provider rejected the call. The status and the provider's error code are shown; its own error text is not, since it can carry a response body or part of your key. Check the key and model. |
| Run item: “Provider request timed out” | The provider took longer than the call deadline (60 seconds by default, response body included). Try a smaller or faster model, or a shorter prompt. |
| Run item: “LLM base URL rejected” | An openai-compatible base URL must be https and resolve to a public address. A name that doesn't resolve and one that resolves privately read the same, on purpose. |
| Email deliveries skipped | SMTP_URL isn't set. Configure it — skips don't consume the dedupe window, so the next breach sends. |
| Webhook failed: SSRF guard | Alert webhooks must resolve to public HTTPS endpoints — private, loopback, and metadata addresses are rejected. |