Judges
A judge looks at one case's output and gives it a score between 0 and 1. Judges are your own code: subclass Judge, read case.run_results, and return a Score.
from eac import Case, Judge, Score
class FoundIssueJudge(Judge):
"""Passes if the agent named the issue the seed created for the expected
error, or no issue when there's nothing to find."""
name = "found_issue"
def judge(
self,
case: Case,
*,
agent_trace: Any = None,
) -> Score | None:
error = case.expected_output["error"]
expected = case.seed_results["incident"]["issues"][error] if error else None
actual = case.run_results.get("issue")
if actual == expected:
return Score.passed(self.name)
return Score.failed(self.name, f"expected {expected}, actual {actual}")case.seed_results holds what the case's seeds set up, by name, the same as the runner saw. This judge needs them because the issue's ID only exists once the seed has created it.
If the judge doesn't apply to a case, return None. A score of None is saved but doesn't count toward pass or fail. If a judge throws, its score records the error instead, and the case errors.
Reading agent traces
Some judges need more than the final output, like the agent's full conversation or the tools it called. Implement get_agent_trace() to fetch it:
from eac import AgentRun, AgentTrace, Case, Judge, LLMMetrics, Score
class TriageLLMJudge(Judge):
name = "triage_llm_judge"
def get_agent_trace(self, run: AgentRun) -> AgentTrace | None:
conversation = load_conversation(run.conversation_id)
if conversation is None:
return None
return AgentTrace(
trace=conversation["messages"],
metrics=LLMMetrics(**conversation["usage"]),
)eac fetches the trace once per case and hands it to every judge as agent_trace. It's saved with the run, so re-judging doesn't fetch it again. Since it doesn't depend on the case's expected output, a judge like this works on online evals too.
LLM judges
An LLM judge asks a model to grade the trace. This one asks two true-or-false questions, and each is worth half the score:
def judge(
self,
case: Case,
*,
agent_trace: Any = None,
) -> Score | None:
if agent_trace is None:
return None
with client() as openrouter:
result = openrouter.chat.send(
model=self.args.get("model", JUDGE_MODEL),
messages=[
{"role": "system", "content": self.PROMPT},
{"role": "user", "content": json.dumps(agent_trace)},
],
response_format={"type": "json_object"},
temperature=0,
)
judge = json.loads(result.choices[0].message.content)
grounded = judge.get("grounded") is True
fix_works = judge.get("fix_works") is True
return Score(
name=self.name,
score=(int(grounded) + int(fix_works)) / 2,
explanation=judge.get("explanation"),
metadata={"grounded": grounded, "fix_works": fix_works},
llm_judge_metrics=LLMMetrics(**usage_of(result)),
)metadata is saved with the score, so you can see which question failed. llm_judge_metrics records what judging cost, kept apart from what the agent cost.
Settings per run
Need settings that change per run, like the judge's model? Pass them with --judge-args, keyed by the judge's name:
eac offline run --judge-args '{"triage_llm_judge": {"model": "openai/gpt-6.2-sol"}}'The judge gets its entry as self.args, a plain dict, or {} without one. eac doesn't check what's inside, so check anything you rely on. It does reject a name that no judge in the run has, to catch typos.
To try new settings without running the cases again, re-judge the last run with them: eac offline judge --judge-args '...'.