Skip to content

[Platform] Deprecate CRITICAL_FILE_PATTERNS backup of write_file overwrites — causes backup file explosion #808

Description

@up-guillaume

Problem

The write_file operation triggers an automatic backup of the existing file before overwriting it, controlled by CRITICAL_FILE_PATTERNS in the Clawith platform code. When an agent uses write_file on memory.md, curiosity_journal.md, or other critical files, the platform creates a .backup_<timestamp> file.

Over time this causes massive backup file accumulation:

  • DevOps Moiria: 134 memory.md backups
  • Platform Moiria: 193 backups
  • LiteLLM_MCP Moiria: 54 backups
  • Curator Moiria: 22 backups
  • Total: 872 backup files across 4 agents (verified 2026-08-02)

These backups serve no useful purpose because:

  1. workspace_revisions already tracks file diffs and provides version history
  2. The backups fragment content — useful fragments from older versions are scattered across hundreds of .backup_* files
  3. Agents use write_file to overwrite memory.md with their consolidated version (the latest version IS the consolidation), making incremental backups redundant
  4. The backups consume disk space and clutter the filesystem

Root Cause

In the Clawith platform code (likely workspace_collaboration.py or agent_context.py), when write_file is called on a file matching CRITICAL_FILE_PATTERNS, the platform creates a .backup_<timestamp> copy before overwriting.

The pattern was designed as a safety net but is redundant with workspace_revisions.

Proposed Solution

Replace the automatic pattern-matching backup with an explicit version parameter on write_file:

# Instead of always backing up critical files:
write_file(path="memory.md", content="...")

# Allow explicit opt-in versioning:
write_file(path="memory.md", content="...", create_backup=True)

This gives agents control over when a backup is created, instead of triggering it on every write.

Acceptance Criteria

  • Identify the code path where CRITICAL_FILE_PATTERNS triggers backup creation
  • Verify workspace_revisions provides equivalent recovery capability
  • Deprecate the automatic backup mechanism (or make it opt-in via parameter)
  • Clean up existing 872 backup files (done at agent level — Phases A5)
  • Document the change in agent system prompts: "use edit_file for modifications, write_file for new files"

Context

Priority

P2 — Not causing functional issues but creates ongoing filesystem hygiene debt. Every agent write_file call on memory.md creates a new backup.

Labels

enhancement, tech-debt, agent-workspace

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions