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

earakely-scale wants to merge 10 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 three things (all additive, read as None from older records):
    • on its lock, steps_run, the steps it actually ran, in the task's order, a retry's included, as a resume runs only the rest and a retry may rerun an earlier step;
    • on its lock, completed, whether each of them reached its end: it returned, or raised a verdict once it had graded (VerifierNotPassingError, JudgeDisagreementError); an error or a cancel stops it short. Task.run notes each step as it dispatches it and how it ended (step_dispatched, step_ended), and a worker that runs steps itself does the same;
    • on its intent, trajectory_formats, the trajectory formats it prescribes to the agents whose trajectories its judges read, from its overrides or else the config. A value named wrongly records None for this field alone.
  • 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, each of a step's step_params by its name, a role's model among them hard
the pins, where an attempt's reads aren't recorded 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
the agent_sandbox, env_sandbox and sandbox overrides, and where a verifier's judge ran soft
an endpoint a step's step_params name 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, and whether it completed them never
a secret's reference given as an override, as an API key's 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 and the record version. The endpoint overrides (litellm_base_url, judge_litellm_base_url) and the trajectory formats override aren't listed as overrides, since the role rows and the prescribed formats compare them as they resolve. What a row can't compare it says why (Comparison.not_compared): each row declares its own reason, and the comparison gathers them. 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, or a type only one used, is a difference only when both ran and completed the same steps. A resume runs only the rest of a task's steps, which read less, and a run that failed stopped short of what the other read, so what one didn't read isn't compared, and the listing says how many and why. When both ran and completed 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.
  • An override is compared by what it changes. A model override is hard: a role's model is resolved where no step names one, so it can't tell a step's own model from the config's, and a run given the config's model where the task's step names another would otherwise read as alike. An endpoint is soft however it was named, compared by the role rows as it resolves. A secret's reference, as a per-run env: API key, is never drift. Where a run's sandboxes run is soft by every key sandbox_overrides sets, sandbox included, and by where a judge the step deploys ran (judge_sandbox_type). A step's step_params are compared each by name, an endpoint among them soft, as the trl harness gives each episode its own.
  • A failed grade's settings aren't the attempt's graded settings. Its calls hadn't filled in what they fill in, so a judge that failed against one that graded isn't hard drift.
  • A grade's settings are compared where both verifiers started with the same value. A setting they started with otherwise is one difference, by the starting settings' row, and its graded value isn't compared against a start that differs.
  • 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. Its pins are compared instead, as they say what it was told to read. The listing says so, and the verdict is "the same thing ran, in what both recorded" whenever anything wasn't compared.
  • 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 and completed the same steps. A resume that ran the rest, a run that failed before it read the agent, and an attempt that doesn't record its steps are compared on what both read, with a note.
    • sandbox is soft, as is where a judge ran; an endpoint override is the role rows', and soft in step_params; an API key's reference is never drift; a model override is hard though the role it names resolves alike. Two judges that started with different effort are one difference however they graded.
    • A trajectory formats override that isn't a list is named as such, and a judge whose formats both attempts keep only as a hash is said not to be compared.
    • The run manifest's macOS-build gap: the computer, built from another base image, is a new version of its artifact, exactly one hard difference.
    • 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: the steps an attempt ran and whether each reached its end, for every way it ends (every step passing, a step failing the run, a failure tolerated, a step retried then passing, a verifier's verdict failing the run, a cancel), a retry within a resume that reruns an earlier step, a failed grade recording no graded settings, and the formats it prescribes from the config and from the run, a value named wrongly recording None and the rest.

Tested on Linux hosts

On fresh EC2 hosts with the stores on SQLite, MongoDB 7 (a one-node replica set) and DynamoDB Local, at 550ddeb, 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,782 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,437 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 passing run and one that failed at its first step, before reading anything, exit 0: the steps each ran and whether it completed them are never, and the entities only the passing one read aren't compared, with a note;
    • a run that fails, continued through LocalRunner from step 1, compared with its first attempt by its instance alone, exits 0: its first attempt ran the steps up to the one that failed and the resume the rest, both never, and the entities only the first read aren't 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: 120 of 120 gave the right verdict. Over every run, a round that couldn't read the store exited 2 naming its error, never a wrong verdict.
  • Scale: two attempts with 3,000 reads and 200 verifiers each, one image changed: exactly its two differences, in 1.5 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 run with --judge-model claude-sonnet-5-5 is hard drift in the judge's model and in the override, with a regrade offered, and the names of the settings the override changed as never;
    • a run with --sandbox local exits 0: the three sandbox overrides, soft.
  • 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/5RetriggerView in Greptile

The PR appears safe to merge.

Summary

Adds agent-env task diff to compare attempts by the lock table.

  • Task attempts show which recorded differences matter.
  • Each task attempt records the steps it ran and the formats its judges read.

All six supplied previous findings are addressed in the current code. No new actionable issues were found.

Reviews (15) · Last reviewed commit: "fix(task): a judge whose formats both at..." · 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
earakely-scale and others added 2 commits November 30, 2026 22:09
…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>
…e compare without false drift

From a review of the comparator against runs that ran the same thing:
- Each attempt records whether it completed the steps it ran (`completed`: none failed, tolerated or not, and no
  cancel). An entity only one attempt read, or a type only one used, is a difference only when both ran and completed
  the same steps, so a run that failed early is no longer hard drift for what it didn't reach.
- Where a run's sandboxes run is soft by every key that says so (`SANDBOX_OVERRIDE_KEYS`, which `sandbox_overrides`
  sets, `sandbox` included), and a judge's `judge_sandbox_type` is compared as where it ran, soft.
