Error & Crash Auto-fix
A pipeline where AI agents analyze production errors and crashes and automatically draft code-fix PRs/MRs.
The error and crash auto-fix pipeline analyzes real user errors collected by the Sophonz SDK, finds the root cause, and automatically drafts a PR/MR containing the code fix and regression tests. Error monitoring no longer stops at the alert — it continues all the way to a code-fix candidate.
The problem it solves
Error monitoring tools only send alerts; humans still write the fixes. Connecting a stack trace to source code and finding similar issues takes time, and developers handle even simple, recurring bugs by hand. This pipeline delegates triage, root-cause analysis, and the fix attempt to agents, so people step in only where judgment is needed — such as approving a merge.
NOTE — v2 plan
This page describes the v2 pipeline plan. The agent composition and retry policy are settled, but specific behavior and thresholds may change during implementation.
Step-by-step flow
- Event trigger — An exception span or crash reported by the SDK is stored and indexed; when an alert rule marks it as an auto-fix target, the pipeline starts.
- Triage — The Triage Agent groups new issues into duplicate clusters and assigns severity.
- Fix — The Fix Agent explores the repository, finds the root cause, drafts a patch and regression tests, commits to a new branch, and opens a PR/MR.
- Validation — The Validator Agent reviews the PR body and diff quality and posts review comments.
- Merge approval — A developer makes the final review and merges. There is no auto-merge.
Responsibilities per agent
Triage Agent
- Input — New issue metadata (error type, app, session ID, trace ID).
- Output — Group ID, severity, and whether auto-fix is possible.
- Escalation — Infrastructure issues, external dependency outages, and data issues are excluded from auto-fix and handed to a human.
Fix Agent
- Clones the repository and explores the relevant files.
- Reproduces the error where possible via session replay or a unit test.
- Drafts a patch.
- Adds regression-prevention tests.
- Confirms local tests pass.
- Pushes the branch and opens the PR/MR.
On failure, it records the reason and rolls back to the Triage stage.
Validator Agent
Reviews the PR body and diff quality, flags missing tests, and warns about conflicting overlapping fixes. The Validator holds read-only permissions only.
Retry policy
| Failure type | Action |
|---|---|
| Reproduction failure | Search for additional similar sessions, then retry (up to 2x) |
| Test failure | Redesign the patch (up to 3x) |
| CI failure | Fix Agent reads the CI logs and re-patches (up to 2x) |
| Limit exceeded | Escalate to a human with a summary of the trace and attempts |
Where humans step in
The goal of automation is not to remove people, but to focus them on where their judgment matters.
| Stage | Agent | Human |
|---|---|---|
| Error triage | O | - |
| Root-cause analysis | O | - |
| Code fix attempt | O | - |
| PR/MR merge approval | - | O |
| Production deployment | - | O |
What sets it apart
- Full trace context — The agent receives not just the error stack but every front-end and back-end span on that trace.
- Session replay link — When reproduction is needed, a real user session can be replayed from RUM data for reference.
- Air-gapped support — Enterprise on-prem deployments integrate with a self-managed GitLab.
Security and safeguards
- Sensitive paths (for example, auth- or billing-related directories) default to having auto-fix disabled.
- Secret changes and infrastructure code are excluded from auto-fix.
- The pipeline never pushes directly to a production branch — it always goes through a new branch and a PR/MR.
- The entire pipeline is recorded as a single trace, and the PR body includes a trace ID link so human reviewers can see the context immediately.