> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sureops.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Post-Closure Agents

> The Problem Commander pipeline that runs after an incident closes — deep RCA, response critique, improvement recommendations, and code fixes.

When an incident closes and a Problem Record is created for it, a second pipeline runs asynchronously to build out the RCA, critique the response, propose improvements, and (where opted in) draft a code fix. This pipeline runs without blocking the incident response workflow — it produces artifacts you review on your own schedule.

Problem Record creation itself is driven by your closure policy — configured per severity and closure reason at **Settings → Incident Policy** — not by whether the incident matches a pattern seen before. Recurrence is stamped onto the resulting Problem Record (via clustering against prior incidents) as an attribute, not a precondition for creating it. If clustering can't run when the record is created (for example, a model timeout or error), the record is created anyway, with category **Other**, and sureops tries to cluster it again later. If that succeeds, the category is filled in (unless you already changed it) and a recurrence link to an earlier Problem Record can be added. See [Incident Pipeline Agents](https://docs.sureops.ai/ai-agents/incident-pipeline-agents.md) for how a Problem Record becomes eligible at closure.

***

## Problem Commander

The Problem Commander is the orchestrator for this pipeline — it's the agent shown in **Settings → AI Agents** and the one you configure a model for. Internally it runs a fixed sequence of stages, **sequentially**, each handing its output to the next:

```
context_gatherer → deep_rca → critic → recommender → fix_pr → runbook
```

**What triggers it:** a Problem Record is created for a closed incident (per your closure policy), or a manual regenerate is requested from the Problem Record page.

***

## Deep RCA Investigator

The `deep_rca` stage produces the root cause analysis.

**What it does:**

* Correlates the incident with prior related incidents
* Produces a root cause analysis (RCA) grounded in the incident's telemetry and timeline
* Identifies patterns in timing, affected services, and contributing factors

**Where results appear:**

* **Problem Records page**: the Problem Record's RCA content
* Feeds every downstream stage (critique, recommendations, fix PR, runbook)
* If your knowledge base repository is configured, the `deep_rca` stage also opens a pull request adding the postmortem document to `.sureops/postmortems/` — a separate PR from the runbook PR described below, gated by the org-wide automation kill switch (**Settings → Organization → Knowledge Base → Advanced**). There's also a second, `.sureops/policy.yaml`-level gate for this one: a `postmortem_pr.auto_pr` setting (default: `true`) that can be turned off per KB repo to suppress the postmortem PR without touching the kill switch.

**Length and action items:** the RCA is kept concise. A generated RCA holds at most 8 timeline entries, 4 contributing factors, 3 lessons learned, 5 action items and 3 resolution next steps; a longer generated list is cut to these caps. Each AI-generated action item is tagged **Fix**, **Detect**, **Process** or **Prevent**; items added by hand show **Near-term** or **Long-term** instead, so you can see the kind of work each one asks for.

**Regenerating:** a regenerate retires only the AI-generated action items that nobody has touched into the Problem Record's version history (**Previous investigations** on the **History** tab — see [Problems](https://docs.sureops.ai/using-sureops/problems.md)), which keeps the 5 newest unpinned versions plus any version a Responder or above pins, and the new draft's items take their place. An item someone edited, an item created by hand and an item pushed to a tracker carry forward, and the new draft does not add an item whose title matches one already on the Problem Record.

**If the RCA can't be drafted:** when the investigation produces no usable RCA (for example, thin telemetry), sureops does not save a placeholder. The Problem Record shows a **Couldn't draft the RCA** card instead, no postmortem PR and no runbook PR are opened for that attempt, and sureops retries automatically with growing gaps (roughly 1, 2, 4, and 8 hours). It stops after five attempts in total, counting any you trigger yourself; you can still trigger a new draft from the Problem Record page. While a draft is in progress the card reads **Drafting the RCA**. On sureops-supplied capacity, an automatic draft can also be held back while platform usage is high; the card then says drafting is paused and will start automatically, and sureops starts it on an hourly pass once usage has dropped. On sureops-supplied capacity, an automatic draft can also stop after unusually high usage on a single problem; the card says so, and sureops retries it later. A draft you start yourself is never held back this way. Regenerating an RCA also clears its earlier approval, since the new content hasn't been reviewed.

