Skip to content

[agentic-token-optimizer] Daily Agentic Workflow AIC Usage Audit β€” prompt & execution efficiencyΒ #293

Description

@github-actions

🎯 Target Workflow

Daily Agentic Workflow AIC Usage Audit (agentic-token-audit.md)

Selected as the highest-AIC workflow not optimized within the last 14 days after filtering the monitoring family exclusion (allowed in githubnext/agentic-ops). Second-ranked in the 7-day top-workflow list with ~978 AIC total.


πŸ“Š Analysis Period & Spend Profile

Period: 2026-07-10 β†’ 2026-07-16 (5 completed runs, all successful)

Metric Value
Runs analyzed 5
Total AIC 978.10
Avg AIC / run 195.62
Peak AIC run 260.07 (2026-07-16)
Token-instrumented run 772,127 tokens, 20 turns (2026-07-16 only)
Success rate 100%
Errors observed 0

Note: Token and turn data is only available for the most recent run; the prior 4 runs have null for token_usage and turns. AIC jumped ~40% on 2026-07-16 vs the prior four runs (~181 avg), suggesting context growth or new data volume. Estimates below are calibrated to the 195 avg.

References:


πŸ” Analysis Matrix

Area Finding Verdict
Tool usage bash *, agentic-workflows, repo-memory β€” all used each run Keep all
AI credit spend High avg (195/run) for deterministic JSON β†’ Python β†’ chart β†’ issue pipeline Top driver: verbose prompt context
Reliability 100% success, 0 errors No waste from failures
Prompt efficiency Detailed schema tables, duplicate PYTHONPATH instructions, full OTEL JS block, verbose report template Multiple reduction opportunities
Structural optimization 4 sequential phases β€” all depend on the prior phase's output; no parallelism possible No sub-agents warranted

πŸ† Ranked Recommendations

1. Compress schema documentation sections β€” ~20–30 AIC/run

Action: The ## Data Sources section contains a full 11-field Markdown table documenting workflow-logs.json fields plus a JSON shape block for audit_snapshot.json. These are loaded into every agent turn (20 turns observed). Replace with a compact 4-field summary covering only workflow_name, aic, token_usage, and conclusion, and link the rest as a comment.

Evidence: At 20 turns Γ— 772 k tokens/run, the schema tables likely account for 2–4 k tokens/turn of constant overhead. Reducing by ~60% saves an estimated 25 k tokens/run.

Concrete change:

Replace the 11-row schema table in ## Data Sources / Pre-downloaded logs with:

Each run object has: `workflow_name` (string), `aic` (float, treat null as 0),
`token_usage` (int, treat null as 0), `turns` (int), `conclusion` (string),
`run_id` (int64), `url` (string), `error_count` (int), `created_at` (ISO 8601).

Replace the JSON shape block for audit_snapshot.json with a single sentence: "Save to /tmp/gh-aw/token-audit/audit_snapshot.json with the schema embedded in the Python script below."

Estimated savings: ~20–30 AIC/run


2. Deduplicate PYTHONPATH instructions β€” ~5–10 AIC/run

Action: The string PYTHONPATH=/tmp/gh-aw/token-audit/site-packages${PYTHONPATH:+:$PYTHONPATH} appears in a code fence in Phase 3, once in a bullet, and once inline β€” three occurrences. Consolidate to a single note at the start of Phase 3: "Prefix all Python commands with PYTHONPATH=/tmp/gh-aw/token-audit/site-packages${PYTHONPATH:+:$PYTHONPATH}."

Evidence: At 20 turns, repeated long env-var strings inflate context on every turn.

Estimated savings: ~5–10 AIC/run


3. Shrink the OTEL experiment section β€” ~5–8 AIC/run

Action: The ## Experiment OTEL Span Attributes section contains a ~25-line JavaScript code block that runs only when /tmp/gh-aw/experiments/assignments.json exists. Collapse to a brief conditional check:

If `/tmp/gh-aw/experiments/assignments.json` exists, read its keys, set
`gh_aw.experiment.<name>` attributes, and call `otlp.logSpan('experiment', attrs)`.

Remove the inline JS block; the agent can derive the implementation.

Evidence: The JS code block is context overhead on all 20 turns even when no experiments file is present.

Estimated savings: ~5–8 AIC/run


4. Combine Python processing steps β€” ~3–5 AIC/run

Action: Phase 1 instructs the agent to: (a) write a Python script to a file, (b) run it with PYTHONPATH prefix. Phase 3 adds a second Python invocation for charts. Combine into a single script (process_and_chart.py) that handles both aggregation and chart generation, reducing bash tool calls and intermediate file steps.

Evidence: Each bash tool call is a turn. The instrumented run shows 20 turns, which is high for a deterministic pipeline. Fewer distinct Python invocations β†’ fewer turns.

Estimated savings: ~3–5 AIC/run


πŸ’‘ Structural Optimization

Sub-agents: Not recommended. All four phases are strictly sequential β€” Phase 2 depends on Phase 1's output, Phase 3 depends on Phase 1's aggregated data, and Phase 4 depends on chart upload URLs from Phase 3. No independent sections exist that would benefit from parallelism or a smaller model.


πŸ“ˆ Combined Estimate

Recommendation Estimated AIC savings/run
Compress schema docs 20–30
Deduplicate PYTHONPATH 5–10
Shrink OTEL section 5–8
Combine Python steps 3–5
Total 33–53 AIC/run

At 5 runs/week this represents 165–265 AIC/week in potential savings (17–27% of current spend).


⚠️ Caveats

  • Token and turn data is only available for 1 of 5 runs; savings estimates are extrapolated from that single instrumented run.
  • The 260-AIC spike on 2026-07-16 vs ~181 prior average may reflect larger log volume that day; schema compression savings scale with turn count.
  • Combining Python steps (Rec 4) requires validating that chart output paths remain accessible before the issue is published.

Generated by Agentic Workflow AIC Usage Optimizer Β· 134.7 AIC Β· ⊞ 21.6K Β· β—·

  • expires on Jul 23, 2026, 3:11 PM UTC

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    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