Skip to content

feat(retro): add flapping detection to retro analysis skill (#5512)#5513

Open
Benkapner wants to merge 2 commits into
fullsend-ai:mainfrom
Benkapner:feat/retro-flapping-detection
Open

feat(retro): add flapping detection to retro analysis skill (#5512)#5513
Benkapner wants to merge 2 commits into
fullsend-ai:mainfrom
Benkapner:feat/retro-flapping-detection

Conversation

@Benkapner

Copy link
Copy Markdown
Contributor

Summary

Adds flapping detection guidance to the retro-analysis skill. The retro agent now knows how to identify fix-break oscillation patterns during its post-workflow analysis.

What it adds to the skill

  • File oscillation detection: check if the same files were changed and reverted across consecutive agent runs
  • Test result flipping: detect tests that pass/fail/pass across runs
  • Cycle count threshold: flag more than 2 review-fix cycles without convergence
  • Concrete bash commands for comparing diffs between runs
  • Proposal guidance: how to structure a flapping finding (title format, evidence, suggested intervention)
  • False positive guard: single rework cycles and different-file changes are explicitly excluded

Why this matters

Flapping wastes agent cycles and often indicates a deeper problem (conflicting instructions, flaky tests, or an approach the agent cannot converge on). Today, the retro agent has no specific guidance to detect this pattern, even though the flapping-convergence problem doc identifies it as a key concern.

Related Issue

Closes #5512

Testing

  • Docs-only change to an existing skill (no code/lint/test changes required)
  • Section integrates with existing skill structure (placed before the "Before proposing" section)
  • Follows the skill's existing pattern of providing bash commands and subagent prompts

Checklist

  • PR title follows Conventional Commits
  • Commits are signed off (DCO)

…-ai#5512)

Add a "Flapping detection" section to the retro-analysis skill that
teaches the retro agent how to identify fix-break oscillation patterns:
file-level oscillation (same files changed and reverted across runs),
test result flipping, and excessive review-fix cycles.

Includes concrete signals to check, bash commands for diff comparison,
guidance on when to flag vs when NOT to flag (single rework is normal),
and how to structure proposals when flapping is detected.

Signed-off-by: Benjamin Kapner <bkapner@redhat.com>
@Benkapner
Benkapner requested a review from a team as a code owner July 23, 2026 08:49
@github-actions

Copy link
Copy Markdown

E2E tests did not run

E2E tests run automatically for org/repo members and collaborators on pull requests.

For other contributors, a maintainer must add the ok-to-test label after the latest push.

See E2E testing guide for details.

1 similar comment
@github-actions

Copy link
Copy Markdown

E2E tests did not run

E2E tests run automatically for org/repo members and collaborators on pull requests.

For other contributors, a maintainer must add the ok-to-test label after the latest push.

See E2E testing guide for details.

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Add flapping detection guidance to retro-analysis skill

📝 Documentation 🕐 10-20 Minutes

Grey Divider

AI Description

• Add a "Flapping detection" section to retro-analysis guidance.
• Document file/test oscillation signals and excessive review-fix cycle thresholds.
• Provide bash commands, proposal template fields, and false-positive guards.
Diagram

graph TD
  A["Retro agent"] --> B["Subagent: gather runs"] --> C["Run artifacts"] --> D{"Flapping signals"} --> E["Proposal guidance"] --> F["Existing issues check"]
  C --> G["CI results"] --> D
  subgraph Legend
    direction LR
    _proc["Process step"] ~~~ _data["Data/artifact"] ~~~ _dec{"Decision"}
  end
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Add a small helper script/gh alias for oscillation detection
  • ➕ Reduces manual steps and makes detection more repeatable across retros
  • ➕ Can compute overlaps/reverts across multiple runs more reliably than ad-hoc commands
  • ➖ Introduces maintenance surface area beyond the skill doc
  • ➖ May require decisions about where the script lives and how it’s distributed
2. Implement first-class flapping detection in the retro agent/harness
  • ➕ Most reliable: can automatically inspect run graph, diffs, and CI outcomes
  • ➕ Enables consistent thresholds and structured evidence generation
  • ➖ Higher effort and risk than a docs-only change
  • ➖ Requires tighter coupling to workflow/run metadata sources and permissions

Recommendation: For the stated goal (teach the retro agent what to look for), the docs-first approach in this PR is the right lowest-friction improvement. If flapping findings become common, follow up with automation (script or harness support) to make detection deterministic and less labor-intensive.

Files changed (1) +44 / -0

Documentation (1) +44 / -0
SKILL.mdDocument flapping detection signals, commands, and proposal format +44/-0

Document flapping detection signals, commands, and proposal format

• Adds a dedicated "Flapping detection" section describing how to identify fix-break oscillation via file-level reversions, test pass/fail flipping, and excessive review-fix cycles. Includes concrete bash commands for comparing changed files across runs plus guidance on how to structure a flapping proposal and when not to flag.

internal/scaffold/fullsend-repo/skills/retro-analysis/SKILL.md

@github-actions

github-actions Bot commented Jul 23, 2026

Copy link
Copy Markdown

Site preview

Preview: https://4aebfafa-site.fullsend-ai.workers.dev

Commit: 8113425f65bfdaf571eb929338e4592fce4db5c8

@qodo-code-review

qodo-code-review Bot commented Jul 23, 2026

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (0) 📜 Skill insights (0)

Context used
✅ Compliance rules (platform): 61 rules

Grey Divider


Remediation recommended

1. PR files API unpaginated ✓ Resolved 🐞 Bug ≡ Correctness
Description
The snippet calls the PR files endpoint without pagination, so it can return an incomplete file list
on larger PRs. That incomplete list undermines file-oscillation detection by omitting files that may
have been changed repeatedly.
Code

internal/scaffold/fullsend-repo/skills/retro-analysis/SKILL.md[R117-118]

+gh api "repos/$REPO_FULL_NAME/pulls/$PR_NUMBER/files" \
+  --jq '.[].filename' | sort > /tmp/current_files.txt
Relevance

⭐⭐⭐ High

Repo has accepted adding --paginate/error handling for PR files listing to avoid incomplete
file-based decisions.

PR-#2398
PR-#337

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The new section uses a non-paginated PR files listing, while other in-repo guidance/workflows
explicitly paginate PR file retrieval to avoid missing files; this discrepancy indicates the new
snippet is likely to be incomplete in real use.

internal/scaffold/fullsend-repo/skills/retro-analysis/SKILL.md[115-125]
internal/scaffold/fullsend-repo/agents/review.md[181-196]
.github/workflows/e2e.yml[121-139]
PR-#2398

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
The example `gh api` call to list PR files is not paginated, so it may omit files and weaken oscillation detection.

### Issue Context
Other repo guidance and workflows consistently use `--paginate` and/or `?per_page=100` when fetching PR files.

### Fix Focus Areas
- internal/scaffold/fullsend-repo/skills/retro-analysis/SKILL.md[117-118]

### Suggested change
- Update the snippet to fetch all pages, e.g.:
 - `gh api "repos/$REPO_FULL_NAME/pulls/$PR_NUMBER/files" --paginate --jq '.[].filename' ...`
 - (Optionally) include a short note that API failures should be surfaced (don’t treat an empty list as authoritative).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Run diff comparison wrong 🐞 Bug ≡ Correctness
Description
The flapping-detection snippet compares the full PR file list against git diff HEAD~1 HEAD, which
is not a comparison between consecutive code/fix runs and only yields filename overlap (not reversed
changes). This can cause the retro agent to miss real oscillations or generate false flapping
candidates that aren’t tied to specific run-to-run transitions.
Code

internal/scaffold/fullsend-repo/skills/retro-analysis/SKILL.md[R115-125]

+```bash
+# Compare diffs between consecutive code/fix runs
+gh api "repos/$REPO_FULL_NAME/pulls/$PR_NUMBER/files" \
+  --jq '.[].filename' | sort > /tmp/current_files.txt
+
+# Get previous run's changed files from the commit before
+git diff --name-only HEAD~1 HEAD | sort > /tmp/prev_files.txt
+
+# Files changed in both runs (potential oscillation)
+comm -12 /tmp/prev_files.txt /tmp/current_files.txt
+```
Relevance

⭐⭐⭐ High

Team favors comparing specific SHAs/ranges for run-to-run diffs; has accepted similar diff-range
correctness fixes.

PR-#2617
PR-#337

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The added snippet intersects a PR-wide file list with only the latest commit’s file list, which
can’t represent consecutive run transitions and doesn’t demonstrate reversal. Elsewhere in this
repo, comparing changes between two specific SHAs via the GitHub compare API is the established
pattern for run-to-run comparisons and includes safeguards for compare limitations.

internal/scaffold/fullsend-repo/skills/retro-analysis/SKILL.md[99-125]
internal/scaffold/fullsend-repo/skills/pr-review/SKILL.md[160-173]
PR-#2617

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
The current flapping-detection bash example doesn’t compare *consecutive code/fix runs* (it compares PR-wide files to the last commit), and it doesn’t provide a way to verify that changes were actually reversed.

### Issue Context
The section describes detecting oscillation between *runs* (run N vs run N+1), but the snippet uses `HEAD~1..HEAD` and PR-wide file listing, which is not run-scoped.

### Fix Focus Areas
- internal/scaffold/fullsend-repo/skills/retro-analysis/SKILL.md[115-125]

### Suggested direction
- Change the snippet to:
 - Use run-specific commit SHAs (e.g., from each run’s produced commit / PR head at the time) and compare consecutive SHAs via `gh api repos/$REPO_FULL_NAME/compare/<shaN>...<shaNplus1>` (or `git diff <shaN>..<shaNplus1>` if available locally).
 - Add an explicit step that checks *reversal* for candidate files (e.g., show `git diff <shaN>..<shaNplus1> -- <file>` and `git diff <shaNplus1>..<shaNplus2> -- <file>` to demonstrate add/remove reversal).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Qodo Logo

Comment on lines +115 to +125
```bash
# Compare diffs between consecutive code/fix runs
gh api "repos/$REPO_FULL_NAME/pulls/$PR_NUMBER/files" \
--jq '.[].filename' | sort > /tmp/current_files.txt

# Get previous run's changed files from the commit before
git diff --name-only HEAD~1 HEAD | sort > /tmp/prev_files.txt

# Files changed in both runs (potential oscillation)
comm -12 /tmp/prev_files.txt /tmp/current_files.txt
```

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remediation recommended

1. Run diff comparison wrong 🐞 Bug ≡ Correctness

The flapping-detection snippet compares the full PR file list against git diff HEAD~1 HEAD, which
is not a comparison between consecutive code/fix runs and only yields filename overlap (not reversed
changes). This can cause the retro agent to miss real oscillations or generate false flapping
candidates that aren’t tied to specific run-to-run transitions.
Agent Prompt
### Issue description
The current flapping-detection bash example doesn’t compare *consecutive code/fix runs* (it compares PR-wide files to the last commit), and it doesn’t provide a way to verify that changes were actually reversed.

### Issue Context
The section describes detecting oscillation between *runs* (run N vs run N+1), but the snippet uses `HEAD~1..HEAD` and PR-wide file listing, which is not run-scoped.

### Fix Focus Areas
- internal/scaffold/fullsend-repo/skills/retro-analysis/SKILL.md[115-125]

### Suggested direction
- Change the snippet to:
  - Use run-specific commit SHAs (e.g., from each run’s produced commit / PR head at the time) and compare consecutive SHAs via `gh api repos/$REPO_FULL_NAME/compare/<shaN>...<shaNplus1>` (or `git diff <shaN>..<shaNplus1>` if available locally).
  - Add an explicit step that checks *reversal* for candidate files (e.g., show `git diff <shaN>..<shaNplus1> -- <file>` and `git diff <shaNplus1>..<shaNplus2> -- <file>` to demonstrate add/remove reversal).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed. now compares consecutive commit SHAs instead of using HEAD~1.

Comment thread internal/scaffold/fullsend-repo/skills/retro-analysis/SKILL.md Outdated
@codecov

codecov Bot commented Jul 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Address review feedback:
- Compare consecutive commit SHAs instead of HEAD~1
- Add --paginate to gh api calls for PR files

Signed-off-by: Benjamin Kapner <bkapner@redhat.com>
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.

feat(retro): detect flapping and fix-break oscillation in retro analysis

1 participant