CORAL
API Reference

Types

Core type definitions — Task, Score, ScoreBundle, Attempt.

Module: coral.types

These dataclasses are the building blocks of CORAL's data model.

Task

A unit of work for agents to optimize.

from coral.types import Task

task = Task(
    id="my-task",
    name="My Task",
    description="Optimize solution.py",
    metadata={"files": ["solution.py"]},
)

Fields

FieldTypeDescription
idstrUnique identifier
namestrDisplay name
descriptionstrWhat to optimize
metadatadict[str, Any]Additional context

Methods

MethodDescription
to_dict()Serialize to dictionary
from_dict(data)Create from dictionary

Score

A single evaluation score.

from coral.types import Score

score = Score(
    value=0.85,
    name="eval",
    explanation="Runtime: 1.2s",
)

Fields

FieldTypeDescription
valuefloat | str | bool | NoneThe score value
namestrScore identifier
explanationstr | NoneHuman-readable feedback
metadatadict[str, Any]Extra data

Methods

MethodDescription
to_float()Convert value to float (handles bool, str mappings)
to_dict()Serialize to dictionary
from_dict(data)Create from dictionary

String score mappings

When value is a string, to_float() maps it:

StringFloat
"CORRECT", "C"1.0
"INCORRECT", "I"0.0
"PARTIAL", "P"0.5
"NOANSWER", "N"0.0

ScoreBundle

A collection of scores from evaluation.

from coral.types import Score, ScoreBundle

bundle = ScoreBundle(
    scores={"eval": Score(value=0.85, name="eval")},
    aggregated=0.85,
)

Fields

FieldTypeDescription
scoresdict[str, Score]Named scores
aggregatedfloat | NoneOverall score
is_publicboolWhether scores are visible to agents (default: True)

Methods

MethodDescription
get(name)Get a score by name
get_score_value(name, default=0.0)Get float value of a named score
compute_aggregated(weights=None)Compute weighted average of all scores
to_dict()Serialize to dictionary
from_dict(data)Create from dictionary

Attempt

Record of a single optimization attempt by an agent.

from coral.types import Attempt

attempt = Attempt(
    commit_hash="abc1234",
    agent_id="agent-1",
    title="Optimized inner loop",
    score=0.85,
    status="improved",
    parent_hash="def5678",
    timestamp="2025-03-15T10:30:00+00:00",
    feedback="Runtime reduced from 2.3s to 1.1s",
)

Fields

FieldTypeDescription
commit_hashstrGit commit hash
agent_idstrWhich agent made this attempt
titlestrDescription from coral eval -m
scorefloat | NoneEvaluation score (None if crashed/timeout)
statusstrOne of: improved, baseline, regressed, reverted, crashed, timeout
parent_hashstr | NonePrevious commit hash
timestampstrISO 8601 timestamp
feedbackstrGrader feedback

Methods

MethodDescription
to_dict()Serialize to dictionary
from_dict(data)Create from dictionary