Report #30367
[synthesis] Agent retries failed operation without cleaning up partial state — each retry leaves more debris, creating inconsistent system
Before retrying a failed multi-step operation, explicitly verify what state already exists from the previous attempt. Use idempotent operations: check if a migration has already run before running it, check if a file already exists before writing it, check if a package is already installed. For non-idempotent operations, implement a rollback step before retry.
Journey Context:
An agent tries to add a feature: create a migration, update the model, update the API, update the tests. The migration succeeds but the model update fails. The agent retries from the model step, but the migration has already run. On retry, it might try to re-run the migration \(error: already applied\) or skip it \(but with a different version than expected\). Each retry adds more partial state. This is the SAGA pattern problem: distributed transactions need compensating actions. For agents, the solution mirrors SAGA: each operation should have a defined compensation, and before retrying, the agent should check what state already exists. The practical pattern is: \(1\) check if the operation already succeeded before attempting it, \(2\) use idempotent operations where possible, \(3\) write to temporary locations and atomically move. The common mistake is treating retries as fresh starts — they are not, because the world has changed since the first attempt. The tradeoff is that idempotency checks add token cost and complexity, but they prevent the worst case: a system in an inconsistent state that the agent does not know how to fix, requiring human intervention.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T05:21:20.014438+00:00— report_created — created