Skip to content

Optimize Issue Monster workflow: reduce token usage from 337K to 90-170K per run #27083

@lpcox

Description

@lpcox

Summary

The Copilot Token Usage Optimizer (run 24612668312) analyzed the Issue Monster workflow and found it consuming 337K tokens per successful run — over 2x the 150K target and exceeding its own 300K alert threshold. The optimizer was unable to file this issue automatically due to the AWF firewall port 8080 regression (fixed in #27080).

Current Metrics

Metric Value Target
Avg tokens/run 337K 50-150K
Avg turns/run 11.7 ~5
Input:output ratio ~150:1
Cache efficiency 44-47%
Failure rate 70% (7/10)
GitHub tools loaded 22 ~5

Trend (worsening)

  • April 7: 261K tokens/run, 5.9 turns (13 runs)
  • April 17: 228K tokens/run, 5.2 turns (5 runs)
  • April 18: 337K tokens/run, 11.7 turns (3 successful runs) ⚠️

Root Causes

1. Overly broad GitHub toolset

The workflow uses [default, pull_requests] toolsets, loading 22 tools when it only needs issue-related tools. Each tool definition adds ~2.5-3K tokens to the system prompt.

Impact: ~63K tokens/run (19% of total)

2. Model mismatch

Config specifies gpt-5.1-codex-mini but runs actually execute on claude-sonnet-4.6. This likely explains the spike in turn count (5.2 → 11.7) and token usage between April 17-18.

3. 50% of turns are reducible data-gathering

The agentic assessment flagged partially_reducible — approximately 50% of agent turns are data-gathering (reading issue bodies/comments) that could be moved to deterministic pre-activation bash steps.

Impact: ~90-150K tokens/run

4. Instruction duplication in prompt

Sections 1 and 2 of the workflow prompt cover the same ground — Section 1 describes what the pre-activation job does, Section 2 repeats it with slight variations. This inflates the system prompt unnecessarily.

5. Reads full issue bodies + comments

The agent reads full issue content including all comments when body-only would often suffice for triage decisions.

Impact: ~15-30K tokens/run

6. Poor agentic control

The agentic assessment flagged poor_agentic_control (medium severity): friction=0 execution=exploratory actuation=read_only — the workflow has broad tool access and exploratory execution patterns.

Recommendations

R1: Narrow GitHub toolset to [issues]

Replace [default, pull_requests] with [issues] in the tools configuration. The workflow only triages issues — it does not need PR, repo, or code search tools.

Estimated savings: ~63K tokens/run (19%)

R2: Downgrade model to claude-haiku-4.5

The agentic assessment flagged model_downgrade_available. Issue triage is a structured, well-defined task that does not require a large reasoning model. Haiku would be 5-8x cheaper per token.

R3: Pre-read issue bodies in bash pre-activation step

Move issue body reading into a deterministic bash step during pre-activation. Pass the pre-fetched content to the agent prompt instead of having the agent make redundant API calls.

Estimated savings: 90-150K tokens/run

R4: Restrict to body-only (no comments)

For triage decisions, issue body is usually sufficient. Only read comments when the body is ambiguous or when specific triage rules require comment context.

Estimated savings: 15-30K tokens/run

R5: Clean up prompt — remove duplication

Consolidate sections 1 and 2 into a single clear instruction section. Remove verbose success criteria that repeat the instructions.

Projected Impact

Scenario Tokens/run Weekly (10 runs)
Current 337K 3.36M
R1 only (toolset) 274K 2.74M
R1 + R3 (toolset + pre-read) 124-184K 1.24-1.84M
All recommendations 90-170K 0.9-1.7M

Implementing all recommendations would bring token usage within the 50-150K target range.

Source

Analysis performed by the Copilot Token Usage Optimizer workflow on April 18, 2026. The optimizer could not file this issue automatically because the MCP gateway port 8080 was blocked by AWF firewall rules (fixed in #27080).

Metadata

Metadata

Assignees

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