Skip to content

fix(agents): make the optimizer recursion guard actually correlate runs - #2993

Merged
stranske merged 3 commits into
mainfrom
fix/optimizer-recursion-guard-match
Aug 8, 2026
Merged

fix(agents): make the optimizer recursion guard actually correlate runs#2993
stranske merged 3 commits into
mainfrom
fix/optimizer-recursion-guard-match

Conversation

@stranske

@stranske stranske commented Aug 8, 2026

Copy link
Copy Markdown
Owner

Source: Issue #464

Closes #464

Automated Status Summary

Scope

Address unmet acceptance criteria from PR #463.

Original scope:

  • After merging PR chore(codex): bootstrap PR for issue #101 #103 (multi-agent routing infrastructure), we need to:
    1. Validate the CLI agent pipeline works end-to-end with the new task-focused prompts
    1. Add GITHUB_STEP_SUMMARY output so iteration results are visible in the Actions UI
    1. Streamline the Automated Status Summary to reduce clutter when using CLI agents
    1. Clean up comment patterns to avoid a mix of old UI-agent and new CLI-agent comments

Context for Agent

Related Issues/PRs

Tasks

  • After PR chore(codex): bootstrap PR for issue #101 #103 merges, create a test PR with agent:codex label
  • Verify task appendix appears in Codex prompt (check workflow logs)
  • Verify Codex works on actual tasks (not random infrastructure work)
  • Verify keepalive comment updates with iteration progress
  • Add step summary output to agents-keepalive-loop.yml after agent run
  • Include: iteration number, tasks completed, files changed, outcome
  • Ensure summary is visible in workflow run UI
  • Modify buildStatusBlock() in agents_pr_meta_update_body.js to accept agentType parameter
  • When agentType is set (CLI agent): hide workflow table, hide head SHA/required checks
  • Keep Scope/Tasks/Acceptance checkboxes for all cases
  • Pass agent type from workflow to the update_body job
  • For CLI agents (agent:* label):
  • Suppress <!-- gate-summary: --> comment posting (use step summary instead)
  • Suppress <!-- keepalive-round: N --> instruction comments (task appendix replaces this)
  • Update <!-- keepalive-loop-summary --> to be the single source of truth
  • Ensure state marker is embedded in the summary comment (not separate)
  • For UI Codex (no agent:* label):
  • Keep existing comment patterns (instruction comments, connector bot reports)
  • Keep <!-- gate-summary: --> comment
  • Add agent_type output to detect job so downstream workflows know the mode
  • Update agents-pr-meta.yml to conditionally skip gate summary for CLI agent PRs

Acceptance criteria

  • CLI agent receives explicit tasks in prompt and works on them
  • CLI agent PRs have ≤3 bot comments total (summary, one per iteration update) instead of 10+
  • Requires PR chore(codex): bootstrap PR for issue #101 #103 to be merged first

Head SHA: c49feee
Latest Runs: ✅ success — Gate
Required: gate: ✅ success

Workflow / Job Result Logs
Gate ✅ success View run
Health 40 Sweep ✅ success View run
Health 44 Gate Branch Protection ❔ action required View run
Health 45 Agents Guard ✅ success View run
Health 50 Security Scan ✅ success View run
Health 51 Actions SAST (zizmor) ✅ success View run
Health 52 Semgrep Scan ✅ success View run
Health 69 Consumer Sync Shadow Evidence ✅ success View run
Health 73 Template Completeness ✅ success View run
Health 74 Template Drift ✅ success View run
Maint 52 Validate Workflows ✅ success View run
PR 11 - Minimal invariant CI ✅ success View run
PR 46 Dependency Repair Contract ⏭️ skipped View run
Selftest CI ✅ success View run
Validate Sync Manifest ✅ success View run

The guard counts prior optimizer runs for an issue by matching the issue
number against `displayTitle`. workflow_dispatch runs display the bare
workflow name ("Agents Issue Optimizer"), so the filter matched nothing.

Observed on Fine-Art-Archive#464, which the optimizer re-ran roughly once a
minute for ~20 hours while its own guard logged:

    Optimizer runs for issue #464 in last hour: 0

Set `run-name` so both trigger types carry `#<issue>`, raise the `gh run
list` window past its 20-run default (a tight loop exhausts that inside the
hour), and match with `endswith` rather than `contains` so the new suffix
form cannot count #4640 against #464.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings August 8, 2026 23:15
@cursor

cursor Bot commented Aug 8, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 19 minutes

Your organization has reached its usage spending cap. Adjust your spending cap in the billing tab.

How can I continue?

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.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 046f8ff8-5632-494a-a84c-6b50b4707560

📥 Commits

Reviewing files that changed from the base of the PR and between c251301 and c49feee.

📒 Files selected for processing (3)
  • .github/workflows/agents-issue-optimizer.yml
  • config/template-drift-allowlist.txt
  • templates/consumer-repo/.github/workflows/agents-issue-optimizer.yml

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

@agents-workflows-bot

agents-workflows-bot Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Automated Status Summary

Head SHA: 839396e
Latest Runs: ⏳ pending — Gate
Required contexts: summary
Required: core tests (3.12): ⏳ pending, core tests (3.13): ⏳ pending, docker smoke: ⏳ pending, gate: ⏳ pending

Workflow / Job Result Logs
(no jobs reported) ⏳ pending

Coverage Overview

  • Coverage history entries: 0

