You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Added pre-agent step Pre-fetch PR diff (truncated) that caps the diff at 8 000 lines before the agent starts — prevents huge diffs from inflating the context window on every turn
Updated Step 1 in the prompt to read the pre-fetched file instead of re-running gh pr diff
Expected Improvements
Test Quality Sentinel: worst-case token spend reduced by ~63% (40 → 15 continuation cap)
Matt Pocock Reviewer: large-PR scenarios bounded; diff no longer re-fetched live inside the agent loop
Contribution Check: runaway protection added; cost capped even if subagent retry loops occur
Validation
All modified workflows compiled successfully:
✅ test-quality-sentinel
✅ contribution-check
✅ mattpocock-skills-reviewer
Note: .lock.yml files will be regenerated automatically after merge.
References
Log analysis: run IDs 25686395186, 25686664431, 25686664489
The bundle file is available in the agent artifact in the workflow run linked above.
To create a pull request with the changes:
# Download the artifact from the workflow run
gh run download 25688146365 -n agent -D /tmp/agent-25688146365
# Fetch the bundle into a local branch
git fetch /tmp/agent-25688146365/aw-q-optimize-token-usage.bundle refs/heads/q/optimize-token-usage:refs/heads/q/optimize-token-usage-20fef7476b3af908
git checkout q/optimize-token-usage-20fef7476b3af908
# Push the branch to origin
git push origin q/optimize-token-usage-20fef7476b3af908
# Create the pull request
gh pr create --title '[q] optimize: reduce token usage in high-consumption workflows' --base main --head q/optimize-token-usage-20fef7476b3af908 --repo github/gh-aw
Q Workflow Optimization Report
Issues Found (from live data)
Contribution Check
timeout-minutes— could run unboundedly if subagent dispatch stallsmax-continuationscap — orchestrator + 3 subagent calls = 24 turns, no hard ceilingMatt Pocock Skills Reviewer
max-continuationscap for Copilot enginegh pr diffinline — large PRs produce multi-thousand-line diffs fed directly into the context windowTest Quality Sentinel
max-continuations: 40is 5-6× the observed run length (7 turns) — allows significant cost overrun on adversarial or complex PRsChanges Made
test-quality-sentinel.mdmax-continuationsfrom 40 → 15 (2× the observed maximum of 7 turns, still provides comfortable headroom)contribution-check.mdmax-continuations: 60(covers 3× subagent runs of ~20 turns each)timeout-minutes: 30(hard wall to prevent runaway on retry loops)mattpocock-skills-reviewer.mdengine: copilot→engine: {id: copilot, max-continuations: 15}gh pr diffExpected Improvements
Validation
All modified workflows compiled successfully:
test-quality-sentinelcontribution-checkmattpocock-skills-reviewerReferences
Log analysis: run IDs 25686395186, 25686664431, 25686664489
Triggered by:
/q optimize token usageon issue [Incident] Incident: github-pages deployment failure (run 25685733509) #31552Fixes [Incident] Incident: github-pages deployment failure (run 25685733509) #31552
Note
This was originally intended as a pull request, but the git push operation failed.
Workflow Run: View run details and download bundle artifact
The bundle file is available in the
agentartifact in the workflow run linked above.To create a pull request with the changes: