Skip to main content
黯羽轻扬Keep Growing Daily

Incident Recovery Workflow: AI What should be recovered first after a programming work flow failure?

Free2026-07-15#AI#AI

AI When a programming workflow encounters a failure, not all issues merit immediate rollback. This article provides a recovery workflow based on fault classification, clarifies the recovery sequence, rollback boundaries, and upgrade conditions, along with analysis of real scenarios and failure points.

Agent engineering path
What is MCP, harness, and agent workflow traffic becomes valuable only when it moves into rollback defaults.

If the visit started with what is MCP, MCP server, harness, responses API, or agent workflow content, the next step this round is rollback evidence, permission recovery, and handoff actions worth keeping for the next outage.

Fault classification: first determine whether it is worth restoring

Not every AI programming failure requires the recovery process to be initiated. A common misunderstanding is to terminate and roll back immediately when the agent generates an error code, which often wastes the context that has been invested. The correct approach is to grade first:

  • P0 (Critical): Data loss, service unavailability, production environment agent produces destructive operations. The current session must be stopped immediately and rollback or recovery performed.
  • P1 (High): Serious errors in code logic and continuous generation of low-quality code lead to schedule delays. You can try to correct the prompt within the current session or go back a few steps.
  • P2 (Medium): Code style issues, small-scale logical errors, and contextual understanding deviations. Usually there is no need to restore, just make local modifications directly.
  • P3 (Low): formatting issues, annotation errors, recommendations that are not best practices. Ignore or process on next iteration.

The key to grading is this: recovery itself has a cost. Rolling back means losing the context accumulated by the current agent. If the project has been running for several hours, an unnecessary rollback may cause the previous correct decisions to be discarded.

Recovery order: start with the operation with the smallest impact

Once it is determined that recovery is needed, the following should be performed in order from least to most severe:

  1. Retry the current command: Sometimes the fault is the instantaneous reasoning fluctuation of LLM. Retrying the same prompt may directly solve the problem with the lowest cost.
  2. Return to the code version submitted by the previous agent: Most AI programming tools (such as Cursor, Copilot Workspace) will retain operation records, and the last change can be directly discarded without affecting previous modifications.
  3. Rollback to the previous git commit: If the agent has submitted multiple steps and cannot roll back locally, use git revert or reset. Note: This will lose all uncommitted context, be sure to confirm before operating.
  4. Clear agent cache and reinitialize: Some failures result from the agent accumulating wrong context (such as misunderstanding the project architecture). At this time, clearing the conversation record and re-describing the requirements is more effective than a hard rollback.
  5. Full rollback to a known stable version: Only when the above steps fail and the fault involves the production environment.

Real Scenario: A developer was refactoring the API layer when the agent suddenly started deleting the routes file because it was injected with the wrong preference of "simplify project structure" after a certain conversation. After the error is classified, it is determined to be P1, and step 2 is performed—return to the previous step for submission. But it was found that the rollback was not enough because the agent had modified multiple files. So perform step 3—git reset to the previous commit. After recovery, when reinitializing the agent, the context description was manually corrected and the constraint "do not delete any existing files" was added, and similar problems did not occur again.

A fault response list is displayed on the laptop, corresponding to the rollback boundary and upgrade conditions sections in the article

Rollback boundary: when not to rollback

Rollback is not a panacea. Rollback may cause bigger problems in the following situations:

  • Conflict with other developers: When multiple people collaborate, rash rollback may overwrite other people's submissions. At this time, priority should be given to communication rather than direct reset.
  • Depends on irreversible operations: If the agent has performed operations such as database migration and deletion of cloud resources, code rollback cannot restore the data. The corresponding approach is to write a migration rollback script or use cloud service snapshot recovery.
  • Complete context loss: If the rollback causes the agent to lose the project global context, it may take a lot of time to rebuild later. At this point, you can try "Export current context" and then roll back. Some tools support exporting conversation records as files.
  • The fault stems from improper prompt design: Rolling back can only eliminate the symptoms, but does not solve the root cause. If the prompt policy is not modified, the same problem will occur repeatedly.

Failure point analysis: The easiest pitfall is "indiscriminate rollback". When the P0 failure occurred, the team rolled back directly to last night's stable version, not realizing that the colleagues who collaborated that day had just merged a key feature. Rolling back will also lose this feature, causing a secondary accident. The standard approach is to first identify the affected scope, roll back only agent-related files, and manually cherry-pick colleagues' submissions if necessary.

A fault response list is displayed on the laptop, corresponding to the rollback boundary and upgrade conditions sections in the article

Upgrade conditions: when team intervention is required

When personal recovery alone cannot solve the problem, you need to upgrade:

  • More than 3 failed restore attempts: There may be a non-technical issue (e.g. tool bug, insufficient permissions).
  • The impact of the fault extends to other services or customers: The P0 event is automatically escalated and the other party is notified at the same time.
  • Unable to determine root cause of failure: Even if it recovers, it may happen again if the cause is not identified. A team is required to conduct a root cause analysis (RCA).
  • agent exhibits systematically incorrect behavior: such as persistently calling the wrong API, or insisting on using a deprecated library. This may be a training data conflict of the agent, which requires the team to adjust model selection or inject custom rules.

Typical actions after upgrade: Open a temporary channel (Slack or Discord), share the current status of the fault, have a dedicated person perform the recovery, and others provide support. At the same time, record the timeline to facilitate review later.

From passive recovery to active prevention

The recovery process is only the last line of defense. The truly efficient approach is to establish prevention mechanisms in daily development:

  • Set the execution boundary for the agent: In the prompt, specify "Only modify files in the /src directory" and "Do not allow shell commands to be executed" to prevent unauthorized operations.
  • Enable confirmation before modification mode: If the AI programming tool supports it, let the agent output diff every time before modifying the file, and the developer will confirm it.
  • Regular submission and labeling: It is recommended to commit every time a function point is completed, and use descriptive message to facilitate later positioning.
  • Monitor the token consumption and abnormal behavior of the agent: A large number of file modifications in a short period of time and frequent rollbacks are early warning signs.

Next action

Mastering the incident recovery workflow is just the foundation. When you face more complex AI programming scenarios (multi-agent collaboration, long context management, dynamic permission models), the boundaries of the recovery process will be blurred. If you want to transform from an ordinary developer to an agent engineer who can design and maintain such workflows, you can pay attention to our high-quality original paid articles and courses, and in-depth dismantling of actual cases and engineering models.

Comments

No comments yet. Be the first to share your thoughts.

Leave a comment