Home » Code Changes During an Agent Run: Detecting a Stale Baseline

Code Changes During an Agent Run: Detecting a Stale Baseline

Baseline, changed file and recheck manifests keep an earlier pass attached to its old state and a fresh checklist beside the changed candidate.

When repository state changes during an agent run, treat conclusions tied to the old state as evidence about that old state. Inspect the change, identify which assumptions and checks it affects, and replan before writing over someone else's work or reporting an obsolete test result as current. A clean working tree at the start does not guarantee a stable baseline throughout the task.

This can happen with one agent: a person edits a dependency, a generator updates a shared file, or another process changes an untracked input while the agent is reading and testing.

Record the state the task actually depends on

A commit identifier is useful but incomplete. Uncommitted changes, untracked fixtures, generated inputs, submodules, and external test configuration can matter without changing HEAD.

Git's diff documentation distinguishes comparisons involving the working tree, index, and commits. Git status also exposes states that an ordinary tracked-file diff alone does not account for. Choose observations that match the repository's work contract rather than calling one command a complete snapshot.

For a bounded task, identify the relevant source files, schema or generated inputs, acceptance checks, and expected starting revision. Preserve a record of pre-existing user changes. Do not copy secret file contents into an audit artifact merely to make a snapshot comprehensive.

Decide what changed before deciding to continue

Imagine an agent adding a client field while a person changes the server schema. The agent's earlier reading and tests may now describe an interface that no longer exists. Reapplying its prepared patch can succeed textually while reintroducing the obsolete field.

A small decision table helps:

Observed change Appropriate question
Documentation unrelated to the task changes Does it alter any governing instruction or acceptance requirement?
A schema used by the patch changes Must the implementation and tests be rebuilt against the new interface?
The file the agent intends to edit contains new work How can the desired change be reconciled without discarding that work?
A fixture or generator input changes Are prior outputs and test results still applicable?

These questions require scope judgment. Automatically aborting on any byte change can waste useful work; automatically ignoring changes outside the originally named file can miss a dependency.

Put checkpoints before consequential transitions

Reobserve relevant state before applying a prepared edit, after integrating it, and before claiming that the resulting candidate passes. Record the exact candidate associated with each check.

Our clean-checkout article asks whether a frozen candidate carries its required inputs. Here the candidate itself may have changed since it was inspected. Reproducing yesterday's snapshot does not establish that today's combined work is correct.

A content fingerprint can help detect a mismatch, but its boundary must be explicit. A list of hashes for declared inputs does not detect an undeclared dependency, establish who changed a file, or prevent a write that races with the next observation.

Detection is not mutual exclusion

A local synthetic fixture checked a scoped file manifest three times: unchanged contents remained equal, a content change was detected, and adding a new matching input changed the manifest. All three checks passed. The fixture used temporary files and hashing; it did not run an agent or simulate a concurrent Git integration.

A check followed by a write still has a race if another actor can modify the same surface between them. If the workflow needs exclusive editing, establish an actual ownership or isolation mechanism and test its behavior. Do not describe a preliminary hash comparison as a lock.

The parallel-agent ownership protocol addresses coordinated workers and shared decisions. A moving-baseline check complements that protocol; it cannot enforce the agreement by itself.

Reconcile without rewriting the evidence

Keep a useful patch or analysis when the baseline changes, but label the revision it used. Inspect the newly introduced work, settle any changed interface, and rerun affected checks on the combined candidate. Preserve unaffected results only when their continued applicability can be explained.

Avoid destructive cleanup as a shortcut. Resetting the checkout to restore the agent's original assumptions can discard the very work it needed to understand. If the change makes the task's authority or intended behavior unclear, ask the owner at that specific boundary while continuing independent investigation.

The handoff should identify the starting state, detected drift, reconciliation decision, final candidate, and checks actually executed. That lets another reviewer see why an earlier pass was insufficient and what the later evidence now covers.

You may also like