You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Daily Agentic Workflow AIC Usage Audit (agentic-token-audit)
Selected as the highest-AIC workflow in the 7-day window (1,117.78 AIC across 5 runs). All workflows in this repository have a recent optimization entry; this one has the highest ongoing spend and a new run today (run #60) that shows a notable duration spike useful for evidence.
Note: All five tracked workflows fall within the 14-day recency window. This workflow was last addressed on 2026-07-22 (5 days ago); the recommendations below focus on newly observable patterns from today's run and areas not previously targeted.
Token/turn data only available for run #60 (today's run). Duration spike on run #60 (15.5 min vs 7β8 min average) is a clear regression signal.
π Analysis
Tool Usage
The workflow configures agentic-workflows, bash, and repo-memory. All are used legitimately across runs. GitHub API calls per run are 8β10, consistent with reading workflow sources in the setup step and writing repo-memory. No tools appear configured but unused.
AI Credit Spend Drivers
Large prompt body (333 lines): includes a 9-field data schema table, inline JSON schema examples for two output files, detailed chart rendering instructions, and a conditional OTEL span section β all loaded into context on every turn.
Write-then-run script pattern (Phase 1): the agent is instructed to write a Python script to /tmp/gh-aw/token-audit/process_audit.py and then execute it. This is a multi-turn sequence (write file β confirm write β run β read output) that adds 2β3 overhead turns.
Chart upload / URL placeholder substitution (Phase 3): upload two assets, receive URLs, then craft the issue with embedded URLs β another multi-turn sequence.
All 5 runs succeeded. No error or warning patterns. No waste from retries.
π Ranked Recommendations
1. Trim the data schema table to essential fields only
Estimated savings: ~25 AIC/run
The prompt's "Pre-downloaded logs" section includes a 9-row Markdown table describing every field of a RunData object β including deprecated (effective_tokens) and rarely-used fields (error_count, warning_count, token_usage_summary). The agent's Python script only needs workflow_name, status, conclusion, aic, token_usage, turns, action_minutes, url, and run_id. The OTEL section also has a Note column and deprecation warnings adding noise.
Action: Reduce the schema table to the 9 fields actually used in Phase 1's aggregations, and remove the "effective_tokens β deprecated; use aic" row entirely. Estimated ~50-line reduction in the prompt body.
2. Condense or extract the OTEL experiment section
Estimated savings: ~12 AIC/run
The "Experiment OTEL Span Attributes" section is ~25 lines of JavaScript boilerplate that only activates when /tmp/gh-aw/experiments/assignments.json exists. It adds context overhead on every run regardless of whether experiments are active. It also includes a full code block that the agent must process on each turn.
Action: Reduce to a two-sentence conditional instruction: "If /tmp/gh-aw/experiments/assignments.json exists, call the logSpan OTEL helper (see the shared component for the pattern) to emit one gh_aw.experiment.<name> attribute per experiment key." If the full code block must be retained, move it to a shared component imported by reference.
3. Replace the "write script to file then run" pattern with inline Python execution
Estimated savings: ~15 AIC/run
Phase 1 tells the agent to write a Python script to a named file and then execute it with a custom PYTHONPATH. Writing a file to disk, confirming the write, and then running it takes 2β3 extra turns compared to executing the Python logic inline via python3 -c '...' or a heredoc. The computation (grouping, aggregation, JSON output) is simple enough for either approach.
Action: Change Phase 1's instruction from "write a script to process_audit.py and run it" to "run the data processing inline using python3 << 'EOF' ... EOF with the PYTHONPATH prefix." Retain the schema and sort requirements in the instruction; just eliminate the write-to-file indirection. For the chart generation in Phase 3, a file script is still appropriate due to length.
The workflow has no existing ## agent: blocks and has 4 distinct phases.
Phase 1 (Process Logs) as an inline sub-agent:
Dimension
Score
Reasoning
Independence
3/3
Reads only pre-downloaded files; no dependency on other phases
Small-model adequacy
3/3
Pure aggregation: group-by, sum, sort, serialize JSON
Parallelism
0/2
Phases 2, 3, 4 all depend on its output
Size
2/2
Writes a Python script + runs it; substantial enough
Total
8/10
Strong candidate
Proposed change:
In the main prompt, replace the Phase 1 block with:
## agent: process-logs
model: small
Read `/tmp/gh-aw/token-audit/workflow-logs.json`. Filter to `status == "completed"` runs. Group by `workflow_name` and compute: `run_count`, `total_ai_credits`, `avg_ai_credits`, `total_tokens`, `avg_tokens`, `total_turns`, `avg_turns`, `total_action_minutes`, `error_count`, `warning_count`. Treat null/missing `aic`/`token_usage` as 0. Sort descending by `total_ai_credits`. Write the result plus an overall summary to `/tmp/gh-aw/token-audit/audit_snapshot.json`.
Why a smaller model fits: This is pure ETL β load, aggregate, serialize. No strategic reasoning, no synthesis, no GitHub API calls. A smaller model handles Python aggregation reliably.
Expected savings from sub-agent: ~20 AIC/run (smaller model, fewer context tokens in that phase).
π° Combined Estimated Savings
Recommendation
Est. AIC / run
Trim schema table
~25
Condense OTEL section
~12
Inline Python execution (Phase 1)
~15
Sub-agent for log processing
~20
Total
~72 AIC/run
At 5 runs/week Γ ~223 AIC/run current spend, implementing all four could reduce weekly spend by ~32% (~360 AIC/week).
The duration spike on run Consolidate optimizer workflows into a single token optimizerΒ #60 (15.5 min) may reflect a one-time condition (e.g., larger rolling-summary file, slower chart rendering). Monitor the next 3β5 runs before attributing it to prompt length.
The sub-agent recommendation requires the gh-aw runtime to support ## agent: with model: small inline blocks. Verify this feature is available before implementing.
π― Target Workflow
Daily Agentic Workflow AIC Usage Audit (
agentic-token-audit)Selected as the highest-AIC workflow in the 7-day window (1,117.78 AIC across 5 runs). All workflows in this repository have a recent optimization entry; this one has the highest ongoing spend and a new run today (run #60) that shows a notable duration spike useful for evidence.
π Spend Profile (7-day window, 2026-07-21 β 2026-07-27)
Per-run breakdown
Token/turn data only available for run #60 (today's run). Duration spike on run #60 (15.5 min vs 7β8 min average) is a clear regression signal.
π Analysis
Tool Usage
The workflow configures
agentic-workflows,bash, andrepo-memory. All are used legitimately across runs. GitHub API calls per run are 8β10, consistent with reading workflow sources in the setup step and writing repo-memory. No tools appear configured but unused.AI Credit Spend Drivers
/tmp/gh-aw/token-audit/process_audit.pyand then execute it. This is a multi-turn sequence (write file β confirm write β run β read output) that adds 2β3 overhead turns.Reliability
All 5 runs succeeded. No error or warning patterns. No waste from retries.
π Ranked Recommendations
1. Trim the data schema table to essential fields only
Estimated savings: ~25 AIC/run
The prompt's "Pre-downloaded logs" section includes a 9-row Markdown table describing every field of a
RunDataobject β including deprecated (effective_tokens) and rarely-used fields (error_count,warning_count,token_usage_summary). The agent's Python script only needsworkflow_name,status,conclusion,aic,token_usage,turns,action_minutes,url, andrun_id. The OTEL section also has a Note column and deprecation warnings adding noise.Action: Reduce the schema table to the 9 fields actually used in Phase 1's aggregations, and remove the "
effective_tokensβ deprecated; useaic" row entirely. Estimated ~50-line reduction in the prompt body.2. Condense or extract the OTEL experiment section
Estimated savings: ~12 AIC/run
The "Experiment OTEL Span Attributes" section is ~25 lines of JavaScript boilerplate that only activates when
/tmp/gh-aw/experiments/assignments.jsonexists. It adds context overhead on every run regardless of whether experiments are active. It also includes a full code block that the agent must process on each turn.Action: Reduce to a two-sentence conditional instruction: "If
/tmp/gh-aw/experiments/assignments.jsonexists, call thelogSpanOTEL helper (see the shared component for the pattern) to emit onegh_aw.experiment.<name>attribute per experiment key." If the full code block must be retained, move it to a shared component imported by reference.3. Replace the "write script to file then run" pattern with inline Python execution
Estimated savings: ~15 AIC/run
Phase 1 tells the agent to write a Python script to a named file and then execute it with a custom
PYTHONPATH. Writing a file to disk, confirming the write, and then running it takes 2β3 extra turns compared to executing the Python logic inline viapython3 -c '...'or a heredoc. The computation (grouping, aggregation, JSON output) is simple enough for either approach.Action: Change Phase 1's instruction from "write a script to
process_audit.pyand run it" to "run the data processing inline usingpython3 << 'EOF' ... EOFwith thePYTHONPATHprefix." Retain the schema and sort requirements in the instruction; just eliminate the write-to-file indirection. For the chart generation in Phase 3, a file script is still appropriate due to length.π§© Structural Optimization: Inline Sub-Agent for Log Processing
The workflow has no existing
## agent:blocks and has 4 distinct phases.Phase 1 (Process Logs) as an inline sub-agent:
Proposed change:
In the main prompt, replace the Phase 1 block with:
Why a smaller model fits: This is pure ETL β load, aggregate, serialize. No strategic reasoning, no synthesis, no GitHub API calls. A smaller model handles Python aggregation reliably.
Expected savings from sub-agent: ~20 AIC/run (smaller model, fewer context tokens in that phase).
π° Combined Estimated Savings
At 5 runs/week Γ ~223 AIC/run current spend, implementing all four could reduce weekly spend by ~32% (~360 AIC/week).
gh-awruntime to support## agent:withmodel: smallinline blocks. Verify this feature is available before implementing.References: Β§30270012569 Β· Β§30008781105 Β· Β§30094628596