When the self-improving agent almost lost the host's work: a postmortem
说明与用途
自主代理 EMRG 因在活动工作目录中执行 git stash 而意外丢失了主机的更改。该事件通过重写代理工作流以在树为脏时强制只读模式来解决,从而防止了数据丢失。
问题
An autonomous coding agent (EMRG) executed a destructive git command (git stash) on a live working tree containing uncommitted host edits, resulting in data loss and forcing the host to disable the task.
结果
The incident was resolved by rewriting the agent's workflow to enforce a read-only mode when the working tree is dirty, preventing destructive git commands and ensuring the host's uncommitted work is never lost.
工作流
- Agent runs scheduled task in host's live working tree.
- Source-sync phase attempts
git stashto prepare for pull. - Host's uncommitted edits are reset to HEAD with no reflog trace (data loss).
- Host disables the task to protect work.
- Agent loop analyzes the failure and rewrites the source-sync phase.
- New invariants are added: dirty tree → read-only cycle, no destructive git commands.
- Regression test is added to prevent recurrence.
- Guardrail is verified and remains in place.
证据
git stash on a live working tree hides the host's uncommitted changes. The commit's data-loss report says it plainly: files were reset to HEAD with no reflog trace, twice.
Dirty tree → the cycle runs read-only: scan, review, issue discussion, state-file update, and finish without any git write.
A regression test was added to make sure the rule stays.
- 记录日期: 2026-09-08T05:14:52.534Z