Skip to content

Move RCA behavioral prompts to system prompt - #445

Merged
damianloch merged 9 commits into
mainfrom
rca-agent-v2
May 25, 2026
Merged

Move RCA behavioral prompts to system prompt#445
damianloch merged 9 commits into
mainfrom
rca-agent-v2

Conversation

@OlivierTrudeau

@OlivierTrudeau OlivierTrudeau commented May 25, 2026

Copy link
Copy Markdown
Contributor

Moves all investigation guidance out of the user message and into dedicated system prompt sections.

Why: The user message was ~130 lines of behavioral instructions mixed in with the actual alert data. The model treats system prompt as authoritative and non-truncatable, so methodology belongs there. The user message should just be the facts.

What changed:

  • New rca_sections/ directory with 6 focused prompt files (identity, investigation, context_mgmt, error_recovery, evidence_standard, conclusion_gate)
  • composer.py loads these for background RCA via _build_rca_system_prompt()
  • rca_prompt_builder.py now returns only alert data + providers + Aurora Learn context — no inline instructions
  • Deleted the old skills/rca/segments/ files that were being appended to the user message

Summary by CodeRabbit

  • New Features

    • Added expanded investigation guidance: hypothesis-first workflow, explicit evidence standards, error-recovery steps, context recording, and a “before concluding” checklist to avoid premature root-cause claims.
    • Strengthened safeguards against common RCA mistakes (correlation vs causation, insufficient evidence, repeated failing queries).
  • Refactor

    • Consolidated behavioral guidance into a single system-level prompt structure and simplified the prompt builder for clearer, less redundant investigator instructions.

Review Change Stack

OlivierTrudeau and others added 2 commits May 25, 2026 11:40
Co-authored-by: Cursor <cursoragent@cursor.com>
@OlivierTrudeau
OlivierTrudeau requested a review from a team as a code owner May 25, 2026 15:41
@coderabbitai

coderabbitai Bot commented May 25, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@OlivierTrudeau, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 24 minutes and 39 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 89fdbf88-9c53-4aba-afd1-826994448af8

📥 Commits

Reviewing files that changed from the base of the PR and between 1eee810 and bf5a7af.

📒 Files selected for processing (4)
  • server/chat/backend/agent/prompt/composer.py
  • server/chat/backend/agent/prompt/rca_sections/conclusion_gate.md
  • server/chat/backend/agent/prompt/rca_sections/identity.md
  • server/chat/backend/agent/prompt/rca_sections/investigation.md

Walkthrough

Consolidates RCA behavioral guidance into ordered system-prompt markdown sections and updates background RCA assembly to load them. Removes legacy segment helpers and stops appending investigation guidance into the user message; builder now formats alert + context only.

Changes

RCA Prompt Architecture Restructuring

Layer / File(s) Summary
RCA Behavioral Guidance Sections
server/chat/backend/agent/prompt/rca_sections/identity.md, server/chat/backend/agent/prompt/rca_sections/investigation.md, server/chat/backend/agent/prompt/rca_sections/error_recovery.md, server/chat/backend/agent/prompt/rca_sections/context_mgmt.md, server/chat/backend/agent/prompt/rca_sections/evidence_standard.md, server/chat/backend/agent/prompt/rca_sections/conclusion_gate.md
Six ordered markdown sections define Aurora's identity, investigation workflow, error-recovery procedures, findings recording, evidence citation standards, and conclusion checklist for RCA system prompts.
System Prompt Assembly for Background RCA
server/chat/backend/agent/prompt/composer.py
Adds _RCA_SECTION_ORDER and _build_rca_system_prompt(); updates build_system_invariant() so background RCA returns the concatenated RCA sections instead of the prior trimmed core-prompt approach.
RCA Prompt Builder Simplification
server/chat/background/rca_prompt_builder.py, server/chat/backend/agent/skills/rca/segments/error_resilience_outro.md
Removes private RCA segment loading/rendering/appending helpers and eliminates appending investigation-depth/error-resilience/output requirements to the user message; the builder now emits only alert + context in the user message. A single-line skill segment was removed from error_resilience_outro.md.

Sequence Diagram

sequenceDiagram
  participant Composer
  participant RCAPrompt
  participant RCABuilder
  Composer->>RCAPrompt: _build_rca_system_prompt() reads ordered sections
  RCAPrompt-->>Composer: concatenated RCA system prompt
  Composer->>RCABuilder: build_system_invariant() returns system prompt
  RCABuilder->>RCABuilder: build_rca_prompt() formats alert + context (user message)
  RCABuilder-->>RCAPrompt: final RCA prompt (system prompt + user message)
