Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Feb 13, 2026

The bot-detection workflow was using single-page API calls (per_page: 100) for comments, reviews, and files, missing activity on noisy/abused PRs—exactly the scenario this detector should catch.

Changes

  • Replace single-page API calls with github.paginate: All four calls (issues.listComments, pulls.listReviewComments, pulls.listReviews, pulls.listFiles) now paginate with explicit 500-item cap for determinism

Implementation

let issueComments = [];
try {
  let total = 0;
  issueComments = await github.paginate(
    github.rest.issues.listComments,
    { owner, repo, issue_number: it.number, per_page: 100 },
    (response, done) => {
      const remaining = 500 - total;
      if (remaining <= 0) {
        done();
        return [];
      }
      if (total + response.data.length >= 500) {
        total = 500;
        done();
        return response.data.slice(0, remaining);
      }
      total += response.data.length;
      return response.data;
    }
  );
} catch {
  // ignore
}

The callback pattern ensures exact cap enforcement by calculating remaining capacity before each page, checking totals before updates, and slicing using the pre-calculated remaining value.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Update bot detection based on review feedback Add pagination to bot-detection API calls with 500-item cap Feb 13, 2026
Copilot AI requested a review from mnkiefer February 13, 2026 07:18
@mnkiefer mnkiefer marked this pull request as ready for review February 13, 2026 07:19
Copilot AI review requested due to automatic review settings February 13, 2026 07:19
@mnkiefer mnkiefer merged commit 3a1ebec into make-botd-agentic Feb 13, 2026
@mnkiefer mnkiefer deleted the copilot/sub-pr-15317 branch February 13, 2026 07:19
Copy link
Contributor

Copilot AI left a comment

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 updates the bot-detection workflow to reliably gather PR activity on high-volume PRs by switching from single-page REST calls to bounded pagination, ensuring the detector considers more complete comment/review/file data.

Changes:

  • Replace single-page GitHub API calls with github.paginate for PR issue comments, review comments, reviews, and file lists (capped at 500 items per call).
  • Regenerate the compiled workflow (bot-detection.lock.yml) to reflect the updated source workflow (bot-detection.md).
  • Includes unrelated changes: a Smoke Copilot cron minute adjustment and minor formatting/quote tweaks in a JS utility.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
.github/workflows/bot-detection.md Switches bot-detection API fetches to bounded pagination (500-item cap) for determinism on noisy PRs.
.github/workflows/bot-detection.lock.yml Regenerated compiled workflow reflecting the new pagination logic.
.github/workflows/smoke-copilot.lock.yml Changes the scheduled cron minute for the Smoke Copilot workflow (appears unrelated to bot-detection pagination).
actions/setup/js/merge_remote_agent_github_folder.cjs Minor formatting/quote changes in path validation logic.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +245 to +251
const remaining = 500 - total;
if (remaining <= 0) {
done();
return [];
}
if (total + response.data.length >= 500) {
total = 500;
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

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

The cap value 500 is hard-coded multiple times inside this pagination callback (and repeated across the other paginate calls). Consider defining a single constant (e.g., MAX_PAGINATE_ITEMS) and referencing it here to avoid inconsistencies if the cap ever changes, and to reduce duplicated magic numbers across the script.

Copilot uses AI. Check for mistakes.
Comment on lines 39 to 41
schedule:
- cron: "37 */12 * * *"
- cron: "46 */12 * * *"
workflow_dispatch: null
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

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

This PR is described as only adding pagination to bot-detection API calls, but it also changes the Smoke Copilot workflow schedule cron (and includes other unrelated edits in the diff). If this cron change is intentional, please update the PR description accordingly (or split into a separate PR). Also, since this is a generated *.lock.yml file, ensure the change is reproducible from the corresponding .md source via gh aw compile, otherwise it may get overwritten later.

Copilot uses AI. Check for mistakes.
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