**Approval and merging:** there is **no approval step** for the postmortem PR. If your org has delegated merge authority to sureops — during the private beta, every organization has delegated merge authority to sureops by default (see [Guided Onboarding Journey](https://docs.sureops.ai/onboarding/guided-onboarding-journey.md)) — sureops tries to merge it as soon as it opens; if the merge fails, it stays open for your team. Otherwise it opens as a regular PR for your team's normal review and merge.

***

## Incident Response Critic

The `critic` stage audits how the response itself performed — not the underlying system fault.

**What it does:**

* Produces a customer-facing critique of your detection and response (what your monitoring and response stages caught, and what they missed) — this lands in the Problem Record as the response critique

***

## Improvement Recommender

The `recommender` stage turns the critique into concrete, customer-actionable output.

**What it does:**

* Produces process improvements you can make to your own incident response process, at most four per run
* Proposes monitor definitions (Grafana today — Datadog is planned but not yet connectable) that would have caught this incident automatically — these land as staged, reviewable monitor proposals. Pushing a proposed monitor live to your provider is a separate approval step and is gated behind the proposed-monitors feature for your plan.
* Adds up to three of its improvements as new action items on the Problem Record, Detect items first. An improvement that repeats an action item already on the record is skipped. A Detect item is linked to its proposed monitor when the recommender staged one for it.

**Where results appear:**

* **Problem Records page**: process improvements, proposed monitors and the action items on the Problem Record, each AI-generated one tagged Fix, Detect, Process or Prevent

***

## Fix-PR Agent

The `fix_pr` stage opens a pull request against the affected service's repo for the root cause identified during diagnosis — either a revert of the offending commit, or a written fix plan for your team to implement.

**What triggers it:** the RCA from the `deep_rca` stage, for the same Problem Record — it's a node in the Problem Commander pipeline, not a standalone handoff from the Resolution Specialist. Before any of that, your org must be on at least a Starter-tier plan for the fix-PR-generation feature itself — this gate isn't bypassable, not even by a manual trigger. Above that floor, it is off by default: on an auto trigger, it only opens a PR when **both** of the following are true — the affected service has `source_fix_pr.auto_fix_pr: true` in its `.sureops/policy.yaml` entry, **and** the org-wide automation kill switch isn't paused (**Settings → Organization → Knowledge Base → Advanced**). Either one being false blocks the auto-triggered PR. You can also trigger it manually from a Problem Record — that bypasses the `auto_fix_pr` and kill-switch checks, but it still respects the plan-tier gate. When the plan gate blocks a fix PR, the Problem Record's **Code fix** card shows **Not on your plan**.

`.sureops/policy.yaml` fields for this agent all live nested under a `source_fix_pr` block per service, and that block itself can be set at four layers — most specific wins: `per_service.<name>.environments.<env>.source_fix_pr`, then `per_service.<name>.source_fix_pr`, then `environments.<env>.source_fix_pr`, then `defaults.source_fix_pr`. This lets you set an org-wide baseline once and override only what changes per service or per environment.

**What it does, depending on your service's resolved `source_fix_pr` policy:**

* **Revert mode** (`source_fix_pr.allow_revert: true`): when the RCA attributes the incident to a specific commit, opens a PR carrying the deterministic inverse diff of that commit — equivalent to `git revert`, computed by the source-code provider with no LLM involved. The revert is applied on top of the current tip of the base branch, so later edits to the same files survive: a file nobody changed since is restored to its content before the commit, a file edited since has only the commit's change undone, and files the commit added are deleted. If the revert conflicts with later edits, sureops opens a fix-plan PR instead; if the base branch already has the commit's change undone, no PR opens.
* **Fix-plan mode** (the default, and the fallback whenever revert isn't allowed or no single commit is attributed): opens a PR that adds a written fix plan — a Markdown document, by default under `fixes/` in the service repo — describing the recommended fix for your team to implement. It does **not** change any code.
* Both `auto_fix_pr` and `allow_revert` are opt-in per service and disabled by default (`source_fix_pr.auto_fix_pr: false`, `source_fix_pr.allow_revert: false`). During the private beta, though, the `policy.yaml` in sureops' starter contract turns both on (along with `allow_forward_diff`) — see [policy.yaml](https://docs.sureops.ai/your-rules/repo-layout.md#policyyaml) to change that. (`source_fix_pr.allow_forward_diff` governs a different path — LLM-written code fixes opened during the incident itself by the Resolution Specialist — see [Incident Pipeline Agents](https://docs.sureops.ai/ai-agents/incident-pipeline-agents.md).)
* Requests review from reviewers configured in that service's resolved `source_fix_pr.reviewers`.

**Where results appear:**

* A pull request in your GitHub repository (a revert PR may already be merged if your org has delegated merge authority to sureops; a fix-plan PR always stays open — see below)
* The incident and Problem Record gain a "Fix PR" link pointing to the PR
* The Problem Record's fix-PR status follows GitHub: when someone merges, closes or reopens the PR there, the status updates to match

**Approval and merging:** there is **no separate approval step** for these PRs. If your org has delegated merge authority to sureops (during the private beta, every organization has delegated merge authority to sureops by default), sureops tries to merge a revert PR as soon as it opens; if the merge fails, the PR stays open for your team. A fix-plan PR is never merged by sureops, even with merge authority: it only adds a written plan, so it stays open for your team to implement the change on its branch. Otherwise — a fix-plan PR always, and a revert PR when your org hasn't delegated merge authority — the PR opens as a draft unless your `policy.yaml` sets `source_fix_pr.draft: false` (the private-beta starter policy does), for your team to review and merge. A revert PR whose merge failed was opened ready for review and stays that way. In every mode, the agent opens a PR from its own branch and never pushes directly to a protected branch.

***

## Runbook drafting

The final `runbook` stage runs only when `deep_rca` produced an RCA. It assembles a runbook from everything the earlier stages produced (RCA, critique, action items, timeline) and opens a **separate** pull request — distinct from the postmortem PR described under Deep RCA Investigator above — adding it to your knowledge base repository under `.sureops/runbooks/`. Like the postmortem PR, this one is gated by both the org-wide automation kill switch (**Settings → Organization → Knowledge Base → Advanced**) and the same `postmortem_pr.auto_pr` policy.yaml setting described above — no separate per-service opt-in beyond that shared flag.

**Approval and merging:** same as the postmortem PR — no approval step. If your org has delegated merge authority to sureops (during the private beta, every organization has delegated merge authority to sureops by default — see [Guided Onboarding Journey](https://docs.sureops.ai/onboarding/guided-onboarding-journey.md)), sureops tries to merge it as soon as it opens (if the merge fails, it stays open for your team); otherwise it opens as a regular PR for your team to review and merge.

***

## Pre-mortem Agent (roadmap)

Pre-mortems — automated risk analysis on a pull request before it ships — are not yet available; they're on the roadmap. See [Pricing & Tiers](https://docs.sureops.ai/getting-started/pricing-and-tiers.md) for current status.

When shipped, the design is: a GitHub webhook fires on a pull request being opened or updated (`synchronize`), and the agent reviews the diff against service history and dependency blast radius to produce a pre-mortem summary — likelihood of incident, risk areas, recommended monitoring during rollout. It would be advisory only and would never block a deployment.

***

## Configuring post-closure behavior

Post-closure agent behavior is configured in:

* **Settings → AI Agents**: Problem Commander's model
* **`.sureops/policy.yaml`** (`source_fix_pr` block — settable at `defaults`, per-environment, and per-service layers): Fix-PR auto-open, draft mode, revert opt-in, reviewer routing — and the forward-diff opt-in, which applies to incident fix PRs rather than this pipeline
* **Settings → Organization → Code fixes**: read-only. It explains the `source_fix_pr` keys, says whether sureops merges these PRs for your org, and lists the service-to-repo mappings sureops read from your contract (edit them in `services.yaml`). Auto-open and reviewers are set only in `policy.yaml` (`source_fix_pr.auto_fix_pr` and `source_fix_pr.reviewers`)
* **Settings → Incident Policy**: which closed incidents produce a Problem Record in the first place
* **Settings → Organization → Knowledge Base → Advanced**: the org-wide automation kill switch that gates the fix-PR, postmortem, and runbook PRs


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.