cd /news/ai-agents/the-day-a-scheduled-ai-agent-erased-… · home › topics › ai-agents › article
[ARTICLE · art-177792] src=dev.to ↗ pub= topic=ai-agents verified=true sentiment=↓ negative

The Day a Scheduled AI Agent Erased 31,000 Lines — append-only discipline and verify-first detection

An engineering team reported that a scheduled AI agent erased 31,318 lines from a 31,323-line shared roadmap file 52 seconds after a PR merge, because the agent performed a whole-file Write without reading existing content and its checkout had not caught up. The team recovered the file from the last-good git commit and now restricts automated agents to anchored tail appends, backed by a CI or pre-receive hook that rejects any tracked file shrinking by more than a set line threshold.

recommendation

Give scheduled agents append-only edit tools anchored on a unique tail string, and add a pre-receive or CI check that blocks any tracked file shrinking beyond a set line threshold.

more in playbook: Securing agents and AI tools
by read3 min views16 publishedNov 28, 2026

Automated AI agents are convenient — until a task as simple as "update a file" turns into a destructive operation. This post uses a real ROADMAP truncation incident from our operations to explain the append-only discipline that keeps scheduled agents from destroying large shared files, and the verify-first pattern that caught the damage immediately.

Our growth-strategy log, GROWTH_STRATEGY_ROADMAP.md, had grown to a single file of 31,323 lines. Then, 52 seconds after a PR was merged to main, a scheduled "roadmap update" agent fired an automated commit.

The commit looked like this:

1 insertion(+), 31,318 deletions(-)

The file was wiped down to a few header lines. The cause was simple: the agent wrote back an "updated" version with a full Write (whole-file overwrite) without reading the existing content first. Right after the merge its checkout hadn't caught up, so the agent treated near-empty content as the source of truth and overwrote everything.

What saved us was an operating rule: treat the prompt's premises as hypotheses and always cross-check them against date / KPI / git / PR / issue state. At the start of the next session, the state check flagged "the ROADMAP is abnormally short" instantly, and it was handled as an incident.

Recovery itself was a one-liner thanks to git:

git show <last-good-commit>:docs/GROWTH_STRATEGY_ROADMAP.md > docs/GROWTH_STRATEGY_ROADMAP.md

Rebuilding 31,000 lines by hand would be impossible. git's immutability is a textbook case of protecting "capital = time."

For large append-only record files (roadmaps, changelogs, ops logs), never allow an automated agent to full Write. Allow only tail appends.

Operation On a large shared file
Tail append (anchored) ✅ safe
Local edit on a unique anchor ⚠️ ok if the anchor is unique
Whole-file overwrite (full Write) ❌ forbidden (source of truncation)

In practice, restrict the agent's edit tool to "append anchored on a unique tail string." In the very session behind this post, the ROADMAP entry was written without re-reading any of the 31,364 lines — anchored on the unique last line and appended (no full read, no full Write).

Don't rely on human eyes — mechanically reject mass deletions in CI / a pre-receive hook.

THRESHOLD=500
before=$(git show "$BASE:docs/GROWTH_STRATEGY_ROADMAP.md" | wc -l)
after=$(wc -l < docs/GROWTH_STRATEGY_ROADMAP.md)
if [ $((before - after)) -gt $THRESHOLD ]; then
  echo "::error::ROADMAP shrank by $((before - after)) lines — block destructive overwrite"
  exit 1
fi

Following an existing regression-guard pattern lets you stop the whole class of "a grown file shrinks by accident" across the repo.

A single 31,000-line markdown file is risky on every axis — editing, diffing, and blast radius when something goes wrong. Split by period (e.g. ROADMAP_2026H1.md) to keep the live file small and shrink the blast radius of any single incident.

Automation trades speed for the risk of a "self-driving destructive operation." Build the safety valve in two layers: a design that limits the agent to appends only, and a guard that mechanically rejects anomalies.

── more in #ai-agents 4 stories · sorted by recency
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/the-day-a-scheduled-…] indexed:0 read:3min 2026-11-28 · —