Skip to content

feat(task): each attempt of a run records the code that ran it and what it was asked to do and read - #967

Open
earakely-scale wants to merge 5 commits into
mainfrom
edgararakelyan/run-lock
Open

earakely-scale wants to merge 5 commits into
mainfrom
edgararakelyan/run-lock

Conversation

@earakely-scale

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

Copy link
Copy Markdown
Collaborator

What

The first of three pieces that let two runs of a task be told apart and compared.

Each attempt of a run now records, on its task instance, the code that ran it and what it was asked to do and read. The record is written by the process that runs the steps, so on a split deployment it describes the worker, not the machine that submitted the run.

It is written when the run starts and again when the run ends, however it ends. A run that dies midway keeps what it started with. A resume in another process adds its own entries beside the first run's. A write that fails is logged and never fails the run.

  • runtime has one entry per attempt (task/run_lock.py), keyed by the attempt_epoch the process started under:

    • the core, protocol and Python versions;
    • each installed agent-env plugin's version, and how it was installed: index, vcs@<commit>, editable or local;
    • how the config file was found: environment (from AGENT_ENV_CONFIG), discovered, or none;
    • the distribution that supplied each type the run used: its step types from the start, and its env, artifact, sandbox-provider and env-provider types once it ends.

    No path is ever recorded.

  • lock has one entry per attempt.

    • intent is what the run was asked to do: the task's id, version and content hash, its pins, each role's model and endpoint host as this process's config resolves them, the overrides without secrets, and the result rules version. It is computed the way the eval plan computes its own (eval/intent.py), so the two can be compared.
    • resolved is what the process found: each verifier's settings and providing-package version at the run's start, and, once the run ends, every entity version the run read. Children are included, each with its type, whether it was read at its latest, and, for an image, its image_identity.
  • agent_env.plugins: distribution_of, distribution_version, installed_plugins and install_origin. They read installed metadata only and import nothing. Agent-env's own types map to agentenv-framework, a plugin's to the distribution whose entry point names the class, and a config-registered class to the distribution that holds its module.

  • DockerImageArtifact.image_identity: source:<digest>, the build context's content hash, when the image has one, so a rebuild of an unchanged context is the same image. Otherwise registry:<digest>, the digest it's pinned to. An image held only as a tarball gets None, since its artifact version already names it.

  • Smaller changes:

    • The config snapshot keeps found_by, and Config.config_found_by() returns it.
    • Each read the getters record now carries the entity's type, class and image identity.
    • The verifier's grade takes its settings (recorded_settings, formerly private) and version from the same functions the lock uses, so the two can't disagree.

Choices made here, for review

  • The record is per attempt, kept across re-registers, as the usage ledger is, rather than replaced each time, so a resume can later be compared with the run it resumes. An attempt that a retry starts within the run belongs to the entry before it, because the same process runs it with the same code.
  • One write at the start and one at the end, each replacing the attempt's own entries. Sending a write again is harmless, and a superseded process only ever touches its own attempt's entry.
  • intent is computed on the worker, not copied from the eval plan. The eval plan's intent lock describes the planning machine, while each run's lock describes what its own process resolved. Comparing the two is what catches a worker whose config differs from the planner's.
  • plugins lists every installed agent-env plugin, not only the ones the task's types came from, because a plugin can change a run without supplying any of its types. types lists only the types the run used, as the issue asks.
  • found_by can't name a package. A plugin that sets AGENT_ENV_CONFIG reads as environment; nothing records which package set it.
  • Known gaps:
    • Reads made on a thread that doesn't carry the run's context aren't listed. Today that's the computer composer's thread pool at a computer env's first deploy.
    • A worker that runs a task's steps itself has to enter run_recorded around them, as it already has to set run_pins.

Not in this PR

  • The drift comparator and its table come next, and the digest of the image that actually ran comes after that.
  • Showing these records in the CLI's and explorer's instance views and in eval's per-run JSON.
  • AgentEnvHub accepting the new fields: its instance models and the warehouse sync.

