Before the Rollout Ends: Early Terminal Reward Prediction for Long-horizon Coding Agents
Organizations: University of Washington · Independent Researcher · HKUST
Abstract
Long-horizon coding agents receive verifiable rewards only after completing expensive sequences of tool calls. This increases inference cost, amplifies early wrong hypotheses, and can lead to sparse terminal reward and unstable training. We introduce Contextual Early Reward (CER), which predicts terminal reward through behavioral evidence in a trajectory prefix. CER synthesizes adaptive rubrics specific to the current task and stage through experiences summarized from related historical tasks. In test-time scaling on SWE-bench Verified, CER improves RM@8 over the strongest baseline by 4.2 percentage points (pp) on Nemotron 3 Ultra and 2.0 pp on Qwen 3.6 27B; on Nemotron, it takes only 15.3% tokens to match the best baseline performance. In RL training experiments, CER exceeds full-rollout TMax by 1.9 pp while using 52.7% fewer online policy-and-judge tokens. Together, CER provides an interpretable, efficient, and dense evaluation method for long-horizon coding agents.
Figures & tables
| Nemotron 3 Ultra | Qwen 3.6 27B | |||||||
| Method | RM@4 | RM@8 | Top-tie | Tok./Ins. | RM@4 | RM@8 | Top-tie | Tok./Ins. |
| % | % | % | M | % | % | % | M | |
| SWE-RM | 62.2 | 61.6 | 17.8 | 25.67 | 66.2 | 67.6 | 18.0 | 5.27 |
| OpenHands Critic@20 | 57.6 | 57.8 | 3.2 | 3.91 | 64.4 | 64.2 | 1.6 | 1.57 |
| OpenHands Critic@40 | 60.4 | 58.4 | 2.8 | 5.70 | 65.0 | 64.0 | 0.6 | 2.99 |
| OpenHands Critic@60 | 61.8 | 60.4 | 2.4 | 7.93 | 65.4 | 63.4 | 1.2 | 4.07 |
| Method | Fold 0 | Fold 1 | Fold 2 | Mean |
|---|---|---|---|---|
| Qwen 3.5 9B | ||||
| TMax | ||||
| TMax-40 | ||||
| CER |
| CER | @20 | @40 | @60 | @80 |
|---|---|---|---|---|
| Nemotron | 63% | 68% | 68% | 69% |
| w/ Qwen exp. | 64% | 69% | 70% | 70% |
| Qwen | 73% | 75% | 76% | 75% |
| w/ Nemotron exp. | 67% | 68% | 69% | 70% |
Appendix figures & tables11 assets
Supplementary material from the paper’s appendix.
Appendix
| Fold | Train (250) | Validation (50) | Test (200) |
|---|---|---|---|
| 0 | django/django (103), matplotlib/matplotlib (27), psf/requests (4), pydata/xarray (16), sphinx-doc/sphinx (36), sympy/sympy (64) | django/django (13), matplotlib/matplotlib (7), pallets/flask (1), psf/requests (4), pydata/xarray (6), sphinx-doc/sphinx (8), sympy/sympy (11) | astropy/astropy (22), django/django (115), mwaskom/seaborn (2), pylint-dev/pylint (10), pytest-dev/pytest (19), scikit-learn/scikit-learn (32) |
| 1 | django/django (102), pydata/xarray (16), pylint-dev/pylint (6), scikit-learn/scikit-learn (25), sphinx-doc/sphinx (36), sympy/sympy (65) | django/django (13), mwaskom/seaborn (2), pydata/xarray (6), pylint-dev/pylint (4), scikit-learn/scikit-learn (7), sphinx-doc/sphinx (8), sympy/sympy (10) | astropy/astropy (22), django/django (116), matplotlib/matplotlib (34), pallets/flask (1), psf/requests (8), pytest-dev/pytest (19) |
| 2 | astropy/astropy (14), django/django (207), matplotlib/matplotlib (24), pylint-dev/pylint (5) | astropy/astropy (8), django/django (24), matplotlib/matplotlib (10), mwaskom/seaborn (2), pallets/flask (1), pylint-dev/pylint (5) | psf/requests (8), pydata/xarray (22), pytest-dev/pytest (19), scikit-learn/scikit-learn (32), sphinx-doc/sphinx (44), sympy/sympy (75) |
| Component | Hyperparameter | Value |
| Rollout | Samples per task group | 8 |
| Samples per global batch | 128 | |
| Sampling temperature / top- | 1.0 / 0.95 | |
| Context / Completion maximum length | 65,536 / 20,480 tokens | |
| Rollout step limit | 250 (TMax and TMax-40); 40 (CER) | |
| Dynamic sampling | true |
| Step Budget | 20 | 40 | 60 | 80 | |
|---|---|---|---|---|---|
| Subset Size | 453/386 | 313/98 | 188/17 | 110/4 | |
| Nemotron 3 Ultra | SWE-RM | 59.4% | 52.4% | 44.7% | 40.9% |
| Adaptive Rubrics | 61.1% | 54.0% | 48.4% | 43.6% | |
| CER | 62.9% | 56.2% | 50.5% | 45.5% | |
| Qwen 3.6 27B | SWE-RM | 63.0% | 44.9% | - | - |
| Adaptive Rubrics | 64.8% | 46.9% | - | - |
| Model | @20 | @40 | @60 | @80 |
|---|---|---|---|---|
| Nemotron 3 Ultra | 55.0% | 55.7% | 55.9% | 58.8% |
| Qwen 3.6 27B | 50.7% | 51.4% | 55.4% | 60.4% |
| Method | @20 | @40 | @60 | @80 | Avg. |
| Nemotron 3 Ultra | |||||
| CER | 63 | 68 | 68 | 69 | 67.0 |
| w/o tie-breaking | 63 | 67 | 68 | 68 | 66.5 |
| w/o regression | - | 67 | 66 | 66 | 65.5 |
| w/o beam parent | - | 66 | 65 | 65 | 64.8 |
| w/o experience | 65 | 67 | 63 | 68 | 65.8 |
| Primary category | Weighted percent | Example |
|---|---|---|
| Pre-edit reproduction and runnable testbed | 0.65% | For Django-13033, the criterion requires executed evidence that exposes the erroneous SQL join and ordering direction and contrasts it with semantically informative control orderings. |
| Root-cause localization and causal diagnosis | 16.82% | For Astropy-12907, the criterion requires model to identify that recursive separability yields an array for the nested right operand and that _cstack destroys its dependency structure by filling the embedded block with ones. |
| Fix-design convergence and authoritative grounding | 0.36% | For scikit-learn-9288, the criterion goes beyond locating the serial–parallel seed mismatch by requiring a branch-invariant repair that draws one deterministic integer seed per n_init run and passes the corresponding seed to every serial invocation. |
| Investigation efficiency and environment recovery | 3.43% | For pytest-7432, the criterion requires recovery from unusable or contradictory runtime evidence by identifying which pytest installation is executing, avoiding contamination of installed packages, and returning to authoritative repository evidence without overstating validation. |
| Intermediate-edit safety and workspace hygiene | 1.29% | For Django-10914, the criterion preserves independent directory defaults and secure temporary-file behavior while applying mode 0644 only to final stored uploads. |
| Primary category | Weighted percent | Example |
|---|---|---|
| Functional implementation correctness | 18.07% | For Astropy-13398, the criterion requires a coherent implementation of bidirectional ITRS–AltAz and ITRS–HADec transforms using topocentric geometry while keeping the terrestrial position time-invariant. |
| Edge-case and implementation completeness | 5.81% | For Django-13089, the criterion covers the empty-result edge case in which a culling query returns no row: execution must complete without subscripting None or deleting a valid cache key. |
| Patch scope and minimality | 5.47% | For Astropy-12907, the criterion confines the repair to _cstack : copy the computed right separability matrix into its positioned block rather than overwrite that block with ones. |
| Compatibility and integration preservation | 8.88% | For Astropy-14309, the criterion requires the FITS identifier to return false when no positional object exists without indexing an empty tuple, while preserving signature, extension, and HDU detection. |
| Final-code quality and maintainability | 0.47% | For SymPy-16450, the criterion requires posify to transfer compatible known assumptions through replacement-symbol construction, give positive=True unambiguous precedence, and avoid private-state mutation. |
| Submission and patch-artifact integrity | 9.48% | For Django-14915, the criterion requires a complete, repository-targeted patch in a format that the evaluator can directly recognize and ingest, rather than prose or partial diff fragments that require reconstruction. |
| Primary category | Weighted percent | Example |
|---|---|---|
| Causal before/after verification | 1.17% | For Django-11206, the criterion requires executed post-edit evidence for the reported tiny-Decimal behavior plus counterexamples that expose raw-exponent zeroing, lost scientific safeguards, or bypassed formatting arguments. |
| Targeted behavioral validation | 14.43% | For Astropy-13236, the criterion requires evidence that direct multi-field array input reaches ordinary Column construction without automatic NdarrayMixin conversion while explicit columns and legitimate mixins retain established handling. |
| Edge-case and scenario validation | 0.88% | For Django-13028, the criterion distinguishes an ordinary lookup RHS whose application attribute is false from an ORM expression that intentionally prohibits filtering, using source tracing or a task-shaped boundary experiment. |
| Regression-suite and breadth validation | 11.64% | For Astropy-14096, the criterion must establish the corrected nested-property error while protecting ordinary missing attributes and SkyCoord’s dynamic frame and transform behavior. |
| Execution-environment fidelity | 0.57% | For Django-11880, the criterion credits the dictionary-isolation check only when it is executed against the edited checkout, rather than a toy object or a different installed version. |
| Failure interpretation and claim discipline | 0.34% | For Django-12193, the criterion requires a consistent ledger in which a failed property is resolved only after its implementation or oracle is corrected and rerun, and success claims remain limited to demonstrated properties. |
Long-Horizon Agent Evaluation
Long-Horizon Agent Evaluation measures whether AI agents can plan, act, remember, and stay reliable across extended tasks and changing environments.
See all 358 papers