SWE Scoring
This document describes the current SWE scoring logic implemented in mcpplatform/app/api/routes/scoring.py.
This document describes the current SWE scoring logic implemented in
mcp_platform/app/api/routes/scoring.py.
Task types and scoring paths
There are three benchmark task types:
swebench_verifiedswe_explorer_editswe_explorer_explore
Scoring is split into two paths:
swebench_verifiedandswe_explorer_edituse the same SWE task-score path:compute_swe_task_score,build_swe_miner_scores, andbuild_swe_miner_total_score.swe_explorer_exploreuses a separate explore-quality path:compute_explore_task_scoreandcompute_explore_miner_total_score.
Token counting
Token totals are computed from a weighted token-type breakdown.
Let:
T_ibe non-cached input tokens,T_cbe cached input tokens,T_obe output tokens.
Default weights:
| Token type | Weight |
|---|---|
| Input, non-cached | 1.0 |
| Cached input | 0.1 |
| Output | 3.0 |
Current behavior of compute_weighted_tokens:
input_tokensandoutput_tokensare required.- Missing
cached_input_tokensis treated as0. - The function returns
Noneif a required value is missing or any supplied token count is negative.
SWE path
This path is used for:
swebench_verifiedswe_explorer_edit
Per-task scoring inputs
For each task:
xis the number of resolved baseline runs. Only resolved baselines count.yis the number of resolved miner runs.T_Bis the average weighted token count across resolved baseline runs.T_Ais the average weighted token count across miner runs with valid weighted token counts.
Compression ratio
The compression-ratio term is the natural logarithm of the baseline-to-miner
weighted-token ratio, clamped to [-2, 2]:
If the token inputs are invalid:
Penalty threshold
Per-task score
The per-task score is calculated by compute_swe_task_score.
| Constant | Value |
|---|---|
| Bonus cap | 3.0 |
| Penalty floor | -4.0 |
| Penalty ceiling | -2.0 |
Hard tasks
A task is hard when x <= 1.
Excluded task
If y == 0:
score=Nonepool=excluded
The task does not contribute to the miner aggregate.
Maintain zone
If x == 1 and y == 1:
Bonus zone
All other non-excluded hard tasks use:
Hard tasks are assigned to pool=hard_boost.
Their hard-boost contribution is:
Only the positive part of the hard-task score contributes to the boost.
Standard tasks
A task is standard when x >= 2.
Penalty zone
If y < t:
Maintain zone
If t <= y <= x:
Bonus zone
If y > x:
Standard tasks are assigned to pool=main.
SWE miner aggregation
Miner-level aggregation is performed by build_swe_miner_scores.
Main score
For every task in pool=main, the aggregation weight is:
The main_score is the weighted average of main-task scores:
If the miner has no tasks in pool=main:
Hard boost
The hard_boost is the sum of positive hard-task contributions divided by the
number of scored main and hard tasks:
Where:
N_Mis the number of tasks inpool=main.N_His the number of tasks inpool=hard_boost.h_iis the hard-boost contribution of hard taski.
If there are no hard-boost contributions:
Raw miner total
Final normalized SWE score
Final normalization is performed by build_swe_miner_total_score.
First, the raw total is clamped to [-4, 3]:
The clamped value is then linearly normalized from [-4, 3] to [-1, 1]:
Equivalently:
This normalized value is consumed by downstream category and leaderboard scoring.
Explore path
This path is used for:
swe_explorer_explore
Explore scoring has a different objective: preserve exploration quality while reducing weighted token usage.
Per-task explore score
The per-task score is calculated by compute_explore_task_score.
Exploration quality
Let:
fbe the hit-file rate,nbe the noise-file rate.
Quality is:
The quality margin is:
Where:
q_Ais miner quality.q_Bis baseline quality.
The default quality threshold is:
Hard quality floor
If m <= -delta, the task receives the hard-floor score:
Quality-aware token score
Otherwise, a smooth quality gate g in [0, 1] is computed:
where:
This gate is used asymmetrically:
- for token savings, it unlocks reward as quality improves;
- for token overspend, it softens the penalty as quality improves.
The token term is:
Let:
The final per-task explore score is:
This means:
- when the miner saves tokens, better quality is required to unlock the reward;
- when the miner uses more tokens than baseline, better quality reduces the size of the penalty, but does not remove it entirely;
- once the miner quality margin drops to
m <= -delta, the hard floor still applies.
Explore miner aggregation
Miner-level explore aggregation is performed by
compute_explore_miner_total_score.
The aggregate:
- starts from the mean of the per-task explore scores,
- applies the hard floor only if the miner is worse than baseline on both average quality margin and total weighted token usage,
- otherwise keeps the per-task mean unchanged,
- normalizes the resulting score to
[-1, 1].
docs/miner/scoring.md