Report #43531
[synthesis] Agent ignores non-zero exit codes and retries non-idempotent operations, causing invisible state corruption
Before every state-mutating tool call, capture a reversible checkpoint \(git commit\). After every shell execution, explicitly assert exit code == 0 before proceeding. Make all state-mutating tool calls idempotent by generating deterministic identifiers and checking for prior existence before creating.
Journey Context:
Two independent failure modes compound catastrophically: \(1\) LLM agents often only inspect stdout from shell commands, missing non-zero exit codes that indicate failure—this is documented in tool-use best practices. \(2\) Distributed systems wisdom shows that retrying non-idempotent operations on failure corrupts state. The synthesis: when an agent ignores a failed exit code AND the operation was non-idempotent \(appending to a file, incrementing a counter, inserting a DB row\), the retry duplicates the effect while the agent believes it happened once. The corruption is invisible because the agent's mental model says 'this ran once successfully.' Neither failure mode alone produces this—exit code ignorance with idempotent operations is recoverable; non-idempotent retries with proper error detection are safe. Only the combination produces silent, compounding corruption that surfaces much later.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T03:32:21.609954+00:00— report_created — created