perf(lockfile-stats): enforce single-script cached analysis to cut token/turn cost#31415
Merged
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
…rompt Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Optimize lockfile stats to reduce token usage
perf(lockfile-stats): enforce single-script cached analysis to cut token/turn cost
May 11, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors the lockfile-stats workflow prompt to enforce a bounded, cache-first analysis flow that avoids repeated raw lockfile reads and constrains bash turns/tokens.
Changes:
- Adds a strict performance contract (effective token + bash turn ceilings and a stop/noop fallback).
- Requires a single first-turn analyzer script run that writes a compact JSON summary for downstream reasoning.
- Defines cache-memory/script versioning and optional historical delta reporting from cached summaries.
Show a summary per file
| File | Description |
|---|---|
.github/workflows/lockfile-stats.md |
Replaces the open-ended, multi-phase instructions with a single-script cached JSON analysis flow + explicit runtime budgets. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 1/1 changed files
- Comments generated: 2
| Analyze all .lock.yml files in the `.github/workflows/` directory to identify usage patterns, popular triggers, safe outputs, step sizes, and other interesting structural characteristics. Generate comprehensive statistical reports and publish findings to the "audits" discussion category. | ||
| - Target **effective tokens ≤ 1M** (the sum of input and output tokens as reported by the engine usage metrics for this workflow run). | ||
| - Use **≤ 5 bash turns total** (each bash command execution counts as one turn). | ||
| - If you are about to exceed either limit, call the `noop` safe-output action exposed by the runtime import (`{{#runtime-import shared/noop-reminder.md}}`) with a short reason and stop. Do not create a discussion in that case. |
Comment on lines
+72
to
75
| ### 2) Second turn: read summary JSON only | ||
|
|
||
| Analyze the collected data to generate insights: | ||
| Read only `/tmp/gh-aw/agent/lockfile-stats-summary.json` and derive insights from it. | ||
|
|
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
The
lockfile-statsworkflow prompt was driving high-cost runs (11–15M tokens, 51 bash turns) by repeatedly reading raw lock YAML across hundreds of files. This change reshapes the prompt into a bounded, cache-first analysis flow targeting ≤1M tokens and ≤5 bash turns using compact JSON summaries.What does this improve?
/tmp/gh-aw/agent/lockfile-stats-summary.jsononly.noopfallback).Why is this valuable?
Implementation approach:
.github/workflows/lockfile-stats.mdto define:effective tokens, bash-turn counting, budget stop condition),lockfile_stats_v1.py, version bump rules),