Skip to content

[agentic-token-optimizer] Agentic Maintenance — action-minutes & data pipeline optimizations #84

@github-actions

Description

@github-actions

Target Workflow

Agentic Maintenance (agentics-maintenance.yml) — selected as the only eligible candidate after excluding workflows optimized within the last 14 days and workflows with "Token" in their name.

⚠️ Data Gap Notice: The pre-downloaded all-runs.json and all daily snapshots for the 7-day window contain zero AI workflow runs ("runs": []). No AI token data was available for candidate selection. This issue targets the highest-frequency non-excluded workflow based on GitHub Actions run history.


Analysis Period & Runs Analyzed

Metric Value
Analysis window 2026-05-22 → 2026-05-29 (7 days)
Runs analyzed 10 most recent scheduled runs
Run frequency 2× per day (cron 37 */12 * * *)
All conclusions ✅ 10/10 success

Token Profile

This is a pure GitHub Actions maintenance workflow — no AI agent, no LLM calls, no token usage. The optimization focus is on action-minutes cost and runner efficiency.

Metric Value
Avg run duration ~17 s
Active jobs per scheduled run 2 of 9 (cleanup-cache-memory, close-expired-entities)
Skipped jobs per run 7 (dispatch-only operations)
Estimated weekly action minutes ~4 min
AI token usage 0 (no agent invocations)
Per-run duration table (10 runs)
Run ID Duration
§26640788112 15 s
§26612431974 12 s
§26579321258 14 s
§26548717323 18 s
§26515363755 24 s
§26485173936 13 s
§26451557650 17 s
§26426938225 20 s
§26403650320 23 s
§26378517715 15 s

Ranked Recommendations

1. Investigate empty token-data pipeline (high priority)

Estimated savings: Unblocks all future optimization cycles — indirectly high impact.

Evidence: all-runs.json contained {"runs": [], "summary": {}}. All 10 daily snapshot files for the analysis window (2026-05-20 through 2026-05-29.json) show "workflows": []. The rolling-summary is an empty array. This suggests the gh aw logs download step in the audit workflow is returning no data, preventing any AI workflow token tracking.

Action: Verify that the gh aw logs --start-date -1d --json command is producing output on the runner. Check that the audit workflow's GH_TOKEN has actions: read permission and that the agentic workflow runs being tracked are not filtered by a repo-scope mismatch. Add a diagnostic echo of jq '.runs | length' /tmp/gh-aw/token-audit/workflow-logs.json in the setup step so failures surface in the log.

References: §26640788112


2. Reduce repeated Setup Scripts overhead across all 9 job definitions

Estimated token savings per run: ~0 AI tokens. Action-minutes savings: ~1 s per job per run (~28 job-seconds/week).

Evidence: Every one of the 9 job definitions in agentics-maintenance.yml includes the identical Setup Scripts step (uses: github/gh-aw-actions/setup@bc56a0cad...). On each scheduled run, only 2 jobs execute, and each spends 1–2 s on this step before doing 1–2 s of actual work. The setup overhead represents 25–50% of each job's wall time.

Action: The file is auto-generated by pkg/workflow/maintenance_workflow.go. Evaluate whether the generator can emit the setup action as a reusable job output or skip it entirely for jobs that don't require script artifacts (e.g., close-expired-entities uses actions/github-script which doesn't need the gh-aw CLI setup).


3. Relax schedule frequency when all minimum expiries allow it

Estimated savings: ~2 min/week action minutes if frequency halved.

Evidence: The cron comment reads # Every 12 hours (based on minimum expires: 3 days). A 12-hour schedule means the workflow runs 14×/week to enforce a 3-day minimum expiry — that is a 6× safety margin. Running every 24 hours would still give a 3× margin against a 3-day expiry, cutting weekly runs from 14 to 7.

Action: In the generator configuration (expires: 3d or equivalent), evaluate whether the safety margin can be relaxed to produce a 0 */24 * * * schedule. Alternatively, add a check at the top of close-expired-entities that exits early if no entities are approaching expiry, avoiding unnecessary API calls.


Caveats

  • All 10 runs analyzed were scheduled (no workflow_dispatch) — dispatch-only job behavior is unobserved.
  • This workflow is auto-generated; recommendations 2 and 3 require changes to the generator source, not the .yml file directly.
  • The action-minutes savings are small (~2–3 min/week) given the workflow's brevity. The highest-value action (Rec 1) is to restore the token data pipeline so future optimization cycles can target high-AI-cost workflows.
  • Only 10 runs examined; no failures were observed, so no error-recovery token waste was detected.

Generated by Agentic Workflow Token Usage Optimizer · ● 13.8M ·

  • expires on Jun 5, 2026, 3:48 PM UTC

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    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