- The override row leaves out each role's model and endpoint, which the role rows compare as they resolve; a secret's
  reference, as an API key's, is never drift; a step's `step_params` are compared each by name, an endpoint among them
  soft.
- A grade's settings are compared where both verifiers started with the same value, so a setting they started with
  otherwise is one difference and its graded value isn't misread.
- Pins are compared when an attempt's reads aren't recorded, and the listing says "in what both recorded" when
  anything wasn't compared.
- A trajectory formats value named wrongly records None for that field rather than dropping the attempt's records.
- The grading-evidence and placement settings are sets in the verifier base, and the registry's name in a record is
  one helper (`registry_name`) the recorder and the comparator share.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread src/agent_env/task/drift.py Resolved
…override or a failed grade compares without missing or false drift

- `Task.run` notes each step it dispatches and whether it reached its end, a verdict that fails the step included
  (`step_dispatched`, `step_ended`). `steps_run` (now on the lock beside `completed`) is the steps it ran, in the task's
  order, a retry's included, so a resume whose retry reruns an earlier step says so; `completed` is that each reached
  its end, so a verifier that graded "not passing" no longer makes its attempt incomplete.
- Model overrides (`agent_model`, `user_model`, `judge_model`) are compared again, hard: a role's model is resolved
  where no step names one, so a run given the config's model where the task's step names another read as alike.
  Only endpoint overrides are left to the role rows.
- A failed grade's settings aren't the attempt's graded settings: its calls hadn't filled in what they fill in.
- What a row can't compare it says why: each row declares its own reason, and the comparison gathers them, so a type
  only one attempt used is now said, and a trajectory formats override that isn't a list is named as such.
- `RUN_ENDPOINT_OVERRIDES` is exported from `config/model.py` and shared; the step-params check names `step_params`;
  AGENTS.md keeps the comparator's invariants and points at `ROWS`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread src/agent_env/task/drift.py Resolved
earakely-scale and others added 2 commits December 1, 2026 11:50
…ask diff puts before it

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… said not to be compared

The formats row now lists every verifier both attempts graded, so its reason for one it can't compare is said even
when neither attempt has a summary, rather than the listing saying "the same thing ran" unqualified.

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