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

オープン 初心者向け
#76,544 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
76/100
issue の種類
機能追加
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
github, github-actions, go
領域
devtools

調査の方向性

.github/workflows/pr-code-quality-reviewer.mdから始め、特にSteps 1と2、Guidelines、grumpy-coderエージェントブロックを確認してください。記載された探索とdiffの読み取りの制限をワークフローに反映し、探りを入れるパターンや再試行パターンを削除して、サブエージェントの出力契約を整合させてください。ワークフローが推奨事項を反映したら完了です。issueにはテストコマンドの記載がありません。

索引モデルが issue の本文から書いたものです。

説明

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
主要言語
Go
スター
5.6k
フォーク
615
平均マージ
5時間 21分
マージ済み PR(30日)
792

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

github/gh-aw のほかの issue

github/gh-aw の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。