Updated automatically; will refresh on subsequent CI/Docker completions.


Keepalive checklist

Scope

Address unmet acceptance criteria from PR #463.

Original scope:

  • After merging PR chore(codex): bootstrap PR for issue #101 #103 (multi-agent routing infrastructure), we need to:
    1. Validate the CLI agent pipeline works end-to-end with the new task-focused prompts
    1. Add GITHUB_STEP_SUMMARY output so iteration results are visible in the Actions UI
    1. Streamline the Automated Status Summary to reduce clutter when using CLI agents
    1. Clean up comment patterns to avoid a mix of old UI-agent and new CLI-agent comments

Context for Agent

Related Issues/PRs

Tasks

  • After PR chore(codex): bootstrap PR for issue #101 #103 merges, create a test PR with agent:codex label
  • Verify task appendix appears in Codex prompt (check workflow logs)
  • Verify Codex works on actual tasks (not random infrastructure work)
  • Verify keepalive comment updates with iteration progress
  • Add step summary output to agents-keepalive-loop.yml after agent run
  • Include: iteration number, tasks completed, files changed, outcome
  • Ensure summary is visible in workflow run UI
  • Modify buildStatusBlock() in agents_pr_meta_update_body.js to accept agentType parameter
  • When agentType is set (CLI agent): hide workflow table, hide head SHA/required checks
  • Keep Scope/Tasks/Acceptance checkboxes for all cases
  • Pass agent type from workflow to the update_body job
  • For CLI agents (agent:* label):
  • Suppress <!-- gate-summary: --> comment posting (use step summary instead)
  • Suppress <!-- keepalive-round: N --> instruction comments (task appendix replaces this)
  • Update <!-- keepalive-loop-summary --> to be the single source of truth
  • Ensure state marker is embedded in the summary comment (not separate)
  • For UI Codex (no agent:* label):
  • Keep existing comment patterns (instruction comments, connector bot reports)
  • Keep <!-- gate-summary: --> comment
  • Add agent_type output to detect job so downstream workflows know the mode
  • Update agents-pr-meta.yml to conditionally skip gate summary for CLI agent PRs

Acceptance criteria

  • CLI agent receives explicit tasks in prompt and works on them
  • CLI agent PRs have ≤3 bot comments total (summary, one per iteration update) instead of 10+
  • Requires PR chore(codex): bootstrap PR for issue #101 #103 to be merged first

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 24b65c3c64

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +7 to +9
run-name: >-
Agents Issue Optimizer #${{
github.event.issue.number || inputs.issue_number }}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Apply the recursion guard fix to the consumer template

This changes only the Workflows-local copy, but the manifest compiler's workflow ownership policy selects templates/consumer-repo/.github/workflows/agents-issue-optimizer.yml for consumer sync; that template still lacks run-name, uses the 20-run default, and filters with contains. Consequently, the sync workflow will continue distributing the ineffective recursion guard to Fine-Art-Archive and the other consumers, leaving the runaway loop this commit targets unfixed there. Mirror these changes into the consumer template before syncing.

AGENTS.md reference: AGENTS.md:L60-L66

Useful? React with 👍 / 👎.

Copilot AI 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.

Pull request overview

This PR aims to make the issue-optimizer recursion guard actually count prior runs for a given issue by ensuring workflow runs are correlatable via displayTitle and by tightening the match logic to avoid false positives.

Changes:

  • Adds run-name to include #<issue> so workflow_dispatch runs can be correlated via displayTitle.
  • Updates the recursion-guard run correlation from contains($issue) to endswith($issue) to avoid counting #4640 as #464.
  • Increases gh run list history to --limit 100 so tight-loop scenarios aren’t truncated by the 20-run default.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +7 to +9
run-name: >-
Agents Issue Optimizer #${{
github.event.issue.number || inputs.issue_number }}
Comment on lines +152 to +156
# window; ask for enough history to actually see the recursion.
# shellcheck disable=SC2016
count=$(gh run list \
--workflow=agents-issue-optimizer.yml \
--limit 100 \
…r template

Check Template Drift flagged agents-issue-optimizer.yml as unallowlisted:
the root copy carried the fix and the consumer template did not. The template
is the copy the fleet's 13 consumer repos actually run, so it needs the same
run-name, endswith match, and --limit 100.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@stranske
stranske temporarily deployed to agent-high-privilege August 8, 2026 23:26 — with GitHub Actions Inactive
Both surfaces changed in this branch, so the stored pair.11 fingerprints no
longer match and the drift check reported unallowlisted content. Refresh both
hashes and record this round's shared contract in the reason, per the file's
existing re-baseline convention.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@stranske
stranske temporarily deployed to agent-high-privilege August 8, 2026 23:28 — with GitHub Actions Inactive
@stranske
stranske merged commit 54d8b9e into main Aug 8, 2026
230 of 235 checks passed
@stranske
stranske deleted the fix/optimizer-recursion-guard-match branch August 8, 2026 23:35
@stranske

stranske commented Aug 9, 2026

Copy link
Copy Markdown
Owner Author

Closer audit: this PR's only closing reference is long-closed #464 (closed 2026-01-03); its unresolved acceptance checklist is unrelated to this optimizer-recursion-guard diff. No durable verifier label is being applied against that stale source. Owner decision needed: identify the correct source issue, or authorize this as a no-source maintenance disposition; then the closer can route/verify it safely.

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.

[Follow-up] Unmet criteria from PR #463

3 participants