Tests

  • tst/unit/task/run_lock_test.py:
    • A run through Task.run records:
      • the core version, how the config was found, and each type it used;
      • its intent: content hash, pins, overrides with no key, each role's model;
      • each verifier's settings and version;
      • every entity version it read, including children, the ones read at their latest, and each image's identity (build context, registry digest, or none for a tarball).
    • The grade's verifier_settings and verifier_version match the lock's.
    • A resume adds its own entries and keeps the first. A run that fails, and one that's cancelled mid-step, still record what they read.
    • A run whose record can't be made runs and completes unrecorded. Writing an attempt's record again replaces only that attempt's entries.
    • With an editable plugin and AGENT_ENV_CONFIG pointing at a private path, no path appears in the record.
    • An instance stored before these fields existed loads without them.
  • tst/unit/plugins/provenance_test.py: agent-env's own classes, an entry point's class identified without importing it, a class with no distribution, each install kind, and a distribution that isn't installed.
  • tst/unit/config/config_found_by_test.py: a config found from the environment, discovered by walking up, and none.
  • tst/unit/artifact/image_identity_test.py: every image form.
  • E3's tst/unit/eval/resolve_test.py is unchanged and passes on the shared intent module.

Tested on Linux hosts

Host e2e and chaos results follow once the run on a dedicated host finishes.

🤖 Generated with Claude Code

Confidence Score: 5/5 · The PR appears safe to merge, with a non-blocking gap in how resumed attempts record older verifier settings after a retry.RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge, with a non-blocking gap in how resumed attempts record older verifier settings after a retry.

Summary

Each task attempt now records the code, inputs, verifier settings, and entity versions it used.

  • Each task attempt records the process and inputs behind its run.
  • Entity reads record their type and, for images, a stable image identity.
  • Run records identify installed plugins and how config was found.
  • Eval plans and task runs share the same intent calculation.

Reviews (4) · Last reviewed commit: "fix(task): a run's records are never awa..." · Reviewed by Greptile

…at it was asked to do and read

- task/run_lock.py: run_recorded writes, per attempt and by its attempt_epoch, a runtime entry (core, protocol and
  Python versions, installed plugins with their install kind, how the config file was found, the distribution of each
  type the run used; never a path) and a lock entry (intent: content hash, pins, each role's model and endpoint host,
  overrides without secrets, result rules version; resolved: each verifier's settings and version at the start and
  every entity version the run read, with each image's identity), at the start and again when the run ends.
- agent_env.plugins: distribution_of, distribution_version, installed_plugins, install_origin, from metadata alone.
- The config's found_by (environment, discovered, none); DockerImageArtifact.image_identity; recorded reads carry the
  entity's type, class and image identity.
- eval/intent.py holds the intent helpers the eval plan and each run share; the verifier's grade takes its settings
  and version from the same functions the lock does.

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 17:55
Comment thread src/agent_env/plugins/_provenance.py Resolved
Comment thread src/agent_env/task/run_lock.py Resolved
Comment thread src/agent_env/task/run_lock.py Resolved
earakely-scale and others added 2 commits November 30, 2026 10:12
…de the run's own handling of one

The start entries are written in step, as the run is registered, and the end entries on a thread the run doesn't wait
for, so a cancel between registering and the first step, or after the result is recorded, is the run's own as before.
The config tests that stand in for discovery patch discover_config, the function the snapshot now calls.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…he settings each grade ran with, and a seed shows

- The plugin scan reads each distribution's entry points: Python 3.11's entry_points() with no group yields group
  names, which left every run unrecorded there.
- A verifier's lock entry gains graded_settings, the settings its grade records once a judge has called, beside those
  it started with.
- The intent gains steps_hash, a hash of the steps as the run runs them, its seed applied, so runs of one task with
  different seeds tell apart without recording the seed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread src/agent_env/task/run_lock.py Resolved
Comment thread src/agent_env/task/run_lock.py Resolved
earakely-scale and others added 2 commits November 30, 2026 10:29
…Local run's goes to the local stores

run_in_executor doesn't carry context variables, so the unawaited end write ran outside the run's namespace scope and
an @Local run's record went for the configured store, which the write fence refused.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… in whichever order they land, and a resume names only the grades it made

- The start entries are made on the event loop, reading metadata and the context but no store, and written on a thread
  like the end ones, so a slow store holds up neither the run nor the loop; a finished entry never gives way to a
  started one, so the two writes may land in either order.
- graded_settings names only the grades this attempt wrote, not those a resume's restored context carries.
- The public names of agent_env.plugins include the provenance helpers.

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