Repository navigation
Description
Target Workflow
Copilot cloud agent — the highest-token agentic workflow in this repository (150,233 tokens across 30 runs per last audit), selected as the primary optimization target. No "Token"-excluded and not recently optimized with complete data.
Analysis period: 2026-05-05 – 2026-05-14 | Runs analyzed: 20
Token Profile
| Metric | Value |
|---|---|
| Runs analyzed | 20 |
| Successful / Cancelled | 18 / 2 (10% cancellation rate) |
| Avg run duration | 3.3 min |
| Avg processing time | ~2.0 – 9.4 min (wide spread) |
| Estimated avg tokens/run | ~5,008 (from 30-run audit: 150,233 total) |
| Cancellation waste | ~2 × 5,008 ≈ 10,016 tokens wasted |
| Setup overhead (smoke test + validate) | ~7–9 s/run |
Ranked Recommendations
1. 🔴 Suppress rapid re-triggers on the same PR (Est. savings: ~500–2,500 tokens/day on active review cycles)
Evidence: On 2026-05-05, PR #9 alone triggered 6 consecutive agent runs between 07:22–08:01 UTC, with 2 cancellations (runs §25364643611 and §25362630400 cancelled). PR #10 triggered 2 additional runs. This pattern – multiple comments or pushes on a PR firing sequential agent runs before previous ones complete – is the primary source of both wasted tokens and cancellations.
Action: Add a concurrency group to the Copilot cloud agent invocation configuration to cancel in-progress runs for the same PR when a new trigger arrives, or add a debounce delay so that rapid successive triggers (within 60–90 s of each other) consolidate into a single agent run.
concurrency:
group: copilot-agent-${{ github.event.issue.number || github.event.pull_request.number }}
cancel-in-progress: trueThis would have eliminated ~4 redundant runs on May 5 alone, saving an estimated 20,000 tokens that day.
2. 🟡 Cache or skip smoke-test compilation on every agent invocation (Est. savings: ~7–9 s setup overhead per run, negligible tokens)
Evidence: copilot-setup-steps.yml runs gh aw add ... && gh aw compile --validate on every Copilot agent invocation (step "Smoke test published workflows via gh aw add": 7 s on recent runs). This compiles the two token-audit/optimizer workflows into a temp directory every time, regardless of whether those workflows have changed.
Action: Gate the smoke-test step with a condition, or move it to only run on changes to copilot-setup-steps.yml (which already triggers via push: paths). Consider caching the gh aw compile output using actions/cache keyed on the workflow source hash to skip redundant compilation.
References: §25846852022, §25813362645
3. 🟡 Investigate high-variance processing times (Est. savings: 500–2,000 tokens on long-tail runs)
Evidence: Processing Request times ranged from 113 s (1.9 min) to 563 s (9.4 min) across observed runs — a 5× spread. Long runs correlate with complex PR contexts (many comments, large diffs).
Action: Review whether the agent is loading unnecessary context (full repository history, all PR comments) on every invocation. Add instructions to limit context to the last N comments (e.g., last 5) and to only read directly changed files. This is the highest-leverage lever for token reduction since it acts on every turn in long sessions.
Caveats
- Token counts are estimated from a 30-run rolling audit (150,233 total); per-run breakdowns are not available in the current pre-downloaded data.
- Cancellation savings are conservative — cancelled runs may have consumed 0–100% of a full run's tokens depending on when they were cancelled.
- Recommendation 1 (concurrency) requires verifying that the Copilot cloud agent's invocation workflow supports concurrency groups.
- Only 20 runs were analyzed; the May 5 PR review spike may not be representative of typical usage.
Run log detail (20 runs)
| Run ID | Date | Title | Conclusion | Duration |
|---|---|---|---|---|
| 25846852022 | 2026-05-14 | Running Copilot cloud agent | success | 6.8 min |
| 25813362645 | 2026-05-13 | Running Copilot cloud agent | success | 6.6 min |
| 25693808119 | 2026-05-11 | Running Copilot cloud agent | success | 2.9 min |
| 25542080565 | 2026-05-08 | Running Copilot cloud agent | success | 9.8 min |
| 25539679417 | 2026-05-08 | Running Copilot cloud agent | success | 5.1 min |
| 25390013866 | 2026-05-05 | Addressing comment on PR #12 | success | 2.2 min |
| 25389809805 | 2026-05-05 | Running Copilot cloud agent | success | 2.4 min |
| 25375860097 | 2026-05-05 | Running Copilot cloud agent | success | 1.2 min |
| 25371284600 | 2026-05-05 | Running Copilot cloud agent | success | 4.7 min |
| 25371147233 | 2026-05-05 | Running Copilot cloud agent | success | 2.0 min |
| 25365534961 | 2026-05-05 | Running Copilot cloud agent | success | 2.4 min |
| 25364781713 | 2026-05-05 | Addressing comment on PR #9 | success | 0.9 min |
| 25364643611 | 2026-05-05 | Addressing comment on PR #9 | cancelled | 2.5 min |
| 25364288988 | 2026-05-05 | Addressing comment on PR #9 | success | 1.4 min |
| 25363753741 | 2026-05-05 | Addressing comment on PR #9 | success | 3.1 min |
| 25363409308 | 2026-05-05 | Addressing comment on PR #9 | success | 5.0 min |
| 25363287279 | 2026-05-05 | Addressing comment on PR #9 | success | 1.9 min |
| 25362630400 | 2026-05-05 | Addressing comment on PR #10 | cancelled | 0.5 min |
| 25362178014 | 2026-05-05 | Addressing comment on PR #10 | success | 2.2 min |
| 25361878172 | 2026-05-05 | Running Copilot cloud agent | success | 3.0 min |
Generated by Copilot Token Usage Optimizer · ● 9.4M · ◷
- expires on May 21, 2026, 8:47 AM UTC
Activity
github-actions commentedon May 14, 2026
This issue is being closed as outdated. A newer issue has been created: #29
View newer issue
This action was performed automatically by the
Copilot Token Usage Optimizerworkflow.