[agentic-token-optimizer] PR Code Quality Reviewer: cut ~0.5 AIC/run (~22%) by bounding exploration and removing probe/retry calls

Aperta Adatta ai principianti
#76,544 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
76/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
github, github-actions, go
Ambito
devtools

Direzione di ricerca

Inizia da .github/workflows/pr-code-quality-reviewer.md, in particolare dai passaggi 1 e 2, dalle Guidelines e dal blocco dell’agente grumpy-coder. Aggiorna il workflow con i limiti indicati per l’esplorazione e la lettura dei diff, rimuovi i modelli di sondaggio e ripetizione dei tentativi e allinea il contratto di output del sottoagente. Il lavoro è concluso quando il workflow riflette le raccomandazioni; l’issue non indica alcun comando di test.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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, all success.
  • Data used: run_summary.json, usage/aw_session.jsonl and token_usage.jsonl per 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 + 18 grep + 28 bash calls. 18 luna requests for one documentation finding.
  • §42834275451: 10 consecutive bash grep -rn/sed -n calls across pkg/workflow and actions/, 32 bash calls in total.
  • The typical run, §42835636119, made 12 view/2 grep/16 bash calls 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 grep call may cover multiple symbols, and one view call 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: view of pr-diff.patch ×10, plus cat, head -c 22000, tail -c, and split. One view_range call failed with "out of bounds" and one split call 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 --help and safeoutputs <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-args safeoutputs ...), followed by a retry.
  • §42834684561 submitted APPROVE first, which allowed-events does not permit, then resubmitted as COMMENT.
  • 2 of 8 runs call noop after already submitting the review.

Action:

  • Add to Guidelines: "Do not run --help. Do not combine commands with cd, ;, && or redirects. Use view/grep/glob for reads."
  • Add: "event must be COMMENT or REQUEST_CHANGES; never APPROVE."
  • Add: "Do not call noop after 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
Lingua principale
Go
Stelle
5.6k
Fork
615
Merge medio
5h 21m
PR unite (30g)
792

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di github/gh-aw

Tutte le issue di github/gh-aw

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.