Skip to content

[copilot-token-optimizer] Delight: reduce 34-turn read-only run (~730K tokens/run savings) #29142

@github-actions

Description

@github-actions

Target Workflow

Delight (delight.md) — highest eligible workflow by total tokens not recently optimized.


Analysis Period

Metric Value
Runs analyzed 1 (2026-04-29)
Total tokens 2,078,746
Effective tokens 2,307,614
Total turns 34
Avg tokens/turn ~61,140
Cache efficiency 96.0% (1,986,014 / 2,068,657 input cached)
Output tokens 10,089 (0.49% — pure read-only run)
Write actions 0
Action minutes 14
Errors / Warnings 0 / 0
Agentic fraction 0.50 (50% of turns assessed as replaceable by deterministic steps)

Cache efficiency is high (96%), meaning the model context prompt is stable. The waste is in turn count, not cache misses.


Key Findings

The workflow is entirely read-only (zero write actions, 0.49% output tokens) yet runs 34 inference turns. The agentic assessment flags it as resource_heavy_for_domain with partially_reducible. Half the turns (≈17) are pure data-gathering that could be pre-computed in deterministic frontmatter steps.


Ranked Recommendations

1. 🔴 Move file-listing and memory-reads to deterministic pre-steps (~350–400K tokens/run)

Evidence: The workflow's Step 1 (Load Historical Memory) and Step 2 (file listing via find ... | shuf -n 2) consume multiple agent turns just to discover what files exist. Each turn re-echoes the full accumulated context (~61K tokens). The agentic_fraction=0.50 assessment explicitly flags this pattern.

Action: Add pre-steps in frontmatter to run find, shuf, and cat memory/... before the agent starts. Write results to /tmp/gh-aw/agent/ and inject file paths into the prompt. Eliminate the agent's exploratory file-discovery turns.

pre-steps:
  - name: Sample files
    run: |
      find docs/src/content/docs -name '*.md' -o -name '*.mdx' | shuf -n 2 > /tmp/gh-aw/agent/doc-samples.txt
      find .github/workflows -name '*.md' | grep -l "messages:" | shuf -n 2 > /tmp/gh-aw/agent/workflow-samples.txt
      cat memory/delight/previous-findings.json 2>/dev/null > /tmp/gh-aw/agent/previous-findings.json || echo "[]" > /tmp/gh-aw/agent/previous-findings.json

Estimated savings: ~6 turns × 61K = ~365K tokens/run


2. 🔴 Remove edit tool (never used) (~20–30K tokens/run + cognitive overhead)

Evidence: actuation_style: "read_only" and write_actions: 0 confirm the edit tool was never invoked. Tool definitions are included in every turn's context.

Action: Remove edit: from the tools: section in delight.md.

Estimated savings: ~20–30K tokens/run (tool schema repeated 34× across turns)


3. 🟡 Replace grep -r '*' docs bash command with scoped allow-list (~100K tokens/run)

Evidence: grep -r '*' docs is an unconstrained recursive grep across the entire docs tree. This wildcard pattern can produce enormous output that fills the context. The bash allow-list should be tightened.

Action: Replace with explicit scoped commands:

bash:
  - "find docs/src/content/docs -name '*.md' -o -name '*.mdx'"
  - "find .github/workflows -name '*.md'"
  - "./gh-aw --help"
  - "./gh-aw * --help"
  - "cat docs/src/content/docs/*.md"
  - "cat docs/src/content/docs/*.mdx"

Remove the wildcard grep -r '*' docs and cat * entries entirely.

Estimated savings: Prevents unbounded output; ~2–3 turns saved = ~100K tokens/run


4. 🟡 Reduce imports: drop shared/jqschema.md if not used for JSON schema validation (~30–50K tokens/run)

Evidence: The workflow produces narrative discussion reports and UX analysis. shared/jqschema.md adds JSON schema tooling context that is not needed for prose output. With 34 turns, any per-turn prompt overhead compounds significantly.

Action: Audit what shared/jqschema.md contributes to this workflow. If it is only used for memory file writes (which could use plain JSON), remove it.

Estimated savings: Import size × 34 turns = estimated ~30–50K tokens/run


Full Token Profile Detail
Field Value
Total input tokens 2,068,657
Total output tokens 10,089
Cache read tokens 1,986,014
Cache write tokens 0
Total requests 34
Total duration 250,687 ms (~4.2 min inference)
Engine claude-sonnet-4.6 via Copilot
Behavior exploratory, narrow tools, read-only, heavy, standalone
GitHub API calls 4
Avg time between turns 24.8s (estimated)

Summary of Estimated Savings

Recommendation Est. Savings/Run
Pre-steps for file listing + memory read ~365,000 tokens
Remove unused edit tool ~25,000 tokens
Tighten bash allow-list (remove grep -r '*') ~100,000 tokens
Drop unused jqschema import ~40,000 tokens
Total conservative estimate ~530,000 tokens/run

At 2.08M tokens/run, this represents a ~25% reduction.


Caveats

  • Only 1 run available for analysis; patterns may vary across days. The file-listing exploratory turns are structural (prompted by the workflow design), making them reliably reproducible.
  • Cache efficiency is already 96%, so prompt restructuring alone will not improve efficiency further — turn reduction is the primary lever.
  • The discussions toolset (GitHub) was loaded; with only 4 GitHub API calls total, it may be over-provisioned, but removing it risks breaking discussion creation at end of run.

References:

Generated by Copilot Token Usage Optimizer · ● 986.6K ·

  • expires on May 6, 2026, 3:32 PM UTC

Metadata

Metadata

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