Defensive verifier framework and helpers for Harbor evaluations
Project description
Graded
Graded is a library to make computing rewards simple, defensive, and structured for agent evaluations, particularly within Harbor environments. It provides tools to declare structured grading criteria, execute LLM judges with automatic tracing, and manage evaluation artifacts.
Installation
pip install graded
Or using uv:
uv pip install graded
Quick Start
Create an evaluation script (e.g. verify.py) to grade a task workspace:
from pathlib import Path
from graded import Evaluator
# Initialize the evaluator
ev = Evaluator(
workspace="/workspace",
output_path="/logs/verifier/reward.json",
auto_save_artifacts=True
)
# 1. Declare a standard criterion
@ev.criterion(name="has_output_file", weight=1.0)
def check_output(workspace: Path) -> bool:
return ev.file_exists("output.txt")
# 2. Declare a fatal criterion (short-circuits final score to 0.0 if failed)
@ev.criterion(name="no_syntax_errors", weight=2.0, fatal=True)
def check_syntax(workspace: Path) -> bool:
return True
# 3. Declare a fractional scoring criterion
@ev.criterion(name="test_pass_rate", weight=3.0)
def check_tests(workspace: Path) -> float:
return 0.8 # Returns a score between 0.0 and 1.0
if __name__ == "__main__":
ev.run()
Core Features
1. Criteria Declarations (@ev.criterion)
Define check functions using the @ev.criterion decorator.
name: Unique identifier for the criterion.weight: Relative weight of the score in the final weighted average calculation.fatal: IfTrue, any score of0.0orFalseimmediately short-circuits the final score to0.0.- Return Value: Must return a
bool,int, orfloat.
2. LLM Judge with Automatic Tracing
Integrate with instructor to run structured, schema-validated LLM grading prompts. Prompt, parameters, response schema, and LLM responses are automatically logged to traces.json.
from pydantic import BaseModel, Field
class Rubric(BaseModel):
score: float = Field(description="Score between 0.0 and 1.0 based on correctness.")
reasoning: str = Field(description="Detailed reasoning for the score.")
# In your criterion:
result = ev.llm_judge(
model="google/gemini-3.5-flash",
response_model=Rubric,
system="You are a strict code correctness evaluator.",
prompt="Compare the student's solution in code.py with the requirements...",
)
# The return value is fully type-hinted as an instance of your Rubric class
print(result.score)
print(result.reasoning)
3. File & Artifact Management
Access files and copy evaluation artifacts to the logs directory safely:
ev.read_file(filename): Reads content as a string and auto-saves a copy to artifacts.ev.load_json(filename): Parses JSON file content and auto-saves a copy to artifacts.ev.save_file(filename, content): Saves arbitrary text to the artifacts directory.ev.save_dir(dirname): Copies an entire directory from the workspace to the artifacts directory.ev.load_trajectory(path): Loads and parses an agent's ATIFtrajectory.jsonfile.
Outputs
When ev.run() completes, the following files are written to the directory containing your configured output_path:
reward.json: Flat JSON dictionary containing the final calculatedrewardand individual scores.reward.txt: Text file containing just the final reward float value.traces.json: List of structured LLM calls made viaev.llm_judge.metadata.json: Optional metadata.artifacts/: Subfolder containing copy-back files preserved during the evaluation run.
Agent Skills
You can install the graded-verifier skill to teach your AI coding agents (such as Cursor or Claude Code) how to write robust graded verifiers:
npx skills add <github-username>/eval-helpers/.agents/skills/graded-verifier
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file graded-1.0.4.tar.gz.
File metadata
- Download URL: graded-1.0.4.tar.gz
- Upload date:
- Size: 11.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e71d76c238324f1ae1fcbbe1cf9b3d387434a17c902972dc715d9720f71fd278
|
|
| MD5 |
d33bb20679a124ccd2d2ad2f5856e109
|
|
| BLAKE2b-256 |
0d2f12cd48431e7035b2b6c08ee0975e2b71f938389d8a3dccabd27bc64c10c0
|
Provenance
The following attestation bundles were made for graded-1.0.4.tar.gz:
Publisher:
ci.yml on ivanleomk/graded
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
graded-1.0.4.tar.gz -
Subject digest:
e71d76c238324f1ae1fcbbe1cf9b3d387434a17c902972dc715d9720f71fd278 - Sigstore transparency entry: 1787579562
- Sigstore integration time:
-
Permalink:
ivanleomk/graded@36b5bda99be826f84959888eddc678d51160db9a -
Branch / Tag:
refs/tags/v1.0.4 - Owner: https://github.com/ivanleomk
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@36b5bda99be826f84959888eddc678d51160db9a -
Trigger Event:
push
-
Statement type:
File details
Details for the file graded-1.0.4-py3-none-any.whl.
File metadata
- Download URL: graded-1.0.4-py3-none-any.whl
- Upload date:
- Size: 8.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d2336ec3b5e7ff0720979caf484a57e10062e7782b22d1dbde769b868f8b0937
|
|
| MD5 |
4ea499c720c26a5f41df751ab3413b92
|
|
| BLAKE2b-256 |
228d52ded943c52b8e2bce410edd20d104e2b5eaeb8ae8a01e13ed83fa594359
|
Provenance
The following attestation bundles were made for graded-1.0.4-py3-none-any.whl:
Publisher:
ci.yml on ivanleomk/graded
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
graded-1.0.4-py3-none-any.whl -
Subject digest:
d2336ec3b5e7ff0720979caf484a57e10062e7782b22d1dbde769b868f8b0937 - Sigstore transparency entry: 1787580000
- Sigstore integration time:
-
Permalink:
ivanleomk/graded@36b5bda99be826f84959888eddc678d51160db9a -
Branch / Tag:
refs/tags/v1.0.4 - Owner: https://github.com/ivanleomk
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@36b5bda99be826f84959888eddc678d51160db9a -
Trigger Event:
push
-
Statement type: