Skip to content

[agentic-token-optimizer] Optimize Agentic Workflow AIC Usage Optimizer — trim verbose prompt sections (~35–45 AIC/run) #195

Description

@github-actions

Target workflow: Agentic Workflow AIC Usage Optimizer (agentic-token-optimizer.md)
Reason selected: Highest-AIC workflow in the 7-day window (2,782 total AIC / 5 runs). All 5 tracked workflows fall within the 14-day cooldown; this one was last optimized 7 days ago (2026-06-18), making it the best available candidate. Running in the source repository (githubnext/agentic-ops) so the AIC-monitoring-family exclusion does not apply.


Spend Profile

Metric All 5 runs Excl. June 18 outlier (4 runs)
Total AIC 2,782 1,748
Avg AIC / run 556 437
Total tokens ~6.85M ~5.25M
Avg tokens / run ~1.71M ~1.31M
Avg turns / run ~36 ~28
Cache efficiency N/A N/A
Success rate 100% (5/5) 100%

June 18 run (1,034 AIC, 58 turns, 3.06M tokens) is treated as a post-change baseline outlier. The four subsequent runs form the stable baseline at ~437 AIC/run, ~28 turns/run.

Per-run breakdown
Date Run AIC Tokens Turns Conclusion
2026-06-18 §27770903508 1,034 3,060,256 58 ✅ success
2026-06-19 §27834854273 415 N/A N/A ✅ success
2026-06-22 §27966098529 463 1,310,078 26 ✅ success
2026-06-23 §28036893325 368 1,029,156 24 ✅ success
2026-06-24 §28109263044 502 1,454,619 35 ✅ success

Token data sourced from daily audit snapshots; June 19 snapshot recorded the prior day (June 18) run.

Spend driver: Turn count is the primary AIC lever (24–35 turns/run). Each turn re-sends the full system prompt (~203 lines of prompt body ≈ 7–8k tokens). Reducing prompt verbosity saves tokens proportionally across every turn.


Ranked Recommendations

1. Trim the ## Data Access Guidelines section (estimated −15–20 AIC/run)

What: The current 27-line section contains three fully-annotated bash code blocks with ✅/❌ markers illustrating gh api --jq filtering and chained commands. These patterns are fundamental best-practices that the agent already applies correctly in every audited run.

Action: Replace the three code blocks and their prose commentary with a single 2-sentence directive:

Always filter gh api responses with --jq or pipe through jq — never load unfiltered payloads. Combine multi-step reads into one bash block using pipes and &&.

Remove the ✅/❌ annotated examples entirely. Retain the opening paragraph if it helps orient the agent. This reduces the section from 27 lines to ~4 lines, saving ~600–700 tokens per turn.

Evidence: All 5 runs completed successfully; the agent consistently used --jq filtering and batched commands. The instructional examples add no observable runtime benefit.

Estimated saving: ~600 tokens × 28 avg turns = ~17k tokens/run ≈ 15–20 AIC/run.


2. Compress the Phase 4 inline sub-agent scoring rubric (estimated −10–15 AIC/run)

What: The ### Inline Sub-Agent Opportunity Analysis subsection spans ~32 lines: a 4-row scoring table, three scoring threshold bullets, a 6-item "smaller models are a good fit for" list, and a "keep with main agent when" paragraph. The qualitative guidance duplicates what the 4-column table already encodes.

Action: Remove the 6-item "smaller models are a good fit for" list and the "keep with main agent when" paragraph (~12 lines). Replace them with one sentence:

Small models suit extractive, classificatory, or single-file-summarisation work; keep cross-source synthesis and the final issue body in the main agent.

Retain the scoring table and the 6+ / 4–5 / <4 thresholds. This reduces Phase 4 from 47 lines to ~33 lines, saving ~450–550 tokens per turn.

Evidence: In the last 3 runs the optimizer identified 0 sub-agent candidates each time. The expanded qualitative guidance is processed every run but rarely acts as the deciding factor.

Estimated saving: ~500 tokens × 28 avg turns = ~14k tokens/run ≈ 10–15 AIC/run.


3. Remove the frontmatter-only code example from Phase 3 (estimated −5–10 AIC/run)

What: ## Phase 3 — Read Workflow Source contains four code blocks (28 lines): full-source read, frontmatter-only read, prompt-body-only read, plus a "Validate from the source" checklist. The frontmatter-only block (awk '/^---$/{n++; if(n==2) exit} n==1') is almost never needed — the agent reads either the full file or the prompt body.

Action: Remove the frontmatter-only code block and its surrounding commentary (~7 lines). Retain the full-source and prompt-body examples. This saves ~250–300 tokens per turn.

Evidence: No recent run needed to extract frontmatter independently; the validation checklist (configured tools, prompt structure, inline sub-agents) is satisfied by reading the prompt body section.

Estimated saving: ~275 tokens × 28 avg turns = ~8k tokens/run ≈ 5–10 AIC/run.


Combined Estimated Impact

# Recommendation Est. savings/run
1 Trim Data Access Guidelines 15–20 AIC
2 Compress Phase 4 scoring rubric 10–15 AIC
3 Remove Phase 3 frontmatter-only example 5–10 AIC
Total 30–45 AIC/run (~7–10% of 437 AIC baseline)

Secondary effect: shorter, more focused instructions may reduce avg turns from ~28 toward ~24 (where the June 23 run landed), yielding an additional 10–15% AIC reduction beyond the direct token savings.


Caveats

  • Sampling: 5 runs analyzed; 1 (June 18) treated as an outlier. Estimates assume the stable 4-run baseline (437 AIC/run). Token data unavailable for the June 19 run.
  • 14-day cooldown: All 5 active workflows were optimized within the last 14 days. This recommendation targets the oldest-cooldown workflow; implement after confirming prior optimizations have stabilised.
  • Turn-count variance: Run turns ranged 24–35 (+46% spread). AIC savings scale proportionally — higher-turn runs will see more benefit from prompt trimming.
  • No reliability issues: All 5 runs succeeded with 0 errors and 0 warnings; no reliability-based recommendations are warranted.
  • Sub-agents not recommended: The optimizer is a sequential analytical pipeline where each phase depends on prior phase outputs. No phase scored ≥6 on the independence/parallelism criteria.

References: §27966098529 · §28036893325 · §28109263044

Generated by Agentic Workflow AIC Usage Optimizer · 271.9 AIC · ⊞ 21.6K ·

  • expires on Jul 2, 2026, 3:35 PM UTC

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions