[agentic-token-optimizer] Optimize PR Description Updater: remove unused tools, tune diff chunk size

PR Description Updater · issue · closed

Filter2mode:review mode:live
All recorded Export JSON
github-actions[bot]

published Aug 25, 2026, 3:21 PM · updated Aug 25, 2026, 5:46 PM

Target Workflow

PR Description Updater (.github/workflows/pr-description-caveman.md) — highest AIC among workflows not optimized in the last 14 days (last touched 2026-06-18). Excludes "Token"-named workflows per policy.

Analysis Period

Last 7 days, 12 runs, all success (0 failures, 0 retries).

Cost Profile

Metric Value
Total AIC 217.94
Avg AIC / run 18.16
Total raw tokens 96,611
Avg raw tokens / run 8,051
Avg sub-agent invocations / run 13.25
Avg rebuild factor 1.044 (up to 1.16 on largest runs)
Avg GitHub API calls / run 52
Total action minutes 108

AIC scales almost linearly with sub-agent invocation count: the two highest-AIC runs (§32852854725, §32853314722) hit 31–32 invocations and 37.2–37.9 AIC, while the cheapest run (§32853462356) used only 4 invocations for 8.2 AIC — a ~4.5x AIC spread driven mostly by diff size/chunk count.

Ranked Recommendations

1. Remove unused github MCP toolset — est. 3 AIC/run savings
The workflow declares tools.github: {mode: gh-proxy, toolsets: [default]}, but the prompt body never calls a github(...) tool — all repository context comes from bash (git diff, git log) captured in the setup step, and the only write is update_pull_request (a safe-output, not the github MCP tool). The default toolset injects a large function-schema payload into every turn's context, rebuilt each of the ~13 avg invocations. Evidence: no github( tool-call references anywhere in pr-description-caveman.md; all 12 analyzed runs relied solely on the pre-fetched diff/commit files and inline sub-agents.
Action: remove the github: tool block entirely (keep permissions: pull-requests: read etc. as-is; they gate the safe-output, not the removed MCP tool).

2. Remove unused cli-proxy: true — est. 1 AIC/run savings
cli-proxy: true is declared but the prompt never issues a gh CLI command (bash allowlist only covers git diff/log/cat/ls/wc/split/head/tail, and none of those go through cli-proxy). This tool adds its own schema/gateway overhead on every turn.
Action: drop cli-proxy: true from tools:.

3. Reduce chunk-call overhead for large diffs — est. 4–5 AIC/run on large-PR runs
Diff chunking splits every PR diff into fixed 400-line chunks, each requiring a separate chunk-analyzer sub-agent call. The 4 highest-AIC runs all had 17+ invocations vs. 4–7 for the cheapest runs — invocation count (proportional to ceil(diff_lines/400)) is the dominant cost driver, not diff content complexity.
Action: raise the chunk size from 400 to 600–700 lines. This proportionally cuts sub-agent call count (and their fixed per-call schema/prompt overhead) by roughly 30–40% for large diffs while staying well under chunk-analyzer's per-call context budget (Haiku handles 600-line unified diff slices comfortably).

Optional Structural Optimization — Setup Prefix

Not warranted: the setup work (diff fetch, chunking, manifest generation) already lives entirely in the single steps: shell block before the agent starts, so there is no duplicated setup logic across prompt sections to extract.

Inline Sub-Agent Note

The workflow already uses two inline sub-agents (chunk-analyzer, pr-description-synthesizer) as its core architecture — per policy, no additional sub-agents are recommended.

Raw run evidence (AIC vs. invocations, sorted)
run_id aic invocations rebuild_factor tokens
32853462356 8.20 4
32853498340 9.35 5 1.002 5,737
32853356507 9.46 5
32853185377 10.30 6
32852908687 11.00 7
32856244991 14.11 7 1.002 6,044
32853522600 14.43 10
32852595213 18.93 14 1.163 9,410
32853278481 21.54 17 1.122 10,003
32853224137 25.62 21 1.008 9,357
32853314722 37.15 32 1.128 13,392
32852854725 37.86 31 1.096 12,797

Caveats

  • 12 runs is a modest sample; conclusions on chunk-size tuning should be re-validated after the change lands across a wider mix of PR sizes.
  • Removing the github tool and cli-proxy assumes no other silent dependency exists in imported shared components (shared/reporting.md was checked and contains no github(/gh calls either).
  • AIC/invocation correlation is observational, not causal; a portion of the increase at high invocation counts may also reflect genuinely larger, more complex diffs needing more synthesis tokens.

References: §32852854725, §32853314722, §32853278481

Generated by Agentic Workflow AIC Usage Optimizer · copilot · auto · 61.3 AIC · ⊞ 11K ·

  • expires on Sep 1, 2026, 7:21 AM UTC-08:00