π― Target Workflow
Daily Agentic Workflow AIC Usage Audit (agentic-token-audit)
Selected as the highest-AIC workflow not optimized in the last 14 days (last entry: 2026-07-27, 8 days ago). All other top-5 workflows were optimized within the past 7 days.
π
Analysis Period
2026-07-29 β 2026-08-04 Β· 5 runs analyzed
π Spend Profile
| Metric |
Value |
| Runs analyzed |
5 |
| Total AIC |
924.16 |
| Avg AIC / run |
184.83 |
| Total tokens |
574,378 (1-run sample) |
| Avg turns / run |
3.0 |
| Conclusions |
5 Γ success (100%) |
| Cache efficiency |
N/A (token breakdown not available for 4/5 runs) |
Avg 184.83 AIC/run is ~2Γ the "Daily Agentic AI Research Digest" (94 AIC/run) despite this workflow having only 3 avg turns and a more structured, data-processing task. The primary cost driver is prompt size β the workflow prompt is 333 lines and carries significant in-prompt reference documentation that the agent re-reads every turn.
References: Β§30911974481 Β· Β§30817584209 Β· Β§30632873627
π§ Ranked Recommendations
1. Remove the full RunData field reference table from the prompt
Estimated savings: ~20β30 AIC/run
The ## Data Sources β Pre-downloaded logs section embeds a 12-row Markdown table documenting every field of the RunData object (workflow_name, workflow_path, aic, token_usage, effective_tokens, action_minutes, turns, duration, created_at, run_id, url, status, conclusion, error_count, warning_count, token_usage_summary). This table is pure reference material β the agent only ever uses 6β7 of these fields (workflow_name, aic, token_usage, turns, conclusion, action_minutes, error_count).
Action: Replace the full 12-field table with a compact note listing only the fields actually used in the Python script:
Key fields per run: `workflow_name`, `aic` (float, treat null as 0), `token_usage` (int, treat null as 0),
`turns`, `conclusion`, `action_minutes`, `error_count`, `warning_count`, `url`. All other fields can be ignored.
This removes ~20 lines of prompt text that is re-loaded every turn.
2. Extract the repeated PYTHONPATH instruction into a setup note
Estimated savings: ~5β8 AIC/run
The ## Phase 3 section mentions the PYTHONPATH prefix twice β once in the bullet list and once in the inline code example. The same instruction was also present in the chart-generation context from earlier runs. Consolidating this into a single ## Setup Note near the top of the prompt ensures the agent picks it up once rather than re-encountering it mid-task.
Action: Add a short setup block after ## Data Sources:
## Setup Note
All Python commands that import pandas, matplotlib, or seaborn must be prefixed with:
`PYTHONPATH=/tmp/gh-aw/token-audit/site-packages${PYTHONPATH:+:$PYTHONPATH}`
Then remove the repeated PYTHONPATH callout from Phase 3.
3. Trim Phase 3 chart requirements
Estimated savings: ~10β15 AIC/run
The chart generation section (## Phase 3 β Generate Charts) is ~60 lines long and includes:
- Detailed styling requirements (300 DPI, white background, whitegrid, axis labels)
- URL replacement instructions for two named placeholders
- A conditional skip rule for when rolling-summary has fewer than 2 points
- Separate bullet items for each chart
Most of this detail could be condensed. The agent succeeds in 100% of runs, meaning it does not need this level of scaffolding.
Action: Reduce Phase 3 to the essential contract:
## Phase 3 β Generate Charts
Write and run Python scripts to generate PNG charts (300 DPI, white background, seaborn whitegrid):
1. **`ai_credits_by_workflow.png`**: horizontal bar chart, top 15 workflows by total AI credits from `audit_snapshot.json`.
2. **`ai_credits_trend.png`**: dual-axis line chart from `rolling-summary.json` β total AI credits (left axis) and `active_workflows` per day (right axis, label: "Active workflows/day"). Skip if fewer than 2 data points.
Upload each chart with `upload_asset`. Use the returned URLs as inline images in the issue.
This cuts ~35 lines while preserving all required behavior.
4. Collapse the issue template boilerplate
Estimated savings: ~5β8 AIC/run
## Phase 4 β Publish Audit Issue embeds a verbatim Markdown template (~50 lines) including the ### π Executive Summary heading structure. The template uses named placeholders (UPLOAD_URL_WORKFLOW_PLACEHOLDER, etc.) that the agent must track across turns. A more concise instruction with a short schema description would be sufficient.
Action: Replace the full template with a structured description:
Create an issue with:
- Executive summary: period, total runs, total AIC, total tokens, total action-minutes, active workflows
- Top 5 table: workflow name, runs, total AIC, avg AIC
- Inline chart images from upload_asset URLs
- Per-workflow detail table (collapsible)
- Final observations (2β4 bullets on trend, top spenders, anomalies)
π¬ Structural Optimization: Inline Sub-Agent for Chart Generation
Phase 3 (Generate Charts) β sub-agent candidate
The chart generation phase is fully file-I/O driven: it reads two JSON files (audit_snapshot.json, rolling-summary.json), writes two PNG files, and uploads them. It requires no strategic reasoning, only procedural Python execution.
| Dimension |
Score |
Rationale |
| Independence |
2/3 |
Depends on Phase 1+2 output files (available before Phase 3 runs) |
| Small-model adequacy |
3/3 |
Purely procedural: write Python β run β upload |
| Parallelism |
1/2 |
Sequential (after Phase 2), but isolated |
| Size |
2/2 |
Substantial enough to justify agent call |
| Total |
8/10 |
Strong candidate |
Proposed change: Replace the ## Phase 3 instructions in the main prompt with:
## Phase 3 β Generate Charts
## agent: chart-generator
Generate two PNG charts from pre-computed audit data and upload them. Return the upload URLs.
Input files (already written to disk):
- `/tmp/gh-aw/token-audit/audit_snapshot.json` β per-workflow AIC totals
- `/tmp/gh-aw/repo-memory/default/rolling-summary.json` β historical daily totals
Tasks:
1. Write and run a Python script (PYTHONPATH=/tmp/gh-aw/token-audit/site-packages) using pandas + matplotlib + seaborn (whitegrid, 300 DPI, white background):
- `ai_credits_by_workflow.png`: horizontal bar chart, top 15 workflows by total_ai_credits from audit_snapshot.json
- `ai_credits_trend.png`: dual-axis line chart from rolling-summary.json β total_ai_credits (left) and active_workflows (right, label "Active workflows/day"). Skip if fewer than 2 data points.
2. Upload each chart with upload_asset. Return the two URLs.
The smaller model handles Python script generation and execution well; the main agent retains responsibility for issue composition (Phase 4) where cross-referencing and synthesizing the full audit is required.
Expected additional savings from sub-agent: ~8β12 AIC/run (smaller model token cost for chart phase vs main model).
β οΈ Caveats
- Token breakdown is only available for 1 of 5 runs; per-phase token attribution is estimated from prompt structure analysis, not observed tool call logs.
- Avg 3 turns/run indicates the agent already completes efficiently β no turn-count reduction opportunities were identified.
- All 5 runs concluded
success; no error-recovery paths were observed, so there is no reliability waste to eliminate.
- Sub-agent recommendation assumes the
## agent: inline sub-agent syntax is supported by this runner version.
Total estimated savings: 40β65 AIC/run (22β35% reduction)
Generated by Agentic Workflow AIC Usage Optimizer Β· 231.8 AIC Β· β 21.6K Β· β·
π― Target Workflow
Daily Agentic Workflow AIC Usage Audit (
agentic-token-audit)Selected as the highest-AIC workflow not optimized in the last 14 days (last entry: 2026-07-27, 8 days ago). All other top-5 workflows were optimized within the past 7 days.
π Analysis Period
2026-07-29 β 2026-08-04 Β· 5 runs analyzed
π Spend Profile
Avg 184.83 AIC/run is ~2Γ the "Daily Agentic AI Research Digest" (94 AIC/run) despite this workflow having only 3 avg turns and a more structured, data-processing task. The primary cost driver is prompt size β the workflow prompt is 333 lines and carries significant in-prompt reference documentation that the agent re-reads every turn.
References: Β§30911974481 Β· Β§30817584209 Β· Β§30632873627
π§ Ranked Recommendations
1. Remove the full RunData field reference table from the prompt
Estimated savings: ~20β30 AIC/run
The
## Data Sources β Pre-downloaded logssection embeds a 12-row Markdown table documenting every field of theRunDataobject (workflow_name,workflow_path,aic,token_usage,effective_tokens,action_minutes,turns,duration,created_at,run_id,url,status,conclusion,error_count,warning_count,token_usage_summary). This table is pure reference material β the agent only ever uses 6β7 of these fields (workflow_name,aic,token_usage,turns,conclusion,action_minutes,error_count).Action: Replace the full 12-field table with a compact note listing only the fields actually used in the Python script:
This removes ~20 lines of prompt text that is re-loaded every turn.
2. Extract the repeated PYTHONPATH instruction into a setup note
Estimated savings: ~5β8 AIC/run
The
## Phase 3section mentions thePYTHONPATHprefix twice β once in the bullet list and once in the inline code example. The same instruction was also present in the chart-generation context from earlier runs. Consolidating this into a single## Setup Notenear the top of the prompt ensures the agent picks it up once rather than re-encountering it mid-task.Action: Add a short setup block after
## Data Sources:Then remove the repeated PYTHONPATH callout from Phase 3.
3. Trim Phase 3 chart requirements
Estimated savings: ~10β15 AIC/run
The chart generation section (
## Phase 3 β Generate Charts) is ~60 lines long and includes:Most of this detail could be condensed. The agent succeeds in 100% of runs, meaning it does not need this level of scaffolding.
Action: Reduce Phase 3 to the essential contract:
This cuts ~35 lines while preserving all required behavior.
4. Collapse the issue template boilerplate
Estimated savings: ~5β8 AIC/run
## Phase 4 β Publish Audit Issueembeds a verbatim Markdown template (~50 lines) including the### π Executive Summaryheading structure. The template uses named placeholders (UPLOAD_URL_WORKFLOW_PLACEHOLDER, etc.) that the agent must track across turns. A more concise instruction with a short schema description would be sufficient.Action: Replace the full template with a structured description:
π¬ Structural Optimization: Inline Sub-Agent for Chart Generation
Phase 3 (Generate Charts) β sub-agent candidate
The chart generation phase is fully file-I/O driven: it reads two JSON files (
audit_snapshot.json,rolling-summary.json), writes two PNG files, and uploads them. It requires no strategic reasoning, only procedural Python execution.Proposed change: Replace the
## Phase 3instructions in the main prompt with:The smaller model handles Python script generation and execution well; the main agent retains responsibility for issue composition (Phase 4) where cross-referencing and synthesizing the full audit is required.
Expected additional savings from sub-agent: ~8β12 AIC/run (smaller model token cost for chart phase vs main model).
success; no error-recovery paths were observed, so there is no reliability waste to eliminate.## agent:inline sub-agent syntax is supported by this runner version.Total estimated savings: 40β65 AIC/run (22β35% reduction)