optimize: stop paginating listWorkflowRuns once 24h cutoff is reached#38779
Draft
Copilot wants to merge 2 commits into
Draft
optimize: stop paginating listWorkflowRuns once 24h cutoff is reached#38779Copilot wants to merge 2 commits into
Copilot wants to merge 2 commits into
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
- Add early exit when a stale run is found (API returns newest-first), avoiding unnecessary page fetches and GitHub API calls - Remove dead countedRuns >= maxInspectableRuns guard in artifact loop - Replace verbose per-page runIds log (up to 100 IDs) with firstRunId/lastRunId - Add test proving pagination stops after the first stale run Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
pelikhan
June 12, 2026 04:35
View session
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The daily AIC guardrail was fetching up to 10 pages of workflow runs even when earlier pages already contained runs past the 24h window. Since
listWorkflowRunsreturns runs newest-first, encountering a stale run means all remaining runs on that page and every subsequent page are also outside the window.Changes
reachedCutoffflag that breaks both the inner and outer loops on the first run older than the cutoff, cutting up to 9 unnecessary API calls per guardrail invocation:countedRuns.length >= maxInspectableRunsin the artifact-inspection loop was unreachable;candidateRunsis already capped tomaxInspectableRunsby the time that loop runs.runIds: runs.map(...)(up to 100 IDs/page) withfirstRunId/lastRunId.listWorkflowRunscall and onegetRunAICcall.