Loading

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • Arvo-AI/aurora#257: Related work on skills/prompt modularization and RCA segment/template loading.
  • Arvo-AI/aurora#276: Overlaps on build_system_invariant() changes for background RCA prompt composition.
  • Arvo-AI/aurora#411: Related edits to RCA investigation guidance content in skills segments.

Suggested reviewers

  • damianloch
  • beng360
  • isiddharthsingh

Poem

🐰 In quiet burrows I arrange each line,

Sections ordered, stitched, and neatly fine.
System holds the guidance, user gives the fact,
Together they guide the investigation's tract.
Hops of joy — RCA in tidy design.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main architectural change: moving RCA behavioral prompts from the user message to the system prompt.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch rca-agent-v2

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@server/chat/backend/agent/prompt/composer.py`:
- Around line 41-47: The _build_rca_system_prompt function currently opens files
from _RCA_SECTIONS_DIR based on _RCA_SECTION_ORDER without guarding against
missing/unreadable files; update it to check existence (os.path.exists or
os.path.isfile) for each path before opening, wrap the open/read in a try/except
OSError block, log the error via the app logger or module logger (e.g.
app.logger.error or logging.getLogger(__name__).error) including the path and
exception, skip the missing/unreadable section and continue assembling parts,
and ensure the function returns a safe fallback (empty string or partial
assembled prompt) instead of letting the exception bubble up to Flask error
handlers.

In `@server/chat/backend/agent/prompt/rca_sections/identity.md`:
- Line 1: Add a top-level H1 heading at the start of identity.md (line 1) to
satisfy MD041 and match other RCA sections; prepend a descriptive H1 such as "#
Identity" (or "# Aurora" if you prefer agent-centric title) so the file begins
with an H1 instead of plain text.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: b5209aa5-9cbe-434e-b114-95f5e18aea58

📥 Commits

Reviewing files that changed from the base of the PR and between 916a8de and 6382d08.

📒 Files selected for processing (16)
  • docs/RCA_QUALITY_ROADMAP.md
  • server/chat/backend/agent/prompt/composer.py
  • server/chat/backend/agent/prompt/rca_sections/conclusion_gate.md
  • server/chat/backend/agent/prompt/rca_sections/context_mgmt.md
  • server/chat/backend/agent/prompt/rca_sections/error_recovery.md
  • server/chat/backend/agent/prompt/rca_sections/evidence_standard.md
  • server/chat/backend/agent/prompt/rca_sections/identity.md
  • server/chat/backend/agent/prompt/rca_sections/investigation.md
  • server/chat/backend/agent/skills/rca/segments/critical_requirements_header.md
  • server/chat/backend/agent/skills/rca/segments/error_resilience_infra.md
  • server/chat/backend/agent/skills/rca/segments/error_resilience_intro.md
  • server/chat/backend/agent/skills/rca/segments/error_resilience_outro.md
  • server/chat/backend/agent/skills/rca/segments/output_requirements.md
  • server/chat/backend/agent/skills/rca/segments/persistence_and_immediate_action.md
  • server/chat/backend/agent/skills/rca/segments/what_to_investigate.md
  • server/chat/background/rca_prompt_builder.py
💤 Files with no reviewable changes (7)
  • server/chat/backend/agent/skills/rca/segments/critical_requirements_header.md
  • server/chat/backend/agent/skills/rca/segments/error_resilience_outro.md
  • server/chat/backend/agent/skills/rca/segments/error_resilience_infra.md
  • server/chat/backend/agent/skills/rca/segments/what_to_investigate.md
  • server/chat/backend/agent/skills/rca/segments/error_resilience_intro.md
  • server/chat/backend/agent/skills/rca/segments/output_requirements.md
  • server/chat/backend/agent/skills/rca/segments/persistence_and_immediate_action.md

Comment thread server/chat/backend/agent/prompt/composer.py
Comment thread server/chat/backend/agent/prompt/rca_sections/identity.md Outdated
OlivierTrudeau and others added 5 commits May 25, 2026 12:30
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
damianloch
damianloch previously approved these changes May 25, 2026
Comment thread server/chat/backend/agent/prompt/composer.py Outdated
@sonarqubecloud

Copy link
Copy Markdown

@damianloch
damianloch merged commit 00a4304 into main May 25, 2026
17 checks passed
@damianloch
damianloch deleted the rca-agent-v2 branch May 25, 2026 20:47
@coderabbitai coderabbitai Bot mentioned this pull request May 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants