Skip to content

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
mainfrom
edgararakelyan/run-drift
Open

earakely-scale wants to merge 6 commits into
mainfrom
edgararakelyan/run-drift

Conversation

@earakely-scale

@earakely-scale earakely-scale commented Nov 30, 2026 •

Copy link
Copy Markdown
Collaborator

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.py compares 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):
    • hard: the two ran different things. A change of the result rules or of a verifier's settings is also marked regrade, since their grades can't be compared until one is regraded under the other's rules.
    • soft: the code that ran differed in a way meant to change under a run, as an upgraded package. It only warns.
    • never: recorded, and never drift.
  • 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 as INSTANCE@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. --json prints the comparison.
  • Each attempt also records two things about what it was asked to do (both additive, read as None from older records):
    • 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.
  • The judges write the keys their settings record of how grading went (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.
attempt 0 of demo-hrcew3vi -> attempt 0 of demo-5rcxnzmj
  hard   role model judge: claude-sonnet-5-5 -> claude-opus-5-5
  soft   override agent_sandbox: - -> modal
  hard   override judge_model: claude-sonnet-5-5 -> claude-opus-5-5
  hard   override step_params score: - -> {"threshold": 0.9}
  hard   verifier settings score threshold: - -> 0.9  (regrade)
4 hard, 1 soft, 0 never: they didn't run the same thing
Their grades are under different result rules or verifier settings: regrade one under the other's before comparing their scores.

The lock table

Row Class
task id, version and content hash hard
steps as run (steps_hash, the seed applied) hard
trajectory formats prescribed hard
each entity's version, type and image identity hard
each role's model hard
each override, a step's step_params by the step hard
result rules version hard, regrade
each verifier's type hard
each verifier's settings, and those its grading set or changed hard, regrade
the trajectory formats a judge read, with their ATIF adapter versions, however many turns soft
the host a judge's calls reached soft
agent_sandbox and env_sandbox overrides soft
a role's endpoint host soft
core packages, Python, each plugin's version and install kind, each type's package soft
each verifier's package and version soft
a role's model's source (the config layer that named it) never
the steps it ran never
which of a verifier's settings a run's overrides changed never
whether an entity was read at its latest or through an alias never
how the config file was found never

Not 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 in NOT_COMPARED, so a field added later can't go unclassified.

Choices made here, for review

  • The first caller is 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 same compare and decide on its classes: refuse hard drift unless --allow-drift, which marks the eval instance not_like_for_like, offer a regrade first, warn on soft drift. That policy, --allow-drift and not_like_for_like come with them, as nothing here would consume them.
  • An image's identity, not its artifact's version, says whether it changed. When both attempts read an image with the same identity, its version's change is never. So rebuilding an unchanged build context, which puts a new version with the same source: identity, is the same image.
  • A thing added or removed is one difference. A verifier, a role or a plugin present in one attempt only is reported once, by its row: the verifier row, the role's model row, the plugin's version row. Its other fields are compared only where both attempts have it.
  • What grading set is compared apart from the starting settings. The set while grading row 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.
  • An entity only one attempt read is a difference only when both ran the same steps. A resume runs only the rest of a task's steps, which read less, so what it didn't read isn't compared, and the listing says how many and why. When both ran the same steps, an entity only one read is hard drift, as when the configured default agent changed between two full runs, which nothing else records.
  • How a judge's grading went isn't a setting. A rubrics judge's settings also 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 how long their conversations went would be hard drift with a regrade offered, and every override would be listed twice. Each has a row of its own instead: the formats a judge read, however many turns, soft, as a turn whose ATIF copy 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, since their values are compared. What judges are given is hard through the formats the run prescribes, which the trajectory_formats override 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.
  • Records written before this PR. They have no steps_run or trajectory_formats. One without steps_run is compared only on the entities both attempts read. One without trajectory_formats is compared by its own trajectory_formats override, and one with neither isn't compared on them. Each case comes with a note, never a false difference.
  • An attempt that didn't finish is compared without what it recorded only at its end: its reads, and the env, artifact and provider types it used. The listing says so.
  • The run manifest gaps from an earlier bench each show up as a hard difference: an unpinned harness version as the agent image's identity, an unpinned effort as the agent_effort override (or the step's own effort, in its content), and an unrecorded macOS build as the computer image's identity.

