DEV Community

Sungsoo Youn
Sungsoo Youn

Posted on

10 Common Failures and How to Recover (Based on Actual Incident Records)

This is chapter 9 of my book **Building Autonomous AI Agents with Claude Code* — a field guide to turning Claude Code from a coding assistant into an agent that remembers, verifies its own work, and knows when to stop. Everything below is from a system I actually run every day on one Windows PC.*

This chapter is the most practical part of this book. All ten of these actually happened,
and most of them happened more than once. From the second time on, they were stopped by installing structure.


Failure 1 — Asserting from Guesswork

Symptom: The AI asserts system state (whether a process is running, whether a file exists, a config value) without checking.

Actual incident: While the user was actively using the computer, the AI asserted "the machine is currently in sleep mode."
Sleep state is 100% verifiable with a single command, yet a plausible guess was stated as fact.

Early signal: The wording is "it is ~" rather than "it seems ~", but no command was executed that turn.

Prevention: Put a table of verification commands into your rules file. With the list in place, compliance rises noticeably.

Fact you're about to assert Verification command
Whether a process is running Get-Process <name> / tasklist /FI
File/folder existence Test-Path / ls (the real file, not memory)
Port occupancy Get-NetTCPConnection -LocalPort N
Remote connectivity actual ping / curl results

Failure 2 — False Completion

Symptom: Treating rc=0 or a "started" log line as evidence of completion.

Actual incident: A scheduled task was reported as "registered and done," but it had never been run even once.
The registration succeeded, but the path was broken, so in practice it was set up to fail silently every day.

Prevention: Change the completion criterion from "the command succeeded" to "the target's state changed."

def verify_done():
    report = REPORT_DIR / f"digest_{today()}.md"
Enter fullscreen mode Exit fullscreen mode

On top of this, add the independent auditor from Chapter 6. The one who built the work must not be the one who passes judgment on it.


Failure 3 — Not Checking the Records

Symptom: Yesterday's solution is in the records, but it goes unread and the same struggle repeats.

Actual incident: The same encoding problem was solved three times. All three times it was approached as if seen for the first time.

Prevention: Install a gate that forcibly checks whether the records were read (the hooks from Chapter 4).

if not read_this_session(PROJECT / "memory/diary.md"):
Enter fullscreen mode Exit fullscreen mode

The key is to not count "I saw the summary" as having checked. Seeing an auto-injected three-line summary
and actually reading the file are different things.


Failure 4 — Encoding Corruption (Essential for Korean-Language Windows Environments)

Symptom: Korean text gets garbled in output, in subprocesses, and in file writes that go through the shell.

Prevention: Block all three places. If any one is missed, corruption comes in through that path.

import sys
sys.stdout.reconfigure(encoding='utf-8')
sys.stderr.reconfigure(encoding='utf-8')

subprocess.run(cmd, encoding='utf-8', errors='replace', capture_output=True)

open(path, 'w', encoding='utf-8', newline='')
Enter fullscreen mode Exit fullscreen mode

Put no Korean at all into batch files. If a path contains Korean, add a single English-path wrapper.


Failure 5 — Variable and Path Destruction at Shell Boundaries

Symptom: Using a PowerShell variable from bash yields an empty string, and unquoted Windows paths
lose their backslashes.

powershell -Command "$dir = 'C:\Temp'; ls $dir"

powershell -File "$TEMP/task.ps1"
Enter fullscreen mode Exit fullscreen mode

Prevention: Don't mix shells. Any other-shell command longer than two lines gets saved to a file and executed.


Failure 6 — Silent Failure

Symptom: Errors swallowed by try/except; "0 items, successfully."

except Exception:
    pass
Enter fullscreen mode Exit fullscreen mode

Prevention: Make failure a first-class citizen of the output format. Build a failure slot into the report template itself.

def render(items, failures):
    if failures:
    if not items:
    return head
Enter fullscreen mode Exit fullscreen mode

Zero results is a warning, not a success. This one line prevents a dead parser from sitting unnoticed for weeks.


Failure 7 — Orphan Process Accumulation

Symptom: Processes left behind by automation paralyze the system weeks later.
This is the number one cause of "my computer suddenly got slow."

Prevention: Duplicate-run check + periodic cleanup.

lock = Path(tempfile.gettempdir()) / "collect.lock"
if lock.exists() and time.time() - lock.stat().st_mtime < 3600:
lock.touch()
Enter fullscreen mode Exit fullscreen mode

Failure 8 — Working Around Instead of Fixing

Symptom: When blocked, taking a side path (retrying, another tool, a temp file) instead of fixing the cause.

Actual incident: When a file write failed, the file was saved to a different folder and the work moved on. The consumer of
that file was watching the original path, so it kept running on stale data with no error.

Prevention: Make it a rule: "after 2 attempts, stop and report the cause." A workaround is debt —
it keeps rolling for now, but it comes back with interest.


Failure 9 — Trusting Documents

Symptom: Believing documents, comments, and past summaries as truth.

Principle: Documents are the map; code is the territory. When the two disagree, the code is always right.
Before any important judgment, look directly at the source code or the actual execution result.


Failure 10 — Copy-Pasting Stale Memory

Symptom: A summary that was correct in the past is wrong now, but it gets asserted as-is.

Actual incident: When auto-generated logs piled up in mistakes.md, the AI mistook them for current issues
and repeated the same wrong answer 16 times. A case where the records actually ruined the judgment.

Prevention: Split the record files by purpose.

File What goes in it — and nothing else
diary.md Context of actual work done by a person
mistakes.md Only mistakes a person pointed out
audit-log.md All automated logs produced by scripts and cron

The moment automated logs mix into human records, memory turns from an asset into a liability.


The Common Principle of Recovery

When an incident happens, the order is always the same.

  1. Stop — cut off further damage first.
  2. Establish the current state by direct measurement — don't guess at what broke.
  3. Record the cause — together with the correct method.
  4. Add one structure that prevents the same incident — a hook, a test, or a checklist.

Recovery is not finished until step ④. Stop at step 3, and the same incident happens six months later.


Want the whole system? The book has 10 chapters plus 4 ready-to-use templates (CLAUDE.md starter, memory files, auditor checklist, measurement guide) and a hands-on section for every chapter. It's $19 as a PDF: https://dbsoul.gumroad.com/l/autonomous-ai-agents-claude-code

Not sure yet? The first three chapters are free, same PDF format: https://dbsoul.gumroad.com/l/autonomous-ai-agents-claude-code-free-sample

Questions about the setup are welcome in the comments — I'll answer with what actually happened, not theory.

Top comments (0)