fix: improve summary prompt for cleaner markdown rendering#98
Conversation
Update _SUMMARY_RULES to produce emoji severity headings (### 🟠 Major), numbered lists, bold file paths, and inline suggestions. Update _format_finding_md fallback to match. Signed-off-by: Wayne Sun <gsun@redhat.com>
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the 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 have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe PR refines how the summarizer formats code review findings in markdown. The AI rules prompt is updated to require emoji severity headings and structured finding layout, the ChangesMarkdown Format Refinement for Finding Summaries
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Replace flat numbered-list format in _unpack_bare_array with heading-per-finding style matching individual agent output. Update _format_finding_md to produce rich blocks with file references, fenced code snippets, and bold suggestion labels. Simplify _SUMMARY_RULES to let the AI format naturally rather than over-constraining markdown structure. Signed-off-by: Wayne Sun <gsun@redhat.com>
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/cicaddy/delegation/summarizer.py (1)
507-519:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winFallback summary drops findings with unexpected severity labels.
Lines 508-519 bucket by raw
severity, but onlycritical|major|minor|nitgroups are rendered later. Any other severity stays infindingsbut disappears from synthesizedsummary.Proposed fix
for f in findings: sev = str(f.get("severity", "minor")).lower() + if sev not in _VALID_SEVERITIES: + sev = "minor" msg = f.get("message", "") if msg: severity_groups.setdefault(sev, []).append(f)🤖 Prompt for 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. In `@src/cicaddy/delegation/summarizer.py` around lines 507 - 519, The current bucket logic in summarizer.py stores findings by raw sev (variable sev) but the rendering loop only iterates ("critical","major","minor","nit"), so any finding with an unexpected severity is lost; update the rendering to include a fallback bucket or dynamically render any remaining keys in severity_groups after the known-order pass (e.g., build an ordered list: the known severities in that order, then append sorted(severity_groups.keys() - set(known))) and iterate that list when building parts/finding_num so all findings (variables: findings, severity_groups, sev, parts, finding_num) are included in the synthesized summary.
🧹 Nitpick comments (1)
src/cicaddy/delegation/summarizer.py (1)
129-134: ⚡ Quick winUse Google-style docstring sections for
_format_finding_md.The updated docstring should follow Google-style (
Args,Returns) forsrc/**/*.py.Proposed refactor
def _format_finding_md(entry: dict) -> str: - """Format a single finding dict as a rich markdown block. - - Mirrors the structure individual review agents produce naturally: - file reference, issue description, code snippet, and suggestion - as separate visual blocks. - """ + """Format a single finding dictionary as markdown. + + Args: + entry: Finding payload containing message, file, and optional + existing_code/suggestion fields. + + Returns: + A markdown string for one formatted finding block. + """As per coding guidelines,
src/**/*.py: Use type hints and Google-style docstrings in Python code.🤖 Prompt for 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. In `@src/cicaddy/delegation/summarizer.py` around lines 129 - 134, The function _format_finding_md has a plain docstring; update it to a Google-style docstring including Args (describe parameters and their types) and Returns (return type and description), and add missing type hints to the _format_finding_md signature and any parameters mentioned in the docstring (e.g., the finding dict parameter and returned str), so the docstring and signature match; ensure the docstring briefly documents parameter types and what the formatted markdown string contains.
🤖 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 `@src/cicaddy/delegation/summarizer.py`:
- Around line 145-147: The current rendering appends raw existing_code inside
triple-backtick fences (see existing_code and parts.append usage in
summarizer.py), which breaks Markdown if the snippet contains ```; update the
logic to choose a fence that doesn't appear in the snippet (e.g., use "```" by
default and switch to "````" or a longer fence when the snippet contains the
default fence), trim the snippet once, then append using the chosen fence for
both opening and closing so the fenced code block cannot be prematurely
terminated by content inside existing_code.
---
Outside diff comments:
In `@src/cicaddy/delegation/summarizer.py`:
- Around line 507-519: The current bucket logic in summarizer.py stores findings
by raw sev (variable sev) but the rendering loop only iterates
("critical","major","minor","nit"), so any finding with an unexpected severity
is lost; update the rendering to include a fallback bucket or dynamically render
any remaining keys in severity_groups after the known-order pass (e.g., build an
ordered list: the known severities in that order, then append
sorted(severity_groups.keys() - set(known))) and iterate that list when building
parts/finding_num so all findings (variables: findings, severity_groups, sev,
parts, finding_num) are included in the synthesized summary.
---
Nitpick comments:
In `@src/cicaddy/delegation/summarizer.py`:
- Around line 129-134: The function _format_finding_md has a plain docstring;
update it to a Google-style docstring including Args (describe parameters and
their types) and Returns (return type and description), and add missing type
hints to the _format_finding_md signature and any parameters mentioned in the
docstring (e.g., the finding dict parameter and returned str), so the docstring
and signature match; ensure the docstring briefly documents parameter types and
what the formatted markdown string contains.
🪄 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: defaults
Review profile: CHILL
Plan: Pro
Run ID: 87c58e43-1577-4b1e-a601-caf467766350
📒 Files selected for processing (2)
src/cicaddy/delegation/summarizer.pytests/unit/test_delegation_summarizer.py
- Fix leading newline when finding has no file path - Use ~~~ fences when existing_code contains backticks - Map unknown severities (high/medium/low/error) to canonical values - Fix heading hierarchy: ## section → ### finding (was ####) - Add edge case tests for all fixes (90 tests total) Signed-off-by: Wayne Sun <gsun@redhat.com>
|



Summary
_SUMMARY_RULESprompt to produce emoji severity headings (### 🟠 Major (2)), numbered lists, bold file paths (**\file`**`), inline suggestions, and Overall Assessment footer_format_finding_mdfallback: bold file paths, removeexisting_coderendering (stays in findings dict only), inline suggestions_unpack_bare_arrayfallback: emoji headings, numbered listsTest plan
uv run pytest tests/unit/test_delegation_summarizer.py -q— 85 passed### 🟠 Major (2),### 🟡 Minor (1),### 🔵 Nit (1)headings, numbered items, bold file paths, and Overall Assessment in review bodySummary by CodeRabbit
Style
Tests