Not in this PR

  • The eval engine's resume, rerun and compare, which refuse or warn on these classes, with --allow-drift and not_like_for_like.
  • The digest of the image that actually ran, recorded as evidence that's never drift, and the provider of every sandbox a run makes, a judge's own included.
  • Showing the records in the explorer's UI and in eval's per-run JSON.

Tests

  • tst/unit/task/drift_test.py:
    • Every record field is in exactly one row or in NOT_COMPARED, and every row has a case.
    • Each row, changed alone, is exactly one difference of its class, with regrade where the table says.
    • An image put again from an unchanged context is never; at another identity, both its version and its identity are hard.
    • The sandbox overrides are soft, and each step's step_params is its own override.
    • A verifier added is one difference. A verifier one attempt didn't grade isn't compared by what grading set. A setting changed from the start is one difference though the grade records it too.
    • An attempt that didn't finish is compared without its reads and without its types beyond its steps', with a note.
    • An entity only one attempt read is hard drift when both ran the same steps. A resume that ran the rest is compared on what both read, with a note, and so is an attempt that doesn't record its steps.
    • A judge that read 5 turns where the other read 1, in the same formats, is no difference. A long conversation's formats kept as a hash are compared by their summary, and without one they're a note. An older attempt is compared by its override of the formats, and one with neither is a note. A change an override made to a judge is its setting, hard, and the setting's name, never. Prescribed formats given as an override are compared once.
    • Two attempts with 3,000 reads and 200 verifiers compare in tens of milliseconds.
    • The run manifest's three gaps are each a hard difference.
    • An instance's records by attempt, its latest by default.
  • 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 real Task.run runs with different step_params plus 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.

  • Unit tests: the whole unit tier plus the protocol package's tests, with a 300 s per-test timeout. 22,765 passed and 4 failed, all tests that need tools these hosts lack: unzip for two, and the two mcp_cli_builder codegen tests. They fail the same way on main.
  • This PR's tests, repeated 10 times: 10 of 10 clean. On Python 3.11.18: this PR's tests, the eval tier and the verifier tier, 1,420 passed.
  • agent-env task diff over real runs (task run, LocalRunner, agent-env run), on each backend, with 0 problems:
    • two runs of a task exit 0, "no differences";
    • a run after a new version of its env is hard drift naming the env, 1 -> 2;
    • a run with --judge-model is hard drift in the judge's role model;
    • an image put again from an unchanged build context, then read at its new version, is never and exits 0;
    • a run that fails, continued through LocalRunner from step 1, compared with its first attempt by its instance alone, exits 0, lists the steps it ran as never and the entities only the first read as not compared;
    • --json parses, and a missing instance or a lone attempt exits 2;
    • two agent-env run bundle runs in the @local namespace exit 0.
  • kill -9 mid-run, 10 rounds per backend: every killed attempt, compared with a finished run of the task, exits 0, compared without its reads and the types it records at its end, never exit 1.
  • A record a newer version wrote beside the instance's own: it's left out, the comparison exits 0, and naming its attempt exits 2. On each backend.
  • Network faults through toxiproxy (lost replies, resets, latency) while task diff reads, 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.
  • Scale: two attempts with 3,000 reads and 200 verifiers each, one image changed: exactly its two differences, in 1.4 s on SQLite and 1.9 s on MongoDB, the CLI's start included.
  • Claude Code on Haiku with a rubric judge, through agent-env run: two runs of the bundle exit 0, "no differences: the same thing ran". A third with --judge-model claude-sonnet-5-5 is hard drift in the judge's model, a regrade offered, with the names of the settings the override changed as never.
  • No hosts are left running.

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 from uv.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.RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge; no blocking issue remains.

Summary

Adds agent-env task diff and compares attempt records using the lock table.

  • Attempt records show which differences matter when runs are compared.
  • The task diff command lists differences between task attempts.
  • Each attempt record names the steps and trajectory formats it was asked to use.
  • Rubric judges record compact details about the inputs and hosts they used.

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]
Loading

Reviews (10) · Last reviewed commit: "fix(task): a long conversation's judge f..." · Reviewed by Greptile

…`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>
@earakely-scale
earakely-scale requested a review from a team as a code owner November 30, 2026 23:46
Comment thread src/agent_env/task/drift.py Resolved
Comment thread src/agent_env/task/drift.py Resolved
earakely-scale and others added 4 commits November 30, 2026 18:55
…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>
Comment thread src/agent_env/task/drift.py Resolved
Comment thread src/agent_env/task/drift.py Resolved
…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

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant