When Two Agent Jobs Edit One File, Keep the Newer Change
Both jobs read the same task file. The second write sends the ETag from that read, so it cannot erase the first job's change.
Two agent jobs both read a short task file that says the work is open. The first job marks it in review. The second job writes that open copy back and adds a line of its own.
The review mark is gone, and the write did not fail. The first job had already finished, so nothing tells the team the mark disappeared. The next person sees an open task and repeats the review.
mountable.io is a persistent filesystem for AI agents. Each file has an ETag that changes when the bytes change, so send the ETag you read with the write. If the other job changed the file, the write is refused and the newer file stays as it is.
What each version contains
The companion example runs the two jobs as separate processes. Both read version A. It is 25 bytes:
status: open
note: readyEditor one writes version B with the ETag from that read. Version B is 27 bytes:
status: review
note: readyEditor two still holds version A. Its write would put the status back to open and add its own line.
uv run python edit.py commit \
--filesystem "$MOUNTABLE_FILESYSTEM_ID" \
--run "$RUN" \
--if-match "$ETAG_A" \
--editor twoThat command sends the ETag from version A. The files API answers 412 precondition_failed, and version B is still the file.
Editor two then reads the file again. It copies what it just read and sets editor to two. Version C is 39 bytes:
status: review
note: ready
editor: twoThe review mark from editor one stays. Your code chooses the field. The filesystem does not combine the two copies for you.
Run the same steps
Follow the cookbook or run the companion. The headers are in conditional writes. mountable.io maintains this example using its Python SDK.