A coding agent says it fixed a CSV importer. Your grader finds that two of three cases pass. If you give the agent one more turn, can it finish the patch? A coding agent retry evaluation lets you answer that question with two saved versions of the same file, one unchanged grader, and a record of exactly what feedback the agent received.
This tutorial is for a developer who has Git, CPython 3, a shell with the usual mkdir and cd commands, a configured Git commit identity, and an interactive coding agent they already know how to start in a specific directory. You’ll build task:csv-import-01, calibrate its grader with two hand-written controls, then run an agent in a fresh worktree. By the end, you’ll be able to tell whether the run passed immediately, recovered on a revision, remained unsolved, or lacked a valid result.
On December 3, 2026, Databricks AI Research published its Try Again evaluation. The researchers gave coding agents a count of passing checks and let them continue from their previous solution in the same workspace. Their experiments allowed up to five total attempts and reported cumulative solve rates. This tutorial uses two attempts at most, with a human running the grader and sending the count. Databricks AI Research’s Try Again study

Give the importer a three-case contract
- In a scratch area outside your existing repositories, create a directory named
csv-retry-laband a child directory namedstarter. Keep your grader and eventual patch files incsv-retry-lab, besidestarter. Use fresh directory names if you already have a lab with these names. - Save the Python starter below as
csv-retry-lab/starter/csv_import.py. Save the file with a final newline. Make this the only file in the starter directory before initializing Git. - In your operator terminal, run the setup commands from
csv-retry-lab. Keep this terminal for grading and Git inspection throughout the exercise.
# csv_import.py
def parse_row(line):
"""Return the two string fields from one headerless CSV record."""
return line.split(',')
cd starter
git init
git add csv_import.py
git commit
git tag csv-import-base
git worktree add --detach ../calibration csv-import-base
git worktree add --detach ../run-01 csv-import-base
git worktree list
cd ..
When git commit opens the editor, enter Add CSV importer starter and save. If Git refuses the commit because it lacks an author identity, fix that prerequisite using your normal Git setup before tagging. The expected listing contains the main starter checkout and two detached worktrees at the same commit. Record the full commit ID from git log in starter if you plan to compare runs later. The tag makes the commands readable. The recorded commit ID gives you a specific starting point to check if the tag ever moves. Git documents the initial snapshot, commit and tag operations separately from linked worktree creation. Git tutorial · Git worktree reference
The contract is small enough to reason through by hand. The function takes a string representing one nonempty, headerless CSV record with no embedded line breaks. The first field is an ID and the second is a label. Return a two-element list of strings in their original order. A quoted comma in the label stays within that field. A record with a field count other than two raises ValueError. The exercises below cover one ordinary record, one quoted label and one record with an extra field. The prompt specifies behavior for a short record as well, while this three-check grade exercises only the extra-field direction.
The ordinary record includes 007 to catch accidental number conversion. The second record contains a comma that belongs to the label. Counting commas in the input string would give that row the same apparent width as the extra-field case, even though the two records require different decisions. Python’s csv.reader accepts an iterable of strings and yields rows as lists of strings under its default conversion behavior. The importer then makes the application-specific decision about field count after parsing the record. Python CSV documentation
Calibrate the grader before opening an agent session
- Save the grader below as
csv-retry-lab/grade_csv.py. Keep it with the operator’s files. Open onlyrun-01as the agent’s workspace later and keep the grader, control implementations, this article and the operator terminal out of the agent’s context. A linked worktree shares repository data with its siblings and is a checkout convenience. Use an environment and access controls suitable for executing reviewed generated code, with the grader outside the agent’s accessible files where your environment supports that separation. Git worktree reference - Run
python3 -I -B grade_csv.py calibrationagainst the untouched worktree fromcsv-retry-lab. Expect one passing case. Then overwrite onlycalibration/csv_import.pywith the incomplete control below and run the identical command. Expect two. Replace that file with the known-good control and run the command again. Expect three. These are illustrative expected observations for the supplied code. - Compare the individual test names and outcomes to the table. Proceed to the agent worktree only after all three calibration runs produce the expected pattern. Leave the verifier file unchanged once calibration succeeds.
# grade_csv.py
import sys
import unittest
from pathlib import Path
class CsvImportCases(unittest.TestCase):
def setUp(self):
from csv_import import parse_row
self.parse_row = parse_row
def test_plain_row(self):
self.assertEqual(self.parse_row('007,North'), ['007', 'North'])
def test_quoted_comma(self):
self.assertEqual(
self.parse_row('031,"North, Annex"'),
['031', 'North, Annex'],
)
def test_wrong_field_count(self):
with self.assertRaises(ValueError):
self.parse_row('042,South,overflow')
def main():
if len(sys.argv) != 2:
raise SystemExit('Usage: grade_csv.py WORKTREE')
worktree = Path(sys.argv[1]).resolve()
if not (worktree / 'csv_import.py').is_file():
raise SystemExit('Invalid grade: csv_import.py is missing from WORKTREE')
sys.path.append(str(worktree))
suite = unittest.defaultTestLoader.loadTestsFromTestCase(CsvImportCases)
result = unittest.TextTestRunner(verbosity=2).run(suite)
if (result.testsRun != 3 or result.skipped or result.expectedFailures
or result.unexpectedSuccesses):
raise SystemExit('Invalid grade: expected three ordinary case outcomes')
passed = result.testsRun - len(result.failures) - len(result.errors)
print(f'Passed {passed} of {result.testsRun} checks.')
return 0 if passed == 3 else 1
if __name__ == '__main__':
raise SystemExit(main())
The script takes a worktree directory as its only argument. -I excludes the script directory and user site-packages from Python’s normal initial import path and ignores PYTHON* environment variables. The grader then appends the one selected worktree for the deliberate csv_import import. -B suppresses writing bytecode on imports. Each invocation starts a fresh interpreter so the grade can load the version on disk for that invocation. These Python flags address interpreter setup. The actual importer still executes Python code under the grader’s access, so inspect it before running it. CPython command-line reference
There is one TestCase method per scored observation. Equality compares the whole list, including its length, values and order. The exception check passes when the call raises ValueError or a subclass. Putting the candidate import in setUp lets a syntax error or an unavailable function in the reviewed candidate appear as case errors. A complete report counts both errors and assertion failures as nonpassing. An interrupted process or missing report lacks that same evidence. The operator needs the three named case outcomes and the tally together. Python unittest documentation
For the deliberately incomplete control, save this entire file as calibration/csv_import.py.
import csv
def parse_row(line):
"""Return the parsed CSV fields without checking record width."""
return next(csv.reader([line]))
For the known-good control, replace that same file with the following implementation.
import csv
def parse_row(line):
"""Return the two string fields from one headerless CSV record."""
fields = next(csv.reader([line]))
if len(fields) != 2:
raise ValueError('expected exactly two CSV fields')
return fields
The incomplete implementation is a useful control because it uses the right parser and still accepts a three-field record. That shows how a plausible-looking fix can leave a detectable contract violation. The known-good control uses the same reader, then checks the length of the parsed list. That ordering preserves North, Annex as one label and rejects the unquoted three-field record 042,South,overflow. These changes belong in the calibration worktree only. If you accidentally paste either control into run-01, create a new worktree at csv-import-base and use that new path for the agent and its grades.
| Input | Action | Expected result |
|---|---|---|
task:csv-import-01 with the starter and 007,North, 031,"North, Annex", and 042,South,overflow |
From the lab root run python3 -I -B grade_csv.py calibration before editing the control worktree. |
Illustrative. The plain record produces ['007', 'North']. Quoting and width rejection both fail, yielding Passed 1 of 3 checks. |
task:csv-import-01 with the incomplete control and 042,South,overflow |
Save the incomplete control in calibration/csv_import.py and rerun python3 -I -B grade_csv.py calibration. |
Illustrative. The quoted label stays intact, but the three-field record returns a list. Only the width assertion fails, yielding Passed 2 of 3 checks. |
task:csv-import-01 with the known-good control and 031,"North, Annex" plus 042,South,overflow |
Save the known-good control in calibration/csv_import.py and rerun python3 -I -B grade_csv.py calibration. |
Illustrative. The first of those records returns ['031', 'North, Annex'] and the second raises ValueError. The suite reports Passed 3 of 3 checks. |
Check the identities of the passes as well as the totals. If the incomplete control reports two passes but the width test is green, you may have pasted a different implementation or changed the case inputs. If all controls return the same score, verify which file you edited and that the grader’s argument points to that directory. A Python error before the suite starts is a setup problem. An assertion failure with an expected name on the incomplete control is the behavior you set out to demonstrate.
Let the agent revise the same patch once
- In a separate terminal, start a clean interactive session rooted in
csv-retry-lab/run-01, using your coding agent’s normal startup method. Keep its model selection, settings and workspace permissions consistent across independent runs. Send the first prompt below and let the turn finish. Keep the session available for the follow-up. - From the operator terminal, inspect the worktree and save the first diff using the commands below. Keep the patch outside the agent’s workspace. Grade the reviewed file while the agent is idle. Preserve the detailed output in your operator notes and record the tally against the first patch.
- On a valid
3 of 3, end the run. On a valid lower count, send the follow-up in the same session and leave the existing worktree edits in place. On an invalid grade, withhold feedback until you’ve determined whether the grade can be recovered without changing the submitted patch or the session. - If the agent revises, wait for the turn to finish, inspect and save the second diff, then run the same three checks with the unchanged grader. End the run at that grade even if one or more cases still fail.
Send the first prompt from the agent terminal.
Task task:csv-import-01. Fix parse_row(line) in csv_import.py.
The input is one nonempty, headerless CSV record without embedded line breaks.
Return exactly two fields as an ordered list of strings, preserving the text
of each parsed field. A comma inside a double-quoted field belongs to that
field. Raise ValueError if the parsed record has fewer or more than two fields.
Use only the Python standard library. Edit only csv_import.py in this workspace.
Leave the edit in the working tree without staging or committing it. You may
check your work with examples you devise inside this workspace. Stop when this
attempt is ready for review.
From the lab root, run the following after the first turn.
cd run-01
git status
git diff csv-import-base
git diff --output=../run-01-attempt-1.patch csv-import-base -- csv_import.py
cd ..
python3 -I -B grade_csv.py run-01
Read git status for staged changes or new files before relying on the saved patch. The full diff compares the tracked working tree with the fixed commit, and the export limits the patch to the one permitted source file. Untracked files need their own inspection via status. Look for unrelated behavior such as file writes, additional imports beyond the expected implementation, or code that keys off specific sample values. A patch can satisfy the three cases by accident or by hard-coding. If the submission violates the stated scope, retain the artifact and mark the run invalid under this exercise’s rules. Keep that disposition visible alongside the run count. Git diff reference · Git tutorial
The follow-up below is ready to paste when the grade is two. For zero or one pass, replace only the 2 with the count you observed. The test names, assertions, exception text and tracebacks stay in your operator notes. If the agent asks which case failed, give it no extra hints for this experiment. The first prompt is the shared task contract, and the one number is the new grading information.
2 of 3 checks passed. Try again. Revise your existing change in this same
workspace using the original task requirements. Leave the edit unstaged and
uncommitted, then stop when this revision is ready for review.
Use these commands after the revision.
cd run-01
git status
git diff csv-import-base
git diff --output=../run-01-attempt-2.patch csv-import-base -- csv_import.py
cd ..
python3 -I -B grade_csv.py run-01
Both patch files describe their respective file states relative to the starter. If the agent ends its second turn with the same implementation, the saved patches can be identical and a repeated failing grade is a valid outcome. If the second score drops from two to one, record both scores. The revision worsened the case tally and the run is still unsolved. If it reaches three, read the diffs to see what changed. In the control implementations, the change from two to three comes from the new length check. An actual agent can reach the same grade through a different implementation, so connect your explanation to its saved code.
If the turn ends and the grader terminal is unavailable, leave the patch alone while restoring your operator setup. Regrade the same snapshot if you can establish that the source and grader are unchanged and no additional feedback was sent. If the original session disappeared after a valid first failure, you know the first score, but you have no valid same-session retry outcome. Save that observation and start a new independent run if you need a replacement. For a separate experiment that changes what the agent gets at the start, see the worked Hurdle README evaluation.
Count recovered runs against the original denominator
- Choose the number of independent sessions for your comparison before reviewing outcomes. For a second session, create
run-02from the same tag with the command below. Begin with a new agent conversation and the first prompt. Substitute the new directory and patch filename prefix in both grading blocks. Repeat with a distinct directory and prefix for each further session. - Record one row per independent run with the task ID, starter commit, grader version or saved copy, agent configuration, first score, optional second score and any invalid reason. Link each valid grade to its corresponding patch. For first-attempt passes, use
not neededfor attempt two. For interrupted runs, record which observation is missing. - For this example, compute both rates over the same set of evaluable runs. A run is evaluable when it passes attempt one or has valid grades for both attempts. Report invalid runs and their reasons separately, including a known first-attempt score when available. If the evaluable set is empty, report counts and investigate the setup before calculating rates.
cd starter
git worktree add --detach ../run-02 csv-import-base
git worktree list
cd ..
Each independent session begins from the starter commit, so a successful patch in run-01 supplies no files to run-02. Keep any persistent agent memory or prior-run material out of the new session’s context. Within a single run, keep both the prior edits and the conversation. This is the experimental condition being measured. Replacing the workspace with a clean checkout after a failure would give the second turn a different starting point. For the general evaluation vocabulary, see how to measure software that acts. For the Git ownership question when a CLI also offers to create worktrees, see One Checkout, One Owner.
The filled ledger below is illustrative. All four rows use task:csv-import-01, the csv-import-base commit and the supplied grade_csv.py. The example keeps one agent configuration throughout. The rows model possible sessions and do not report agent runs performed for this article.
| Run | Attempt one | Attempt two | Decision |
|---|---|---|---|
run-01 |
2 of 3 | 3 of 3 | Recovered on revision |
run-02 |
3 of 3 | Not needed | Passed on attempt one |
run-03 |
1 of 3 | 2 of 3 | Unsolved after both attempts |
run-04 |
2 of 3 | Session lost before revision | Invalid for the paired rates. Retain the first score. |
The three evaluable sessions give first-attempt success of 1/3 and cumulative success by attempt two of 2/3. run-02 contributes to both numerators. run-01 contributes only to the cumulative numerator, so the gain is one recovered run out of three evaluable runs, about 33 percentage points. Among the two evaluable first-attempt failures, one recovers. That conditional recovery rate is 1/2 and answers a different question. Report one invalid run out of four started beside those figures, since dropping incomplete sessions can change the picture.
A first patch with two passes is an unsolved task at attempt one, even though most of its checks pass. Adding up all passing cases across sessions would reward partial implementations. Keep the tally for feedback and diagnosis, and use the all-cases threshold for the outcome. Three repeats of this toy task can show that the procedure records distinct outcomes. To compare agent configurations on broader work, you would need representative tasks and a fixed definition of evaluability for each configuration. The two-attempt result also combines continued workspace state, retained conversation, the count and additional work time. Estimating the contribution of the count alone would require a comparison with the same revision opportunity and a follow-up that withholds the count.
Preserve the patch and remove the worktrees
- Keep the starter commit ID, grader, prompts, case results and attempt patches together in the lab root. Before removing the agent worktree, confirm that the patch you want to retain is present and that its diff describes the intended
csv_import.pychange. Preserve any unexpected files you need for diagnosing an invalid run separately. A session transcript can explain how the edit came about, while the patch records the file the grader evaluated. Intel’s guide to fleet replay - For the illustrative recovered
run-01, rehearse restoration in a new worktree using the commands below. If your run passed on the first attempt, userun-01-attempt-1.patchin bothgit applycommands. Continue from--checkto application only when the check succeeds. - Close the agent session, leave its directory in every terminal and run the cleanup commands from the lab root. Inspect each target with
git statusbefore removal. Use the forced form shown only for the three named disposable worktrees after preserving everything useful. Delete further runs individually after the same inspection. Keepstarterand the operator files to reproduce the example.
cd starter
git worktree add --detach ../replay csv-import-base
cd ../replay
git apply --check ../run-01-attempt-2.patch
git apply ../run-01-attempt-2.patch
cd ..
python3 -I -B grade_csv.py replay
git apply --check validates whether the diff fits the current files without applying it. A failed check can mean you selected the wrong attempt file, the patch is empty, or the replay worktree is dirty or at the wrong commit. Check the worktree listing and read the patch headers before trying again in a fresh replay checkout. Successful application changes the file without creating a commit. For a saved passing patch, the expected replay grade is three passes. If a restored passing patch scores differently, compare the original run and replay before discarding them. Check the base commit, candidate file, interpreter and grader copy, and look for a dependency on an extra file that the scoped patch never captured. Git apply reference
cd starter
git worktree list
git worktree remove --force ../replay
git worktree remove --force ../run-01
git worktree remove --force ../calibration
git worktree list
cd ..
Skip the replay removal line if you never created that worktree. Git normally refuses to remove a dirty worktree. --force discards the working directory, which is why the commands name only disposable paths and come after export and replay. The final listing should still show starter and any other worktree you deliberately retained. Evaluate a fresh agent run from the tag if you want another independent observation. Use a replay checkout when you want to reproduce a saved grade. The two operations use the same base but give you different evidence. For decisions about deploying retries in CI after you’ve measured recovery, see CI failure-to-fix loop guards. Git worktree reference

