Skip to content
SkynetDocs
Pages

Concepts

Metrics and scorers

Write the score function that tells the engine what better means.

The scorer tells Skynet how good one version of your repository is. It is a Python function in scorer.py. Every engine calls the same function. This page gives the contract, the return value, and examples.

The contract

def score(repo_path, case, output=None):
    ...
    return {"score": score_value, "feedback": "..."}
ArgumentWhat it holds
repo_pathA folder that holds only your metric files. It holds no other repository file and no version code
caseA dict. case["input"] holds the input fields. case["expected"] holds the expected value, or None
outputWhat the [run] entry returned for the case, or None when the file has no [run]

The ascent.toml file of the repository must have a [run] section or a [target.<name>] stage. The [run] entry runs one version on one case, in its own sandbox box. Skynet refuses a file with neither, because every version would get the same score.

  • A function entry, for example entry = "serve.py:serve", gets case["input"] as its argument. output is its return value.
  • A command entry, for example entry = ["python", "run_tests.py"], reads {"input": ...} from the JSON file at the path in ASCENT_INPUT. It writes {"output": ...} to the path in ASCENT_OUTPUT. output is the value under "output". What the command prints goes to the logs only.

The scorer runs in a separate sandbox box. That box holds only your metric files. The scorer cannot import or run the code of the version. It sees the version only through output, or through call() to a [target.<name>] stage. Import call with from openascent import call. Read How optimization works.

The return value

score returns one object:

{
    "score": 0.78,
    "feedback": "Misses short names.",
    "scores": {
        "precision": {"score": 0.90},
        "recall": {"score": 0.69, "feedback": "Misses names under 4 letters."},
    },
}
  • "score" is required. It is a finite number. Only this score ranks the versions.
  • "feedback" is optional text. It is recommended, because GEPA and Auto learn from it. Without feedback, the engines see only the scores, and the run log says so one time.
  • "scores" is optional. It maps names to named scores. Each named score is an object with its own "score" and an optional "feedback". Every engine uses each named score as its own objective.

Any other form or key is an error. The check shows the wrong part and the valid form.

Return valueValid
{"score": 0.8, "feedback": "Close. Missing the date."}Yes
{"score": 0.8}Yes. There is no feedback.
{"score": 1.0, "scores": {"format": {"score": 1.0}}}Yes
0.8No. The value is not an object.
(0.8, "Close. Missing the date.")No. The value is not an object.
{"score": "0.8"}No. The score is a string.
{"score": 0.8, "scores": {"format": 1.0}}No. A named score must be an object.
{"score": 0.8, "feedbak": "OK"}No. The key feedbak is unknown.

Write useful feedback

GEPA and Auto read the feedback text to write the next version. Say what is wrong and what a correct output looks like.

Weak feedbackUseful feedback
"Wrong.""Expected 'billing', got 'other'. The message mentions a charge."
"Bad format.""The output is not valid JSON. It has a trailing comma after the last field."

The coding agent never sees your scorer source, the expected values or the run secrets. It sees only the scores and the feedback text.

Examples

Exact match

version = 1

[run]
entry = "serve.py:serve"

case["expected"] is a dict keyed by the name of your Output column. Read Datasets and splits.

Run the tests of the repository

The [run] entry runs the tests. pytest exits with a nonzero code when a test fails, and a nonzero exit code fails the case. Thus the wrapper run_tests.py writes the result to ASCENT_OUTPUT and exits 0. The scorer reads that result.

version = 1

[run]
entry = ["python", "run_tests.py"]
timeout = 300

When the [run] entry fails on a case, that case has no score. If the entry cannot start, times out or a signal stops it, or if a function entry raises or exits before it returns, the feedback is Run failed: …, and Skynet does not call the scorer. A command entry also fails when it exits with a nonzero code or writes no valid output file. A version with such a case has no score. It cannot be the best version, reaches no [outcome] target and opens no pull request. If a failure must count as a number, catch the failure in your program, write an output, and let the scorer score it. Read the repository rules.

Model as judge

The scorer can call a model. Import llm from the openascent helper module. The call goes through Skynet's model gateway to the scorer model of the run.

version = 1

[run]
entry = "serve.py:serve"

The scorer can also use any OpenAI-compatible client with the OPENAI_BASE_URL, ASCENT_MODEL_KEY and ASCENT_MODEL environment variables. The gateway accepts only the scorer model of the run.

Model calls and secrets

  • Calls on Skynet's keys are metered against the run budget. With your own key (BYOK), the call goes to your provider key, with no Skynet model fee. Read Billing.
  • The scorer gets no run secrets as environment variables. A secret reaches the scorer only through a [services.<name>] table that [metric] services lists, or through a server in the [metric] mcp file. Write the secret in the table's headers as ${NAME}. The scorer sends its requests to the URL in ASCENT_SERVICE_<NAME>_URL. Skynet adds the secret outside the sandbox.
  • Skynet hides secret values in the scorer output and in the logs.

Limits

ItemValue
Scorer timeout60 seconds by default, at most 600