Skip to content

[agentic-token-optimizer] Daily XKCD Comic — prompt & tool efficiency optimizations #388

Description

@github-actions

Target Workflow

Daily XKCD Comic (daily-xkcd.md) — selected as the highest-AIC workflow not optimized in the last 14 days (last optimized 2026-07-30, 8 days ago). All workflows above it in the ranking were optimized within the 14-day exclusion window.


Analysis Period

7-day window ending 2026-08-07 · 7 runs analyzed · 100% success rate

Spend Profile

Metric Value
Total AIC 350.96
Avg AIC / run 50.14
Total tokens 126,799
Avg tokens / run 18,114
Total turns 5
Avg action minutes / run 5.3
Failure rate 0%

Note: Token and turn data was fully recorded for only 1 of 7 runs in all-runs.json; aggregate figures from top-workflows.json are used for the spend profile. All 7 runs completed successfully.


Ranked Recommendations

1. Read latest comic from pre-fetched file instead of web_fetch

Estimated savings: ~3–5 AIC/run

The setup step already fetches (xkcd.com/redacted) and saves the full response to /tmp/gh-aw/agent/xkcd/latest.json. The prompt then instructs the agent to "fetch it and read its title/alt text" — which is ambiguous and can cause the agent to issue a redundant web_fetch` for the same URL.

Current (Step 2 in Instructions):

Check if the latest comic is relevant (fetch it and read its title/alt text) — if yes, use it.

Proposed:

Check if the latest comic is relevant — read its title and alt text from the pre-fetched
`/tmp/gh-aw/agent/xkcd/latest.json` (no network call needed). If relevant, use it.

This eliminates a redundant web_fetch call in the common path, saving 1 tool round-trip (~1 turn) per run.

Evidence: With avg 50 AIC/run and a 5-turn ceiling on observed runs, each saved tool call represents 5–10% of per-run cost.


2. Flatten and compress the curated comic list

Estimated savings: ~1–2 AIC/run

The Comic Selection section uses three bold-header groups with markdown formatting that adds ~150 extra prompt tokens per run:

**Developer life classics**: 303, 327, 353, ...
**Math & statistics**: 55, 135, 174, ...
**ML, AI & LLMs**: 1838, 1875, 2050, ...

Since the agent only needs the numbers (not the category labels for selection), these can be inlined into a single flat list with a brief comment:

Pick from this curated list (developer life · math · ML/AI):
303 327 353 386 456 519 664 705 722 737 844 859 936 1068 1168 1205 1319 1425 1443 1537 1739
55 135 174 687 712 715 881 882 1236 1261 1379 1478 1754 2048 2100
1838 1875 2050 2173 2347 2440 2501 2545 2581 2674 2746 2785 2860 2916 2925

This preserves grouping (for human readability) while removing the bold-header markdown syntax and the redundant labels from each line.


3. Remove expr from configured bash tools

Estimated savings: <1 AIC/run (cleanliness)

expr is listed in the workflow's tools.bash configuration but the workflow logic only needs date +%j output and a modulo operation. Both bash arithmetic $(( n % m )) and jq -n handle this natively without expr. Removing it tightens the tool schema passed to the model each turn.

Current frontmatter:

tools:
  bash:
    - "curl"
    - "jq"
    - "bash"
    - "echo"
    - "date"
    - "expr"

Proposed: Remove "expr" from the list.

Evidence: No observed run required expr — bash arithmetic $(( )) subsumes it. Removing unused tools reduces per-turn schema tokens marginally and avoids the model attempting expr-based commands unnecessarily.


Caveats

  • Token/turn data was available for only 1 of 7 runs in the raw log; aggregate savings estimates are based on the observed turn structure and avg AIC from pre-aggregated data.
  • Rec 1 savings depend on whether the agent was actually issuing a redundant web_fetch — the observed 5-turn run likely included this, but confirmation requires run-level trace data.
  • No reliability issues observed; all 7 runs succeeded.
  • No inline sub-agent opportunities identified — the workflow is a single sequential flow (read → select → fetch → post) with strong interdependence between steps; sub-agents would add overhead without parallelism benefit.

Generated by Agentic Workflow AIC Usage Optimizer · 97.7 AIC · ⊞ 21.6K ·

  • expires on Aug 14, 2026, 2:47 PM UTC

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions