[agentic-token-optimizer] PR Code Quality Reviewer: cut ~0.5 AIC/run (~22%) by bounding exploration and removing probe/retry calls
Mantenedores costumam responder em até 1 dia
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 2/5
- Tempo estimado
- 1-3 horas
- Facilidade para iniciantes
- 76/100
Direção de pesquisa
Comece por .github/workflows/pr-code-quality-reviewer.md, especialmente pelas etapas 1 e 2, pelas Guidelines e pelo bloco do agente grumpy-coder. Atualize o workflow com os limites indicados para a exploração e a leitura de diffs, remova padrões de sondagem e repetição de tentativas e alinhe o contrato de saída do subagente. O trabalho estará concluído quando o workflow refletir as recomendações; a issue não informa nenhum comando de teste.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
Target workflow
PR Code Quality Reviewer (.github/workflows/pr-code-quality-reviewer.md).
Selected because it is the highest-AIC workflow in the 7-day top list that is not excluded. Matt Pocock Skills Reviewer (optimized 2026-10-29) and Ponytail Reviewer (optimized 2026-11-02) were skipped under the 14-day rule. Last optimized for this workflow: 2026-10-07.
- Analysis period: 7 days ending 2026-11-10.
- Runs analyzed: 8 of 8, all
pull_request, allsuccess. - Data used:
run_summary.json,usage/aw_session.jsonlandtoken_usage.jsonlper run.
Cost profile
| Metric | Value |
|---|---|
| Total AIC | 17.81 |
| Avg AIC/run | 2.23 (range 1.28–3.79) |
| Raw tokens (input+output, as reported) | 102,595 |
| Cache read / write tokens | 2.96M / 0.33M |
| Cache efficiency (read ÷ total input-side) | ~89% (healthy) |
| Avg model requests/run | 16.1 (range 11–26) |
| Avg reported turns/run | 2.1 |
Main agent (gpt-5.6-luna) |
12.31 AIC (69%), 87 requests |
grumpy-coder sub-agent (claude-haiku-5.5) |
5.50 AIC (31%), 42 requests |
| Errors / missing tools / MCP failures | 0 / 0 / 0 |
Spend is driven by the number of requests per run, not by cache misses. The two most expensive runs, §42835312941 (3.79 AIC, 26 requests) and §42834275451 (3.64 AIC, 24 requests), cost about 1.8 AIC more than the 1.9 AIC median. Together that is ~3.6 AIC, ~20% of the week's total.
Ranked recommendations
1. Hard-bound additional exploration in Step 2 (est. −0.25 AIC/run)
Step 2 says "open at most 5 additional source files", but the limit is not enforced for grep/sed/view loops.
- §42835312941: 34
view+ 18grep+ 28bashcalls. 18 luna requests for one documentation finding. - §42834275451: 10 consecutive
bashgrep -rn/sed -ncalls acrosspkg/workflowandactions/, 32bashcalls in total. - The typical run, §42835636119, made 12
view/2grep/16bashcalls and cost 1.28 AIC.
Action: replace the Step 2 sentence with an explicit budget:
"Use at most 6 tool calls after reading the diff. One
grepcall may cover multiple symbols, and oneviewcall may cover multiple ranges or files. If a finding cannot be confirmed within the budget, drop it or mark it as unverified."
Also drop the # candidate findings = 10 stop condition in favour of "stop at 5 candidates". Reviews post 0–1 inline comments, so the cap of 10 is never useful.
2. Read the diff once, in one shape (est. −0.10 AIC/run)
The prompt says to view the diff, but runs fall back to cat, head -c, tail -c +22000 and split -l 90.
- §42835312941:
viewofpr-diff.patch×10, pluscat,head -c 22000,tail -c, andsplit. Oneview_rangecall failed with "out of bounds" and onesplitcall was denied. - §42835636119:
cat ... | head -c 60000.
Action: in Step 1, tell the agent to read the diff in one batched turn using view with explicit view_range slices of ~500 lines each. Use wc -l from pr-meta.json for the length. State "never split, head -c, or tail -c; they are not authorized and waste turns."
3. Stop probing and retrying safeoutputs and bash (est. −0.10 AIC/run)
- All 8 runs spend 1–3 requests on
safeoutputs --helpandsafeoutputs <tool> --help, even though the prompt already has the exact syntax. - 5 bash calls were denied in 3 of 8 runs. Each was a compound command (
cd ... ; ...,&&,2>/dev/null,split ..., an inline-argssafeoutputs ...), followed by a retry. - §42834684561 submitted
APPROVEfirst, whichallowed-eventsdoes not permit, then resubmitted asCOMMENT. - 2 of 8 runs call
noopafter already submitting the review.
Action:
- Add to Guidelines: "Do not run
--help. Do not combine commands withcd,;,&&or redirects. Useview/grep/globfor reads." - Add: "
eventmust beCOMMENTorREQUEST_CHANGES; neverAPPROVE." - Add: "Do not call
noopafter submitting the review."
Do not remove any tools. Every configured tool in the bash allowlist that was used succeeded at least once.
4. Bound the grumpy-coder sub-agent output (est. −0.15 AIC/run)
The sub-agent already uses a small model (haiku), so it is not worth removing. But it costs 31% of AIC, and output size is uneven: 12k–17k output tokens in 3 runs (§42835312941 14.6k, §42834328539 12.0k, §42834275451 17.0k, 11 requests) versus 2.3k–6.7k in the others. Those three runs averaged 1.30 AIC for haiku against 0.42 for the rest.
The main agent also overrides the sub-agent's declared output schema in its task prompt (severity: bug|risk|style, title, body, confidence) instead of the headline/impact/fix fields in the agent block, so the contract is not enforced.
Action: add to the ## agent: grumpy-coder block:
"Return at most 8 findings. Limit each field to 25 words. Use at most 8 tool calls; do not read files outside the diff unless needed to confirm a finding. Stop when done."
In Step 1, say: "Pass the sub-agent block's output schema unchanged; do not redefine fields in the task prompt."
Run §42835109949 also needed a write_agent nudge ("finish the review now") plus 4 read_agent calls. Specify one bounded read_agent with wait: true, and no repeat polling. Step 3 already says this.
5. Fix or drop the findings_scoped eval (reliability, no AIC estimate)
findings_scoped returned UNKNOWN in 8/8 runs, so it provides no signal. review_posted returned YES 8/8. The eval cannot determine scope from the output alone. Either reword it to something checkable from the review text (for example "Does every inline comment reference a path and line from the PR diff?") or remove it. The evals job also adds ~16–31 s of wall-clock per run.
Estimated savings
| # | Recommendation | Est. AIC/run |
|---|---|---|
| 1 | Bound exploration | 0.25 |
| 2 | Single diff read | 0.10 |
| 3 | No help probes / retries | 0.10 |
| 4 | Bound sub-agent | 0.15 |
| Total (conservative, overlaps discounted) | ~0.5 (~22% of 2.23) |
Structural optimizations
None warranted. The workflow already has an inline grumpy-coder agent, a review-publication skill, and no duplicated setup prefixes, so I am not recommending additional sub-agents or a shared setup section.
Caveats
- Only 8 runs in 7 days. Distribution is skewed by two large PRs, and PR size affects cost more than any prompt change.
- Estimates assume ~0.14 AIC per luna request (12.31 AIC ÷ 87) and are not measured.
- Tool arguments in the session logs were inspected for 3–5 runs in detail. The rest were checked via tool-name counts and denial records.
- Detection and evals job costs are not separable from the aggregate AIC. Tuning them is out of scope.
- Do not lower
max-diff-lines(1500) or reduce review depth; this issue targets process overhead only.
Per-run evidence
| Run | AIC | Requests (luna / haiku) | Haiku out tokens | bash | view | grep | Denied calls | Notes | |---|---|---|---|---|---|---|---|---| | [§42835636119](https://github.com/github/gh-aw/actions/runs/42835636119) | 1.28 | 7 / 5 | 4.6k | 16 | 12 | 2 | 0 | review posted, no inline comments | | 42835448554 | 1.38 | 11 / 5 | 2.6k | 16 | 14 | 4 | 0 | 1 inline comment; extra `noop` | | [§42835312941](https://github.com/github/gh-aw/actions/runs/42835312941) | 3.79 | 18 / 8 | 14.6k | 28 | 34 | 18 | 3 | diff re-read ×10; out-of-bounds `view`; `grep` missing `pattern` | | 42835109949 | 1.90 | 10 / 5 | 2.3k | 14 | 12 | 8 | 0 | `write_agent` nudge + 4 `read_agent` | | [§42834684561](https://github.com/github/gh-aw/actions/runs/42834684561) | 1.89 | 9 / 3 | 6.4k | 16 | 16 | 0 | 1 | `APPROVE` rejected then `COMMENT` | | [§42834328539](https://github.com/github/gh-aw/actions/runs/42834328539) | 2.04 | 8 / 3 | 12.0k | 10 | 10 | 4 | 1 | compound `cd ... && git log ... | grep` denied | | 42834295209 | 1.89 | 11 / 2 | 6.7k | 8 | 20 | 2 | 0 | clean | | [§42834275451](https://github.com/github/gh-aw/actions/runs/42834275451) | 3.64 | 13 / 11 | 17.0k | 32 | 20 | 8 | 0 | 10-call source-grep loop; 11 sub-agent requests |
All 8 runs: harness 1 attempt, 0 retries, 0 firewall blocks of note, review_posted=YES, findings_scoped=UNKNOWN.
References:
Generated by Agentic Workflow AIC Usage Optimizer · copilot · routed: sonnet55 high · ~69 AIC · ⊞ 5.8K · ◷
- expires on Nov 17, 2026, 7:00 AM UTC-08:00
- Linguagem predominante
- Go
- Estrelas
- 5.6k
- Forks
- 615
- Merge médio
- 5h 21min
- PRs com merge (30d)
- 792
Preparar o ambiente
Inicia o contêiner de desenvolvimento do projeto no navegador, com a sua própria conta do GitHub.
- Inclui um Dockerfile ou arquivo Docker Compose
- Sem modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de github/gh-aw
-
automation documentation
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 78/100
Mantenedores costumam responder em até 1 dia
-
ai-inspected
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
Mantenedores costumam responder em até 1 dia
-
agent-research cookie
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 69/100
Mantenedores costumam responder em até 1 dia
-
awf community
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
github/gh-aw#76385 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
automation cli-tools testing
Dificuldade 1/5 1-3 horas Facilidade para iniciantes 68/100
Mantenedores costumam responder em até 1 dia
Todas as issues de github/gh-aw
Issues semelhantes
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
Mantenedores costumam responder em até 1 dia
-
build: make check-linter version tests deterministicTalvez já em andamento Um pull request vinculado a esta issue está aberto ou já foi mesclado. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
Mantenedores costumam responder em até 1 dia
-
GitHub webhook is not subscribed to release events, so `event: release` never triggersTalvez já em andamento @qsun assumiu hoje. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
woodpecker-ci/woodpecker#7542 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 74/100
zilliztech/milvus-backup#1386 ·
Mantenedores costumam responder em até 1 dia
-
Pipelined flush no longer observes kill signals after #2042: flush backoffer is built with nil varsAberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
Mantenedores costumam responder em até 1 dia