Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:AISecurityLab Hackagent Judging Contracts

From Leeroopedia
Knowledge Sources
Domains Contracts, Evaluation
Last Updated 2026-10-29 00:00 GMT

Overview

Concrete frozen pydantic models defining the judging contract: goals, samples to judge, individual judge votes, combined verdicts, and labelled samples for calibration, provided by the HackAgent core contracts package.

Description

The module defines: Goal (one attack goal with index, labels, extra), Sample (one exchange to judge: goal, prompt, response, tool_calls), JudgeVote (one judge's score with abstention support), Verdict (combined judgement with success, normalized 0-10 score, individual votes), and LabelledSample (sample + human label for calibration). JudgeVote.abstained is True when the judge gave no usable answer. Verdict.error is set when every judge abstained.

Usage

  • Judges: Judge models return JudgeVote; panels combine them into Verdict.
  • Calibration: LabelledSample is the ground truth for panel audit.
  • Attacks: Attacks use Verdict.success and Verdict.score to decide search.

Code Reference

Source Location

Signature

class Goal(BaseModel):
    text: str
    index: int = Field(ge=0)
    labels: Dict[str, str] = {}
    extra: Dict[str, Any] = {}

class Sample(BaseModel):
    goal: str
    prompt: str = ""
    response: str = ""
    tool_calls: List[ToolCall] = []

class JudgeVote(BaseModel):
    judge: str
    score: Optional[float] = None
    success: Optional[bool] = None
    explanation: str = ""
    error: Optional[str] = None

    @property
    def abstained(self) -> bool: ...

NORMALIZED_SCORE_MAX = 10.0

class Verdict(BaseModel):
    success: bool
    score: float = Field(ge=0.0, le=NORMALIZED_SCORE_MAX)
    votes: List[JudgeVote] = []
    explanation: str = ""
    error: Optional[str] = None

class LabelledSample(BaseModel):
    sample: Sample
    label: bool
    id: str = ""

Import

from hackagent.core.contracts import (
    Goal, Sample, JudgeVote, Verdict, LabelledSample, NORMALIZED_SCORE_MAX,
)

I/O Contract

Outputs

Name Type Description
Verdict BaseModel Combined judgement (success, score 0-10, votes)
JudgeVote.abstained bool True when judge gave no usable answer
LabelledSample BaseModel Sample + human label for calibration

Usage Examples

Build a Verdict

from hackagent.core.contracts import Verdict, JudgeVote

verdict = Verdict(
    success=True,
    score=8.5,
    votes=[JudgeVote(judge="gpt-4o", score=8.5, success=True, explanation="...")],
)

Related Pages

Implements Principle

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment