Target Workflow: Build Test Suite
Source report: #5476
AIC per run: ~120.2 (highest in the fleet; token data unavailable — see instrumentation note below)
Total tokens per run: unavailable (0 reported — api-proxy token accounting not active)
Estimated cost per run: $0.00 reported (no token accounting)
LLM turns per run: unknown (not instrumented)
Runs analyzed: 3 (all successful)
⚠️ Instrumentation gap: All 50 Copilot runs in the latest report show 0 tokens/$0.00. Recommendations are based on static workflow analysis and AIC (Actions Intelligence Credits) as a proxy for model usage. AIC avg 120.2/run is the highest of all 15 workflows in the fleet.
Current Configuration
| Setting |
Value |
| Tools loaded |
2 — bash: ["*"], github: (no toolsets restriction ≈ 22 tools) |
| Tools actually used |
bash, add_comment, add_label (3 effective tools) |
| Network groups |
12 — defaults, github, node, go, rust, crates.io, java, dotnet, bun.sh, deno.land, jsr.io, dl.deno.land |
| Pre-agent steps |
❌ None |
| Post-agent steps |
❌ None |
| Prompt size |
~8,806 chars (~2,200 tokens) |
| Tasks |
8 sequential ecosystems: Bun, C++, Deno, .NET, Go, Java, Node.js, Rust |
| Test repos cloned |
8 (all inside agent via bash tool calls) |
Recommendations
1. Restrict GitHub MCP Tool Toolsets
Estimated savings: ~10,200 tokens per LLM turn (~80% of tool schema overhead)
Currently github: loads the full GitHub MCP server with no toolsets: restriction. This loads ~22 tool schemas into the context window on every LLM turn. The workflow only uses three GitHub operations: post a PR comment, add a label, and optionally read the PR. Restricting to [pull_requests, issues] reduces loaded tools to ~5.
Change in .github/workflows/build-test.md frontmatter:
# BEFORE
tools:
bash:
- "*"
github:
github-token: "${{ secrets.GH_AW_GITHUB_MCP_SERVER_TOKEN }}"
# AFTER
tools:
bash:
- "*"
github:
github-token: "${{ secrets.GH_AW_GITHUB_MCP_SERVER_TOKEN }}"
toolsets: [pull_requests, issues]
At ~600 tokens per tool schema, removing ~17 unused tools saves ~10,200 tokens per LLM turn. With an estimated 15–20 turns per run, this is ~153K–204K tokens saved per run.
2. Move Repo Clones and Runtime Setup to Pre-Agent Steps
Estimated savings: 8–16 LLM turns per run (eliminates clone bash-call/response cycles)
Currently the agent clones 8 repos, installs Bun via curl, installs Deno via curl, and creates ~/.m2/settings.xml — all as bash tool calls that consume LLM turns. These are deterministic setup operations with no branching logic; they do not require LLM judgment. Moving them to steps: pre-computes them before the agent starts.
Add to .github/workflows/build-test.md frontmatter:
steps:
- name: Clone test repositories
run: |
git clone https://github.com/Mossaka/gh-aw-firewall-test-bun.git /tmp/test-bun &
git clone https://github.com/Mossaka/gh-aw-firewall-test-cpp.git /tmp/test-cpp &
git clone https://github.com/Mossaka/gh-aw-firewall-test-deno.git /tmp/test-deno &
git clone https://github.com/Mossaka/gh-aw-firewall-test-dotnet.git /tmp/test-dotnet &
git clone https://github.com/Mossaka/gh-aw-firewall-test-go.git /tmp/test-go &
git clone https://github.com/Mossaka/gh-aw-firewall-test-java.git /tmp/test-java &
git clone https://github.com/Mossaka/gh-aw-firewall-test-node.git /tmp/test-node &
git clone https://github.com/Mossaka/gh-aw-firewall-test-rust.git /tmp/test-rust &
wait
- name: Install Bun
run: |
curl -fsSL (bun.sh/redacted) | bash
echo "$HOME/.bun/bin" >> $GITHUB_PATH
- name: Install Deno
run: |
curl -fsSL (deno.land/redacted) | sh
echo "$HOME/.deno/bin" >> $GITHUB_PATH
- name: Configure Maven proxy
run: |
mkdir -p ~/.m2
cat > ~/.m2/settings.xml << 'SETTINGS'
<settings>
<proxies>
<proxy>
<id>awf-http</id><active>true</active><protocol>http</protocol>
<host>squid-proxy</host><port>3128</port>
</proxy>
<proxy>
<id>awf-https</id><active>true</active><protocol>https</protocol>
<host>squid-proxy</host><port>3128</port>
</proxy>
</proxies>
</settings>
SETTINGS
Update the prompt body to remove the clone, Bun install, Deno install, and Maven proxy setup instructions from Tasks 1, 3, 6. Replace each with: Repos are pre-cloned to /tmp/test-<ecosystem>. Runtimes are pre-installed. Maven ~/.m2/settings.xml is pre-configured.
This eliminates ~22 LLM turns (8 clones × 2 turns each + 4 install turns + 2 config turns) and removes ~1,800 chars (~450 tokens) from the prompt body.
3. Compress Prompt Body
Estimated savings: ~600–800 tokens per run (constant per-turn overhead)
The 8,806-char prompt has three areas to cut:
a. Remove redundant bash command detail — Tasks 1–8 each include exact bash commands the agent already knows (e.g., bun install && bun test, go mod download && go test ./...). Once repos are pre-cloned, instructions can be shortened to:
Test each project: run install then test using the ecosystem's standard tool.
b. Collapse the combined output table template (~50 lines, ~1,200 chars). Replace the 18-row table template with a short prose description of the desired format:
Produce a single markdown table with columns: Ecosystem, Project, Build/Install (✅/❌), Tests (N/M passed), Status (✅ PASS / ❌ FAIL). Add build-test label if all pass.
c. Shorten the Error Handling section (currently 15 lines). Replace with:
On clone failure: record CLONE_FAILED and continue. If ALL clones fail, call safeoutputs missing_tool with reason "ALL_CLONES_FAILED".
Estimated prompt reduction: ~2,500 chars → ~1,600 chars (save ~225 tokens × N turns ≈ 3,375 tokens/run at 15 turns).
4. Add Post-Agent Validation Step
Estimated savings: 1–3 LLM turns per run (agent stops second-guessing its output)
Currently the agent has no post-validation hook, so it tends to re-read its output and self-check before posting the PR comment. Adding a post-steps: assertion that verifies the PR comment was posted reduces the agent's uncertainty-driven extra turns.
post-steps:
- name: Verify PR comment posted
uses: actions/github-script@v9
with:
script: |
const comments = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
const hasResult = comments.data.some(c => c.body.includes('Build Test Suite Results'));
if (!hasResult) core.setFailed('Agent did not post results comment');
Expected Impact
| Metric |
Current |
Projected |
Savings |
| GitHub tools in context |
~22 |
~5 |
−77% tool schemas |
| Tokens/turn (tool overhead) |
~13,200 |
~3,000 |
~−10,200/turn |
| Total tokens/run (est.) |
~200K–300K |
~60K–100K |
~−55–70% |
| LLM turns/run (est.) |
~20–25 |
~8–12 |
~−10 turns |
| AIC/run |
~120 |
~45–60 |
~−50–60% |
| Prompt tokens |
~2,200 |
~1,400 |
−800 tokens |
| Pre-agent repo clone time |
In-agent (serial) |
Parallel pre-step |
−40–60% setup time |
Implementation Checklist
Generated by Daily Copilot Token Optimization Advisor · 39.1 AIC · ⊞ 6.7K · ◷
Target Workflow:
Build Test SuiteSource report: #5476
AIC per run: ~120.2 (highest in the fleet; token data unavailable — see instrumentation note below)
Total tokens per run: unavailable (0 reported — api-proxy token accounting not active)
Estimated cost per run: $0.00 reported (no token accounting)
LLM turns per run: unknown (not instrumented)
Runs analyzed: 3 (all successful)
Current Configuration
bash: ["*"],github:(no toolsets restriction ≈ 22 tools)bash,add_comment,add_label(3 effective tools)Recommendations
1. Restrict GitHub MCP Tool Toolsets
Estimated savings: ~10,200 tokens per LLM turn (~80% of tool schema overhead)
Currently
github:loads the full GitHub MCP server with notoolsets:restriction. This loads ~22 tool schemas into the context window on every LLM turn. The workflow only uses three GitHub operations: post a PR comment, add a label, and optionally read the PR. Restricting to[pull_requests, issues]reduces loaded tools to ~5.Change in
.github/workflows/build-test.mdfrontmatter:At ~600 tokens per tool schema, removing ~17 unused tools saves ~10,200 tokens per LLM turn. With an estimated 15–20 turns per run, this is ~153K–204K tokens saved per run.
2. Move Repo Clones and Runtime Setup to Pre-Agent Steps
Estimated savings: 8–16 LLM turns per run (eliminates clone bash-call/response cycles)
Currently the agent clones 8 repos, installs Bun via
curl, installs Deno viacurl, and creates~/.m2/settings.xml— all as bash tool calls that consume LLM turns. These are deterministic setup operations with no branching logic; they do not require LLM judgment. Moving them tosteps:pre-computes them before the agent starts.Add to
.github/workflows/build-test.mdfrontmatter:Update the prompt body to remove the clone, Bun install, Deno install, and Maven proxy setup instructions from Tasks 1, 3, 6. Replace each with:
Repos are pre-cloned to /tmp/test-<ecosystem>. Runtimes are pre-installed. Maven ~/.m2/settings.xml is pre-configured.This eliminates ~22 LLM turns (8 clones × 2 turns each + 4 install turns + 2 config turns) and removes ~1,800 chars (~450 tokens) from the prompt body.
3. Compress Prompt Body
Estimated savings: ~600–800 tokens per run (constant per-turn overhead)
The 8,806-char prompt has three areas to cut:
a. Remove redundant bash command detail — Tasks 1–8 each include exact bash commands the agent already knows (e.g.,
bun install && bun test,go mod download && go test ./...). Once repos are pre-cloned, instructions can be shortened to:b. Collapse the combined output table template (~50 lines, ~1,200 chars). Replace the 18-row table template with a short prose description of the desired format:
c. Shorten the Error Handling section (currently 15 lines). Replace with:
Estimated prompt reduction: ~2,500 chars → ~1,600 chars (save ~225 tokens × N turns ≈ 3,375 tokens/run at 15 turns).
4. Add Post-Agent Validation Step
Estimated savings: 1–3 LLM turns per run (agent stops second-guessing its output)
Currently the agent has no post-validation hook, so it tends to re-read its output and self-check before posting the PR comment. Adding a
post-steps:assertion that verifies the PR comment was posted reduces the agent's uncertainty-driven extra turns.Expected Impact
Implementation Checklist
toolsets: [pull_requests, issues]undergithub:tool in frontmattersteps:block with parallel repo clones, Bun install, Deno install, Maven configpost-steps:verification blockgh aw compile .github/workflows/build-test.mdnpx tsx scripts/ci/postprocess-smoke-workflows.ts(if applicable)workflow_dispatchand compare AIC before/after