Target Workflow
Agentic Workflow AIC Usage Optimizer (agentic-token-optimizer)
Selected because it is the highest-AIC workflow (1,251 AIC over 4 runs in the last 7 days) not recently optimized — last optimization was 2026-07-24 (10 days ago, closest to the 14-day cooldown window). All other workflows were optimized within the past 7 days.
Analysis Period
2026-07-28 to 2026-07-31 · 4 completed runs audited
Spend Profile
| Metric |
Value |
| Runs audited |
4 |
| Total AIC |
1,251 AIC |
| Avg AIC/run |
312.8 AIC |
| Avg AIC/run (excl. outlier) |
184 AIC |
| Avg run duration |
~10 min (range: 7–15 min) |
| Total tokens |
N/A (token_usage null in all runs) |
| Avg turns/run |
N/A (turns null in all runs) |
| Cache efficiency |
Cannot assess — token data missing |
⚠️ Data gap: token_usage and turns fields are null for all optimizer runs in all-runs.json. The workflow cannot evaluate cache efficiency or per-turn cost for its own execution. This prevents meaningful self-audit on the most important metrics.
Per-run breakdown
Ranked Recommendations
Rec 1 — Bound job log exploration depth
Estimated savings: ~35–45 AIC/run (average across all runs)
Run §30555042679 consumed 699 AIC in 15:12 — 3.4× the median cost of 184 AIC. The run completed successfully but spent ~5 extra minutes in the agent phase. The most likely cause is unbounded job-log fetching: the current prompt instructs the agent to fetch logs for multiple runs without any line or file limit. Phase 2 says "Audit at least 5 runs when available" but provides no ceiling on how many log lines to read per run.
Action: Add explicit exploration caps to Phase 2:
When reading job logs for individual runs, read at most 3 runs and limit each log to 300 lines. Do not attempt to read the full log for any run — prefer the grep-filtered approach.
This directly targets the outlier. Preventing a single 699 AIC run per week would reduce 7-day average from 312 AIC to ~230 AIC, an ~26% reduction.
References: §30555042679
Rec 2 — Condense Data Access Guidelines section
Estimated savings: ~15–20 AIC/run
The ## Data Access Guidelines section contains ~600 bytes of bash code examples with 4 annotated snippets (3 ✅ and 1 ❌). These examples are loaded as context on every inference turn, but their intent can be expressed in 2 lines:
Always use --jq to filter gh api responses to only the fields you need. Pipe through base64 -d for file contents. Never load full unfiltered responses.
The code block adds ~150 prompt tokens per turn with no additional semantic value over the condensed rule. Across 7–10 turns per run, this adds 1,050–1,500 tokens of redundant context per run.
Action: Replace the full code block in ## Data Access Guidelines with a 2–3 sentence prose rule. Remove the ✅/❌ example snippets.
Rec 3 — Trim Phase 4 sub-agent scoring framework
Estimated savings: ~8–12 AIC/run
The ### Inline Sub-Agent Opportunity Analysis section contains a 4-row scoring table with dimensions (Independence, Small-model adequacy, Parallelism, Size), a 3-tier scoring rubric, and a 7-item "Smaller models are a good fit for" list — approximately 400 bytes of instructions that are read on every turn even when the workflow being analyzed already has inline sub-agents.
Across the last 30 optimization-log entries, 18 of 30 runs (60%) produced 0 sub-agent candidates. The detailed scoring framework is processing overhead for the majority of runs.
Action: Condense the scoring section to:
Score each section: Independence (0–3) + Small-model fit (0–3) + Parallelism (0–2) + Scope (0–2). Score ≥6: strong candidate; 4–5: moderate; <4: skip. Only recommend sub-agents for extractive, classifying, or formatting tasks that don't need cross-section synthesis.
Replace the 7-item "Smaller models are a good fit for" list with a single criterion parenthetical.
Rec 4 — Fix missing token/turns data for self-analysis
Estimated savings: indirect — enables better future self-optimization
All 4 runs have token_usage: null and turns: null in all-runs.json. This means the optimizer cannot analyze cache hit rate, per-turn cost, or context growth trends for its own runs — the most important signals for an AIC optimizer.
Investigate why gh aw logs agentic-token-optimizer returns null for these fields when other workflows (e.g., agentic-token-audit with 564,138 tokens across 5 runs) return valid values. It may require a flag or the data may not be captured before the workflow completes.
Action: Audit the gh aw logs invocation in the Download recent agentic workflow logs step. If the current run's data is excluded from its own log file (because the run is still in-flight when logs are collected), add logic to the Aggregate top workflows step to handle self-reporting, or document the gap explicitly so future analysis skips cache-efficiency checks for this workflow.
Structural Optimization — Inline Sub-Agent for Phase 1 (Target Selection)
No inline sub-agents exist in this workflow. With 7 major prompt phases, there is a clear structural refactor opportunity.
Candidate: Phase 1 — Select Target
| Dimension |
Score |
Rationale |
| Independence |
3/3 |
Reads only pre-downloaded files (top-workflows.json, optimization-log.json) |
| Small-model fit |
3/3 |
Pure filtering: sort by AIC, exclude cooldown entries, return one name |
| Parallelism |
0/2 |
All later phases depend on this output |
| Scope |
2/2 |
Meaningful enough to justify a sub-agent call |
| Total |
8/10 |
Strong candidate |
Why a smaller model fits: Phase 1 is entirely mechanical — read one JSON file, subtract dates, filter a list, return the top remaining entry. No strategic reasoning is required.
Proposed change: Replace the Phase 1 instructions in the main prompt with:
## agent: select-target
tools: [bash]
prompt: |
Read /tmp/gh-aw/token-audit/top-workflows.json and /tmp/gh-aw/repo-memory/default/optimization-log.json.
Return the workflow_name of the highest total_ai_credits entry NOT optimized in the last 14 days
(compare against "date" fields in optimization-log.json; today is {{ date }}).
Exclude "Agentic Workflow AIC Usage Optimizer" and "Daily Agentic Workflow AIC Usage Audit"
unless GITHUB_REPOSITORY is "githubnext/agentic-ops".
Output exactly: SELECTED_WORKFLOW=<name>
The main agent receives the SELECTED_WORKFLOW output and proceeds with Phases 2–6. Estimated savings: 10–15 AIC/run by offloading ~3 turns of mechanical work to a smaller model.
Caveats
- Only 4 completed runs were available (last 7 days). The outlier run (2026-07-30, 699 AIC) is a single data point — it could reflect an unusual target workflow requiring deeper analysis rather than prompt-driven over-exploration.
- Token and turns data are null for all runs; cache efficiency analysis was not possible.
- Rec 2 and Rec 3 savings are estimates based on prompt byte reduction — actual token savings depend on tokenizer behavior and turn count, which cannot be verified without the missing
token_usage data.
- The sub-agent recommendation (Phase 1) requires verifying that the agent framework correctly passes
{{ date }} as a template variable inside agent prompts.
Generated by Agentic Workflow AIC Usage Optimizer · 235.8 AIC · ⊞ 21.6K · ◷
Target Workflow
Agentic Workflow AIC Usage Optimizer (
agentic-token-optimizer)Selected because it is the highest-AIC workflow (1,251 AIC over 4 runs in the last 7 days) not recently optimized — last optimization was 2026-07-24 (10 days ago, closest to the 14-day cooldown window). All other workflows were optimized within the past 7 days.
Analysis Period
2026-07-28 to 2026-07-31 · 4 completed runs audited
Spend Profile
token_usagenull in all runs)turnsnull in all runs)Per-run breakdown
Ranked Recommendations
Rec 1 — Bound job log exploration depth
Estimated savings: ~35–45 AIC/run (average across all runs)
Run §30555042679 consumed 699 AIC in 15:12 — 3.4× the median cost of 184 AIC. The run completed successfully but spent ~5 extra minutes in the agent phase. The most likely cause is unbounded job-log fetching: the current prompt instructs the agent to fetch logs for multiple runs without any line or file limit. Phase 2 says "Audit at least 5 runs when available" but provides no ceiling on how many log lines to read per run.
Action: Add explicit exploration caps to Phase 2:
This directly targets the outlier. Preventing a single 699 AIC run per week would reduce 7-day average from 312 AIC to ~230 AIC, an ~26% reduction.
References: §30555042679
Rec 2 — Condense Data Access Guidelines section
Estimated savings: ~15–20 AIC/run
The
## Data Access Guidelinessection contains ~600 bytes of bash code examples with 4 annotated snippets (3 ✅ and 1 ❌). These examples are loaded as context on every inference turn, but their intent can be expressed in 2 lines:The code block adds ~150 prompt tokens per turn with no additional semantic value over the condensed rule. Across 7–10 turns per run, this adds 1,050–1,500 tokens of redundant context per run.
Action: Replace the full code block in
## Data Access Guidelineswith a 2–3 sentence prose rule. Remove the ✅/❌ example snippets.Rec 3 — Trim Phase 4 sub-agent scoring framework
Estimated savings: ~8–12 AIC/run
The
### Inline Sub-Agent Opportunity Analysissection contains a 4-row scoring table with dimensions (Independence, Small-model adequacy, Parallelism, Size), a 3-tier scoring rubric, and a 7-item "Smaller models are a good fit for" list — approximately 400 bytes of instructions that are read on every turn even when the workflow being analyzed already has inline sub-agents.Across the last 30 optimization-log entries, 18 of 30 runs (60%) produced 0 sub-agent candidates. The detailed scoring framework is processing overhead for the majority of runs.
Action: Condense the scoring section to:
Replace the 7-item "Smaller models are a good fit for" list with a single criterion parenthetical.
Rec 4 — Fix missing token/turns data for self-analysis
Estimated savings: indirect — enables better future self-optimization
All 4 runs have
token_usage: nullandturns: nullinall-runs.json. This means the optimizer cannot analyze cache hit rate, per-turn cost, or context growth trends for its own runs — the most important signals for an AIC optimizer.Investigate why
gh aw logs agentic-token-optimizerreturns null for these fields when other workflows (e.g.,agentic-token-auditwith 564,138 tokens across 5 runs) return valid values. It may require a flag or the data may not be captured before the workflow completes.Action: Audit the
gh aw logsinvocation in theDownload recent agentic workflow logsstep. If the current run's data is excluded from its own log file (because the run is still in-flight when logs are collected), add logic to theAggregate top workflowsstep to handle self-reporting, or document the gap explicitly so future analysis skips cache-efficiency checks for this workflow.Structural Optimization — Inline Sub-Agent for Phase 1 (Target Selection)
No inline sub-agents exist in this workflow. With 7 major prompt phases, there is a clear structural refactor opportunity.
Candidate: Phase 1 — Select Target
top-workflows.json,optimization-log.json)Why a smaller model fits: Phase 1 is entirely mechanical — read one JSON file, subtract dates, filter a list, return the top remaining entry. No strategic reasoning is required.
Proposed change: Replace the Phase 1 instructions in the main prompt with:
The main agent receives the
SELECTED_WORKFLOWoutput and proceeds with Phases 2–6. Estimated savings: 10–15 AIC/run by offloading ~3 turns of mechanical work to a smaller model.Caveats
token_usagedata.{{ date }}as a template variable inside agent prompts.