WEBVTT 1 00:00:01.150 --> 00:00:04.690 To train an agent that works in a terminal, we first need tasks. 2 00:00:04.890 --> 00:00:08.510 Whether a task is good enough to train on comes down to two things. 3 00:00:08.710 --> 00:00:11.450 First, the material in its environment is real. 4 00:00:11.650 --> 00:00:16.370 Second, the grading can be trusted: you score only when you get it right, 5 00:00:16.370 --> 00:00:19.590 and doing nothing or taking a shortcut scores nothing. 6 00:00:19.790 --> 00:00:22.370 This video walks through the whole process once. 7 00:00:22.570 --> 00:00:27.610 From a public data page, we pick material, fetch the files, build two tasks, 8 00:00:27.610 --> 00:00:31.310 check them, and run them for real, so the grading has the last word. 9 00:00:31.510 --> 00:00:34.890 Every command and output on screen comes from a real run. 10 00:00:35.617 --> 00:00:37.877 First, we open the data page. 11 00:00:38.077 --> 00:00:40.417 You can see the index has two layers. 12 00:00:40.617 --> 00:00:42.957 The top layer is task material. 13 00:00:43.157 --> 00:00:46.777 There are 1,793 material sets. 14 00:00:46.977 --> 00:00:50.277 A material set is a batch of files picked from one source. 15 00:00:50.477 --> 00:00:54.177 They are grouped by task family into 13 collections. 16 00:00:54.377 --> 00:00:57.997 The bottom layer is corpora, 124 of them. 17 00:00:58.197 --> 00:01:01.097 A corpus is a whole upstream, read in bulk. 18 00:01:01.297 --> 00:01:06.757 Together they hold 1.22 billion rows, for when no material set fits. 19 00:01:06.957 --> 00:01:10.577 The two layers are counted separately, so don't add them up. 20 00:01:10.777 --> 00:01:13.517 And material sets are not taken from the corpora. 21 00:01:13.717 --> 00:01:15.817 Tasks are built from the top layer. 22 00:01:16.017 --> 00:01:18.917 The files in a material set are split into units. 23 00:01:19.117 --> 00:01:21.697 A unit can be a workbook, or a test case. 24 00:01:21.897 --> 00:01:27.677 There are 4,171 units, and 787 have an answer file. 25 00:01:27.877 --> 00:01:32.617 Without an answer, you can't grade, so we pick from units with answers. 26 00:01:33.317 --> 00:01:35.257 Let's scroll down to the collections. 27 00:01:35.457 --> 00:01:37.397 Here's Spreadsheets with answers. 28 00:01:37.597 --> 00:01:42.017 It has 68 material sets, and 530 units with an answer file. 29 00:01:42.217 --> 00:01:43.357 Let's open it. 30 00:01:43.557 --> 00:01:47.097 We search for the UK government workbooks, and expand that row. 31 00:01:47.297 --> 00:01:50.437 It holds spreadsheets published by UK government bodies. 32 00:01:50.888 --> 00:01:54.428 There are 40 units, and each unit is one workbook. 33 00:01:54.628 --> 00:01:57.608 The 40 answers are kept apart, in the answer folder. 34 00:01:57.808 --> 00:02:03.508 The license is OGL UK 3.0, in the Permissive tier. 35 00:02:03.708 --> 00:02:06.208 Training and redistribution are both allowed. 36 00:02:06.408 --> 00:02:07.868 Now we open Preview. 37 00:02:09.775 --> 00:02:13.715 You can see the index is only a list, not a copy of the files. 38 00:02:13.915 --> 00:02:18.015 Each file gets one row: where to download it, its size, 39 00:02:18.215 --> 00:02:19.435 its checksum, 40 00:02:19.635 --> 00:02:21.095 and its license. 41 00:02:22.817 --> 00:02:26.437 In the same way, we pick one from the Disk images collection. 42 00:02:26.637 --> 00:02:29.777 These are the test cases that come with the exfatprogs tool. 43 00:02:30.741 --> 00:02:34.121 There are 15 damaged exFAT images, each with an answer. 44 00:02:34.321 --> 00:02:37.861 The images themselves are under the GPL, in the Share-alike tier. 45 00:02:38.061 --> 00:02:39.361 Training is allowed. 46 00:02:39.561 --> 00:02:43.261 If you ship the images, you have to ship the same license with them. 47 00:02:43.983 --> 00:02:46.803 With both chosen, we go to Get the data. 48 00:02:47.003 --> 00:02:50.523 The page builds commands for one material set at a time: 49 00:02:50.523 --> 00:02:53.183 Look first to preview, then Take to fetch. 50 00:02:53.383 --> 00:02:57.483 The commands pin a release, which fixes the file list and the checksums. 51 00:02:57.683 --> 00:03:01.703 Fetch again later, and you get the exact same files, or a checksum error. 52 00:03:01.903 --> 00:03:04.863 We want two material sets, so in the terminal 53 00:03:04.863 --> 00:03:06.803 we'll put both into one command. 54 00:03:07.717 --> 00:03:11.637 If an agent does the picking, or you'd rather not open the page, 55 00:03:11.637 --> 00:03:13.257 the index has a catalog. 56 00:03:13.457 --> 00:03:17.797 It's this file: one row for each material set and each corpus. 57 00:03:17.997 --> 00:03:20.077 DuckDB, a database tool 58 00:03:20.077 --> 00:03:24.417 that queries data files directly, reads it with one SQL query. 59 00:03:24.617 --> 00:03:29.177 Collections go by letter here: Spreadsheets with answers is A, 60 00:03:29.177 --> 00:03:30.877 and Disk images is B. 61 00:03:31.077 --> 00:03:34.057 Again, we keep only sets with answers. 62 00:03:34.257 --> 00:03:36.837 That's 111 material sets. 63 00:03:37.037 --> 00:03:40.257 Now the 6 largest sets per collection, by units. 64 00:03:40.457 --> 00:03:43.277 Our two picks are here: this one 65 00:03:43.477 --> 00:03:44.537 and this one. 66 00:03:44.737 --> 00:03:46.917 This column is the license tier. 67 00:03:48.437 --> 00:03:52.057 To fetch files, we use the fetch tool that comes with the index. 68 00:03:52.257 --> 00:03:56.197 uv pulls it from the web and runs it, with nothing to install. 69 00:03:56.397 --> 00:03:58.257 Both sources go in one command. 70 00:03:58.457 --> 00:04:03.677 We take one unit from each, with dry run: preview only, no download. 71 00:04:03.877 --> 00:04:07.097 The files not taken are too many to show, so we filter them out. 72 00:04:07.297 --> 00:04:10.277 You can see the two sources have 55 units. 73 00:04:10.477 --> 00:04:14.477 By default, the tool leaves out duplicates, benchmark copies, files 74 00:04:14.477 --> 00:04:17.517 not yet compared with the benchmarks, files we may not ship, 75 00:04:17.517 --> 00:04:21.777 files not in English, personal data, and files over 20 MB. 76 00:04:21.977 --> 00:04:24.637 This time, all of these are 0. 77 00:04:24.837 --> 00:04:30.057 As asked, it takes 2 units: 8 files, answers and companion files included. 78 00:04:30.257 --> 00:04:33.797 That looks right, so we drop dry run and download for real. 79 00:04:34.588 --> 00:04:36.368 All 8 files are OK. 80 00:04:36.568 --> 00:04:39.868 Each one was checked against the size and checksum in the index. 81 00:04:40.068 --> 00:04:41.668 This exFAT image comes 82 00:04:41.668 --> 00:04:45.688 inside an archive upstream, and the tool unpacked it for us. 83 00:04:45.888 --> 00:04:47.268 Let's see what we got. 84 00:04:47.721 --> 00:04:52.381 The material goes in folders by domain, and the answers go apart, under answer. 85 00:04:52.581 --> 00:04:55.221 They're kept apart because the answers are for grading, 86 00:04:55.221 --> 00:04:57.623 and must never get into the agent's environment. 87 00:04:58.283 --> 00:05:00.623 The index gives you material and answers. 88 00:05:00.823 --> 00:05:02.923 Building the tasks is up to you. 89 00:05:03.123 --> 00:05:06.343 Here is one way to do it, in the Harbor task format. 90 00:05:06.543 --> 00:05:09.443 Harbor is a framework for running tasks like these. 91 00:05:09.643 --> 00:05:11.483 A task is four things: 92 00:05:11.483 --> 00:05:16.303 an instruction, an environment, a reference solution, and tests. 93 00:05:17.863 --> 00:05:20.043 Let's build the spreadsheet task first. 94 00:05:20.243 --> 00:05:24.263 This Python command and these two paths are in the example's README. 95 00:05:24.463 --> 00:05:27.923 The paths are the answer file and the workbook we just fetched. 96 00:05:28.123 --> 00:05:29.823 We open the answer file. 97 00:05:30.381 --> 00:05:39.441 It holds the values of 5 formula cells: 6.5, 6.6, 6.55, 4.9, and 5.8. 98 00:05:39.641 --> 00:05:41.501 Now the workbook itself. 99 00:05:42.194 --> 00:05:46.294 Next to each of the 5 formulas is its result from the last calculation. 100 00:05:48.294 --> 00:05:51.014 They match the answers exactly, because the answer file 101 00:05:51.014 --> 00:05:54.954 was taken from these stored results, saved when the workbook was published. 102 00:05:55.154 --> 00:05:57.414 So the answers are hidden in the workbook. 103 00:05:57.614 --> 00:06:01.394 Give this file to an agent as it is, and it just reads them off. 104 00:06:01.594 --> 00:06:03.614 The task would be pointless. 105 00:06:04.517 --> 00:06:06.597 So for the copy the agent gets, 106 00:06:06.597 --> 00:06:10.217 we open the workbook with openpyxl and save it again. 107 00:06:10.417 --> 00:06:11.957 It's just this one line. 108 00:06:12.157 --> 00:06:16.337 openpyxl is a Python library for reading and writing Excel files. 109 00:06:16.537 --> 00:06:21.037 When it saves, it writes the formulas, but not the computed results. 110 00:06:24.453 --> 00:06:25.593 Let's look again. 111 00:06:27.437 --> 00:06:29.217 The formulas are all still there. 112 00:06:29.417 --> 00:06:32.877 The stored results have all become None: they're gone. 113 00:06:33.077 --> 00:06:35.157 The answer file goes into the tests folder, 114 00:06:35.157 --> 00:06:36.937 and is used only for grading. 115 00:06:37.850 --> 00:06:39.630 The instruction is short. 116 00:06:39.830 --> 00:06:43.290 Work out these 5 cells, and write them to values.json. 117 00:06:43.490 --> 00:06:46.550 The reference solution is the standard way to solve the task. 118 00:06:46.750 --> 00:06:48.830 It opens the workbook in LibreOffice, 119 00:06:48.830 --> 00:06:52.050 headless, with no window, and saves a copy. 120 00:06:52.250 --> 00:06:54.350 Then it reads out the 5 numbers. 121 00:06:54.550 --> 00:06:58.310 The stored results were removed, so LibreOffice computes these cells 122 00:06:58.310 --> 00:06:59.770 when it opens the file. 123 00:07:00.683 --> 00:07:02.143 The tests are simple. 124 00:07:02.343 --> 00:07:03.383 Each value must match 125 00:07:03.383 --> 00:07:06.603 the answer file within a relative error of one in a million. 126 00:07:10.256 --> 00:07:14.836 And the tests run in a separate container, an isolated place to run code. 127 00:07:15.036 --> 00:07:18.176 The answers live only in the tests container. 128 00:07:18.376 --> 00:07:21.836 Only one file, values.json, passes between the two. 129 00:07:22.036 --> 00:07:23.976 Both sides are offline, too. 130 00:07:24.176 --> 00:07:25.456 Otherwise, the agent 131 00:07:25.456 --> 00:07:29.396 could download the original file from upstream and read the stored results. 132 00:07:30.317 --> 00:07:32.669 The second task has a different kind of answer. 133 00:07:32.857 --> 00:07:37.437 First, we check the image with fsck, the file system checker. 134 00:07:37.637 --> 00:07:39.657 You can see a string of errors. 135 00:07:39.857 --> 00:07:44.997 A cluster chain is broken: a file's blocks on the disk no longer link up. 136 00:07:45.197 --> 00:07:46.977 A checksum is wrong, too. 137 00:07:47.177 --> 00:07:48.637 Exit code 4. 138 00:07:48.837 --> 00:07:50.377 It really is broken. 139 00:07:50.577 --> 00:07:52.677 Its answer file holds no value. 140 00:07:52.877 --> 00:07:56.957 It points to the check instead: the address of the upstream test script, 141 00:07:56.957 --> 00:07:58.257 and its line numbers. 142 00:07:58.457 --> 00:08:01.277 That's how exfatprogs itself checks a repair. 143 00:08:01.477 --> 00:08:04.537 The image goes into the environment for the agent to repair. 144 00:08:04.737 --> 00:08:06.191 A copy of the original stays 145 00:08:06.191 --> 00:08:09.891 in tests, so the grading can confirm the image starts out broken. 146 00:08:10.817 --> 00:08:15.137 So the instruction: repair it until fsck finds nothing to fix, 147 00:08:15.137 --> 00:08:17.717 save it to this path, and keep its size. 148 00:08:17.917 --> 00:08:19.617 The tests have four checks. 149 00:08:19.845 --> 00:08:23.465 One: the original image really reports errors. 150 00:08:23.665 --> 00:08:26.885 Two: the repaired image has the same size. 151 00:08:27.085 --> 00:08:31.425 Three: checked again, fsck exits with 0. 152 00:08:31.625 --> 00:08:34.285 Checks one and three follow the upstream assertions. 153 00:08:34.485 --> 00:08:36.185 Check four is ours. 154 00:08:36.385 --> 00:08:39.105 The three files and the directory whose names start 155 00:08:39.105 --> 00:08:41.445 with l0 must still be there. 156 00:08:41.645 --> 00:08:45.745 fsck reports no errors on them, so a real repair keeps them. 157 00:08:45.945 --> 00:08:51.085 Without this check, a freshly formatted empty image would pass the first three. 158 00:08:52.017 --> 00:08:53.957 The reference solution is short, too. 159 00:08:54.157 --> 00:08:59.057 fsck repairs the image, checks it again, and copies it to the required path. 160 00:09:00.350 --> 00:09:02.050 Both tasks are built. 161 00:09:02.250 --> 00:09:03.950 Let's look at the folders. 162 00:09:04.150 --> 00:09:06.230 Each task has an instruction, 163 00:09:06.230 --> 00:09:10.010 an environment, a reference solution, and tests. 164 00:09:10.210 --> 00:09:12.070 That's the Harbor task format. 165 00:09:12.270 --> 00:09:17.150 Following Terminal-Bench 4.0 conventions, we also gave each task a README, 166 00:09:17.150 --> 00:09:19.890 and a cheat solution, which we'll use later. 167 00:09:22.509 --> 00:09:24.449 Our Harbor version is pinned. 168 00:09:24.649 --> 00:09:28.329 First, we lint the tasks: a static check of the folders 169 00:09:28.329 --> 00:09:31.549 and the config against the rules, without running anything. 170 00:09:31.749 --> 00:09:33.769 We turn on two extra rules. 171 00:09:33.969 --> 00:09:37.569 The agent must not run as root, and the environment's container image 172 00:09:37.569 --> 00:09:42.069 must be pinned by digest, that is, by its sha256. 173 00:09:42.269 --> 00:09:44.769 No problems, and the exit code is 0. 174 00:09:45.483 --> 00:09:47.183 Now for the real run. 175 00:09:47.383 --> 00:09:51.643 First, oracle: the agent that just runs the reference solution. 176 00:09:51.843 --> 00:09:54.723 For each task, Harbor builds the environment, 177 00:09:54.723 --> 00:09:58.183 runs the solution, then grades it in a separate container. 178 00:09:58.383 --> 00:10:00.003 We fast-forward this part. 179 00:10:00.203 --> 00:10:02.783 It really took 1 minute 46 seconds. 180 00:10:05.283 --> 00:10:07.943 The mean reward over the two tasks is 1. 181 00:10:08.143 --> 00:10:09.283 Both pass. 182 00:10:11.250 --> 00:10:13.350 But that's not enough. 183 00:10:13.550 --> 00:10:17.150 If the grading is loose, doing nothing could score too, 184 00:10:17.150 --> 00:10:19.970 and the reference solution passing would prove nothing. 185 00:10:20.170 --> 00:10:23.550 So next, nop: the agent that does nothing. 186 00:10:26.050 --> 00:10:28.950 Both tasks score 0, as they should. 187 00:10:29.650 --> 00:10:32.470 Scoring 0 for doing nothing is still not enough. 188 00:10:32.670 --> 00:10:36.050 We also need to see if a shortcut can fool the grading. 189 00:10:36.250 --> 00:10:38.590 Each task comes with a cheat solution. 190 00:10:38.790 --> 00:10:42.490 For the exFAT task, it just formats a new image. 191 00:10:42.690 --> 00:10:44.290 For the spreadsheet task, 192 00:10:44.290 --> 00:10:48.230 it downloads the original workbook, and copies its stored results. 193 00:10:48.430 --> 00:10:51.710 Following the example's README, we put the cheat solution 194 00:10:51.710 --> 00:10:54.850 where the reference solution goes, and run oracle again. 195 00:10:58.891 --> 00:11:01.151 Both tasks score 0 again. 196 00:11:02.217 --> 00:11:03.357 The rewards: 197 00:11:03.557 --> 00:11:05.957 both tasks get 1 with the reference solution, 198 00:11:05.957 --> 00:11:08.217 and 0 in the other two runs. 199 00:11:08.417 --> 00:11:09.957 For the spreadsheet task, 200 00:11:10.497 --> 00:11:13.397 the 5 computed numbers match the answers exactly. 201 00:11:13.597 --> 00:11:17.457 The nop and cheat runs left no output file, so they fail right away. 202 00:11:17.657 --> 00:11:21.357 The cheat needs the network to download, but the task is offline. 203 00:11:21.557 --> 00:11:23.097 For the exFAT task, 204 00:11:23.742 --> 00:11:26.162 the reference solution passes all four checks. 205 00:11:26.362 --> 00:11:28.622 The nop run fails the last three. 206 00:11:28.822 --> 00:11:32.522 The cheat's new image passes the first three, but fails the fourth. 207 00:11:32.722 --> 00:11:34.582 That's why we added check four. 208 00:11:40.450 --> 00:11:43.590 So we went from a public data page to two tasks. 209 00:11:43.790 --> 00:11:47.810 The reference solution passes, and doing nothing or cheating fails. 210 00:11:48.010 --> 00:11:50.910 That's the minimum a task needs before you train on it. 211 00:11:51.110 --> 00:11:56.790 To recap: pick material, fetch files, take the answers out of the environment, 212 00:11:56.790 --> 00:12:02.390 write the instruction and the tests, lint them, and finally run oracle, nop, 213 00:12:02.390 --> 00:12:04.330 and the cheat once each. 214 00:12:04.530 --> 00:12:07.670 With another material set, the steps are the same. 215 00:12:07.870 --> 00:12:11.090 The data page and the example are linked on screen. 216 00:12:11.290 --> 00:12:15.550 Both tasks and every command are in the example, so give it a try.