optimize: reduce token usage in three high-consumption workflows#31582
Merged
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Optimize token usage in high-consumption workflows
optimize: reduce token usage in three high-consumption workflows
May 11, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Reduces worst-case token consumption in three high-usage agentic workflows by capping continuation loops and removing redundant live GitHub API calls from inside an agent loop.
Changes:
- Add/adjust
engine.max-continuationsceilings fortest-quality-sentinel,mattpocock-skills-reviewer, andcontribution-check. - Add a
pre-agent-stepsPR prefetch step tomattpocock-skills-reviewerthat writes PR metadata + full diff to/tmp/gh-aw/agent/, and update the prompt to read those files instead of callinggh pr view/diff. - Regenerate
.lock.ymlfiles and update action pin data to includegithub/gh-aw-actions/setup@v0.71.5.
Show a summary per file
| File | Description |
|---|---|
| pkg/workflow/data/action_pins.json | Adds pin entry for github/gh-aw-actions/setup@v0.71.5 to support compiled workflow actions. |
| pkg/actionpins/data/action_pins.json | Mirrors the same new action pin in the actionpins package dataset. |
| .github/workflows/test-quality-sentinel.md | Lowers Copilot continuation ceiling to reduce worst-case runaway cost. |
| .github/workflows/test-quality-sentinel.lock.yml | Regenerated compilation output reflecting new continuation cap (--max-autopilot-continues 15). |
| .github/workflows/mattpocock-skills-reviewer.md | Adds max-continuations: 10 and prefetches PR diff/meta before the agent; prompt updated to read local files. |
| .github/workflows/mattpocock-skills-reviewer.lock.yml | Regenerated compilation output including new prefetch step and continuation cap (--max-autopilot-continues 10). |
| .github/workflows/issue-arborist.lock.yml | Regenerated compilation output (includes Codex harness argument formatting updates). |
| .github/workflows/contribution-check.md | Adds max-continuations: 20 to cap Copilot continuations at the engine level. |
| .github/workflows/contribution-check.lock.yml | Regenerated compilation output reflecting the new continuation cap (--max-autopilot-continues 20). |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 9/9 changed files
- Comments generated: 0
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.
✨ Enhancement
Three workflows were identified (via run IDs 25686395186, 25686664431, 25686664489) as disproportionately high token consumers due to uncapped continuation loops and live API calls inside the agent loop.
What does this improve?
test-quality-sentinel—max-continuations: 40 → 15(~63% worst-case reduction)mattpocock-skills-reviewer— addsmax-continuations: 10; PR diff and metadata are now pre-fetched into/tmp/gh-aw/agent/before the agent starts, eliminating redundant livegh pr diff/gh pr viewcalls inside the loopcontribution-check— addsmax-continuations: 20as a hard engine-level cap, complementing the existing 50-turn soft limit in the prompt to guard against subagent retry runawayImplementation approach:
mattpocock-skills-reviewer: newPre-fetch PR diffpre-agent step writespr-diff.patch+pr-meta.jsonto disk; Step 1 of the agent prompt updated to read these files instead of making API callsmax-continuationsceilings.lock.ymlfiles auto-regenerated; all three workflows compile with 0 errors