Repository navigation
feat(task): compare two attempts' run records by the lock table, and agent-env task diff - #974
Open
earakely-scale wants to merge 6 commits into
Open
earakely-scale wants to merge 6 commits into
earakely-scale wants to merge 6 commits into
Conversation
…`agent-env task diff` `task/drift.py` classes every difference between two attempts' records by the lock table's rows: hard when they ran different things (task, entity versions and image identity, role models, overrides, result rules and verifier settings, the last two also offering a regrade), soft for code meant to change under a run (core and plugin packages, Python, verifier packages, a role's endpoint host, where its sandboxes ran), never for how a version was asked for or how the config was found. Every record field is in a row or named as not compared, which a test holds. An image's identity, not its artifact's version, says whether it changed, so an image put again from an unchanged context is the same image. `agent-env task diff A [B]` lists the differences of two attempts, an instance's latest or INSTANCE@EPOCH, or of one instance's first and latest, and exits 0 when they ran the same thing, 1 on hard drift and 2 when they can't be compared; `--json` prints the comparison. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ne attempt read is drift only when both ran them A resume runs only the rest of a task's steps, which read less, so an entity its first attempt read and it didn't is no difference. Each attempt now records the ids of the steps it was asked to run (`steps_run`, from its start step to its end step), and the comparator counts an entity only one attempt read as hard drift when both ran the same steps, as when the configured default agent changed between two full runs, and otherwise leaves such entities out, saying how many and why. `steps_run` itself is never drift. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…1 is only ever a verdict Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s alone, and what each read is indexed once An attempt records its env, artifact and provider types once it finishes, so a killed one's runtime lists its step types alone; those it didn't record aren't differences. Each attempt's reads are indexed once per comparison, so two attempts with 3,000 reads compare in tens of milliseconds rather than seconds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tings, and a run records the formats it prescribes A rubrics judge's settings record the trajectory source of each turn it read, the host its calls reached and which settings a run's overrides changed. Compared as settings, two runs alike but for their conversations' length were hard drift with a regrade offered. Now each has a row of its own: the formats a judge read, however many turns, soft, as a copy that failed is read natively; the host its calls reached soft, as a role's endpoint host is; the names of the settings overrides changed never, as their values are compared. Each attempt records the trajectory formats it prescribes (`trajectory_formats`, from its overrides or else the config), hard, so a change of what judges are given stays hard, and the override itself isn't compared twice. The judges write these keys by the names the comparator reads them by. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…prescribed formats compare without false drift A judge's per-turn trajectory sources past the settings' inline cap are kept as their hash, so the comparator couldn't read them. The judge now also records the distinct formats it read (`trajectory_formats_read`), a few names, which the comparator reads; a record that keeps only the hash, and no summary, isn't compared on them, and the listing says so. An attempt recorded before its prescribed formats were is compared by its own `trajectory_formats` override, and one that records neither isn't compared on them, with a note, rather than counted as a change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The second of three pieces that let two runs of a task be told apart and compared. The first (#967) has each attempt of a run record what ran it and what it was asked to do and read. This one says which differences between two attempts' records matter, by the lock table, and lists them with a new command.
task/drift.pycompares two attempts' records (compare) row by row (ROWS). Each difference carries its row, the key within the row that differs, both values, and its class (Drift):regrade, since their grades can't be compared until one is regraded under the other's rules.agent-env task diff A [B]lists every difference. Each of A and B names a task instance, for its latest attempt, or one attempt asINSTANCE@EPOCH. With A alone, its first attempt is compared with its latest, as a run with its resume. It exits 0 when they ran the same thing, 1 on hard drift, and 2 when they can't be compared, any error reading the store included, so 1 is only ever a verdict.--jsonprints the comparison.steps_run, the ids of the steps it was asked to run, from its start step to its end step;trajectory_formats, the trajectory formats it prescribes to the agents whose trajectories its judges read, from its overrides or else the config.judge_endpoint_host,trajectory_sources,overridden) by constants in the verifier base, which the comparator reads by. A rubrics judge also records the distinct formats it read (trajectory_formats_read), a few names, since its per-turn list past the settings' inline cap is kept only as its hash.The lock table
steps_hash, the seed applied)step_paramsby the stepagent_sandboxandenv_sandboxoverridesNot compared, each with its reason in
NOT_COMPARED: the attempt epoch, the stage, the record version, and the pins (the reads show what was read). A test holds that every field of the records is in a row or inNOT_COMPARED, so a field added later can't go unclassified.Choices made here, for review
task diff. The design's other callers, the eval engine's resume, rerun and compare, don't exist yet, and no eval-level lock is stored yet. They call the samecompareand decide on its classes: refuse hard drift unless--allow-drift, which marks the eval instancenot_like_for_like, offer a regrade first, warn on soft drift. That policy,--allow-driftandnot_like_for_likecome with them, as nothing here would consume them.never. So rebuilding an unchanged build context, which puts a new version with the samesource:identity, is the same image.verifierrow, the role's model row, the plugin's version row. Its other fields are compared only where both attempts have it.set while gradingrow compares only the settings a verifier's grade records differently from how it started, such as a judge's model it resolves as it calls. A setting changed from the start is reported once, by the starting settings' row.trajectory_formatsoverride would otherwise list a second time. A record that keeps a judge's formats only as a hash, with no summary, isn't compared on them, and the listing says so.steps_runortrajectory_formats. One withoutsteps_runis compared only on the entities both attempts read. One withouttrajectory_formatsis compared by its owntrajectory_formatsoverride, and one with neither isn't compared on them. Each case comes with a note, never a false difference.agent_effortoverride (or the step's owneffort, in its content), and an unrecorded macOS build as the computer image's identity.Not in this PR
--allow-driftandnot_like_for_like.Tests
tst/unit/task/drift_test.py:NOT_COMPARED, and every row has a case.regradewhere the table says.never; at another identity, both its version and its identity are hard.step_paramsis its own override.tst/unit/cli/task_diff_test.py: exit 0, 1 and 2, the listing, the regrade line, an instance alone,INSTANCE@EPOCH(a local id starts with@),--json, a store that fails exiting 2, and two realTask.runruns with differentstep_paramsplus a resume that starts after the step that reads entities, through the command.tst/unit/task/run_lock_test.py: an attempt records the steps it ran, and the formats it prescribes from the config and from the run.Tested on Linux hosts
On fresh EC2 hosts with the stores on SQLite, MongoDB 7 (a one-node replica set) and DynamoDB Local, at 48a18ae, this PR's head. Model spend was a few cents of Haiku and Sonnet.
unzipfor two, and the twomcp_cli_buildercodegen tests. They fail the same way onmain.agent-env task diffover real runs (task run,LocalRunner,agent-env run), on each backend, with 0 problems:--judge-modelis hard drift in the judge's role model;neverand exits 0;LocalRunnerfrom step 1, compared with its first attempt by its instance alone, exits 0, lists the steps it ran asneverand the entities only the first read as not compared;--jsonparses, and a missing instance or a lone attempt exits 2;agent-env runbundle runs in the@localnamespace exit 0.task diffreads, 60 rounds on MongoDB and on DynamoDB Local, half of them a pair that differs: 119 rounds gave the right verdict, and one exited 2 naming the store's error. No wrong verdict.agent-env run: two runs of the bundle exit 0, "no differences: the same thing ran". A third with--judge-model claude-sonnet-5-5is hard drift in the judge's model, a regrade offered, with the names of the settings the override changed asnever.The "Integration Tests" check fails on modal 1.7.0, released 2026-11-30, which removed
modal.Sandbox._experimental_create: its unlocked install took 1.7.0, and four Modal provider unit tests fail, the same on any branch. This PR doesn't touch Modal. The checks that install fromuv.lock, which pins modal 1.6.3, pass. It's being fixed separately.🤖 Generated with Claude Code


Confidence Score: 5/5
The PR appears safe to merge; no blocking issue remains.Summary
Adds
agent-env task diffand compares attempt records using the lock table.task diffcommand lists differences between task attempts.Diagram
%%{init: {'theme': 'neutral'}}%% flowchart LR A[Attempt records] --> B[task diff] B --> C[compare] C --> D[Classify differences] D --> E{Hard differences?} E -- Yes --> F[Exit 1] E -- No --> G[Exit 0] B -- Cannot read or compare --> H[Exit 2]Reviews (10) · Last reviewed commit: "fix(task): a long conversation's judge f..." · Reviewed by Greptile