Skip to content

skill: checkpoint working code before diagnostic tweaks (avoid overwriting with debug stubs) #65

Description

@DaveHanns

Problem

Under all-stack agent workflows (all three of CLI, MCP, and REST available), we observe a recurring failure pattern: during local-runtime debugging, the agent iteratively rewrites correct code with diagnostic stubs — and doesn't checkpoint the working version first. When the diagnostic path reveals the actual bug is elsewhere (env var, dependency, container config), the agent has already destroyed the correct implementation.

Observed in sc11/all, sc02/all, sc05/all (2026-06-23 sweep).

Concrete trajectory (paraphrased):

  1. Agent writes correct scraper. Local test fails (unrelated env issue).
  2. Agent Edits scraper to add console.log('reached this line') debugging stubs — overwriting the working parse/extraction logic in the process.
  3. Env issue is fixed. Agent re-runs. Now the code is broken (stubs only). Agent tries to reconstruct from memory — often incorrectly.

Suggested addition to the skill

Add a "Checkpoint working code before diagnostic tweaks" pattern:

### Save known-good state before adding debug instrumentation

When local runs fail, and before you Edit any code file to add `console.log`, add a `throw`, or otherwise instrument for diagnostics:

1. **Copy the current file to a `.bak` sibling first**`cp src/main.js src/main.js.bak` — so you can `mv` back to it in one step.
2. **Or `git init` + `git add` + `git commit` early** — before any Edit, so you have a rollback anchor.
3. **Prefer additive instrumentation over destructive rewrite.** Add `console.log` at the top of a function; do NOT replace the function body with a stub.

Rule of thumb: if you're about to Edit-then-Edit-again the same file to try different debug approaches, you should have a checkpoint first. Overwriting working code with a debug stub and losing the original is a common self-inflicted regression.

Related

  • Companion runner-side change in the eval framework: surface trajectories where one stack succeeds and another fails on the same scenario, dumping a diff of what code was written when — makes the regression pattern auditable from artifacts alone.

Impact

High (agent-gap). Concentrated under all stack where the extra tools (MCP for run inspection, REST for KV probing) tempt more iterative debugging cycles.


Surfaced during an evaluation of Apify surfaces for agent-driven Actor development.

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