Target Workflow: build-test.md
Source report: #2262
Estimated cost per run: N/A (cost tracking via AWF api-proxy, not yet in USD)
Total tokens per run: ~453K avg (range: 345K–547K across 8 runs)
Cache hit rate: ~47% (402K cached / 447K input avg)
LLM turns/requests: ~12 requests per run (1 agentic turn)
Current Configuration
| Setting |
Value |
| Tools loaded |
bash: ["*"] + github: (default = ~22 tools) |
| Tools actually used |
bash (shell execution) + github for PR comment + label |
| Network groups |
defaults, github, node, go, rust, crates.io, java, dotnet, bun.sh, deno.land, jsr.io, dl.deno.land |
| Pre-agent steps |
None |
| Prompt size |
8,591 chars (~2,150 tokens) |
| Runtimes |
node 20, go 1.22, rust stable, java 21, dotnet 8.0 (all 5 active) |
Recommendations
1. Restrict GitHub toolset to pull_requests
The workflow only posts a PR comment and adds a label. Yet github: without toolsets: loads the full default set of ~22 tools (repos, issues, PRs, code search, discussions, etc.), each with a schema of ~600 tokens.
Impact: ~19 tools removed × 600 tokens × 12 requests/run = ~136,800 tokens saved per run (~30%)
Change in build-test.md:
tools:
bash:
- "*"
github:
github-token: "$\{\{ secrets.GH_AW_GITHUB_MCP_SERVER_TOKEN }}"
toolsets: [pull_requests]
pull_requests toolset provides: create/update PR comments and add labels — exactly what this workflow needs.
2. Move Maven settings.xml to a pre-agent step
The workflow instructs the agent to write ~/.m2/settings.xml before every Java test run. This is deterministic boilerplate — no LLM reasoning required. Moving it to steps: saves one agent action and removes ~40 lines of verbose instructions from the prompt.
Estimated savings: ~5K tokens/run (~1%) + reduced prompt complexity
Change in build-test.md — add a steps: block before the prompt body:
steps:
- 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
Then remove the "Configure Maven Proxy" section (lines 162–179) from the prompt — replace with a single note: Maven proxy is pre-configured.
3. Trim unused network groups
The workflow loads bun.sh, deno.land, jsr.io, and dl.deno.land as individual entries alongside named groups. While these are needed when those tasks run, the named groups (node, go, rust, java, dotnet) each expand to multiple domains internally. Review whether any named groups pull in domains not needed for simple package install + test.
Specific candidates for removal if the corresponding ecosystem repos are gone from the test suite:
crates.io (separate from rust group) — verify if cargo resolves via the rust group already
bun.sh / deno.land / jsr.io / dl.deno.land — keep only if Bun and Deno tasks remain
Estimated savings: Minimal token impact (network groups don't affect LLM tokens), but reduces firewall attack surface and startup time.
4. Improve cache hit rate with prompt prefix stability
Current cache efficiency is ~47%. The prompt is fully static (no run-specific IDs or timestamps injected), which is good. The main driver of cache misses is likely the ambient context (~29K tokens per session), which includes repository metadata that changes between runs.
To maximize cache benefit:
- Ensure the static prompt text comes before any dynamic content in the assembled context.
- The current structure already does this (static
.md prompt → dynamic tool results). No change needed, but if ambient context is ever extended with dynamic data, keep it at the end.
Estimated savings from improvement: ~15–20K tokens/run if cache efficiency reaches 60% (~3–4%).
Expected Impact
| Metric |
Current |
Projected |
Savings |
| Total tokens/run |
~453K |
~316K |
−30% |
| Requests/run |
~12 |
~12 |
— |
| GitHub tools loaded |
~22 |
~3 |
−19 tools |
| Prompt tokens (tools) |
~264K |
~108K |
−156K |
| Action minutes/run |
~5.1 min |
~3.5 min (est.) |
−30% |
Token savings are dominated by recommendation #1. Recommendations #2 and #3 are lower-impact but reduce prompt complexity and maintenance burden.
Implementation Checklist
Generated by Daily Copilot Token Optimization Advisor · ● 411K · ◷
Target Workflow:
build-test.mdSource report: #2262
Estimated cost per run: N/A (cost tracking via AWF api-proxy, not yet in USD)
Total tokens per run: ~453K avg (range: 345K–547K across 8 runs)
Cache hit rate: ~47% (402K cached / 447K input avg)
LLM turns/requests: ~12 requests per run (1 agentic turn)
Current Configuration
bash: ["*"]+github:(default = ~22 tools)bash(shell execution) +githubfor PR comment + labeldefaults,github,node,go,rust,crates.io,java,dotnet,bun.sh,deno.land,jsr.io,dl.deno.landRecommendations
1. Restrict GitHub toolset to
pull_requestsThe workflow only posts a PR comment and adds a label. Yet
github:withouttoolsets:loads the full default set of ~22 tools (repos, issues, PRs, code search, discussions, etc.), each with a schema of ~600 tokens.Impact: ~19 tools removed × 600 tokens × 12 requests/run = ~136,800 tokens saved per run (~30%)
Change in
build-test.md:pull_requeststoolset provides: create/update PR comments and add labels — exactly what this workflow needs.2. Move Maven settings.xml to a pre-agent step
The workflow instructs the agent to write
~/.m2/settings.xmlbefore every Java test run. This is deterministic boilerplate — no LLM reasoning required. Moving it tosteps:saves one agent action and removes ~40 lines of verbose instructions from the prompt.Estimated savings: ~5K tokens/run (~1%) + reduced prompt complexity
Change in
build-test.md— add asteps:block before the prompt body:Then remove the "Configure Maven Proxy" section (lines 162–179) from the prompt — replace with a single note:
Maven proxy is pre-configured.3. Trim unused network groups
The workflow loads
bun.sh,deno.land,jsr.io, anddl.deno.landas individual entries alongside named groups. While these are needed when those tasks run, the named groups (node,go,rust,java,dotnet) each expand to multiple domains internally. Review whether any named groups pull in domains not needed for simple package install + test.Specific candidates for removal if the corresponding ecosystem repos are gone from the test suite:
crates.io(separate fromrustgroup) — verify ifcargoresolves via therustgroup alreadybun.sh/deno.land/jsr.io/dl.deno.land— keep only if Bun and Deno tasks remainEstimated savings: Minimal token impact (network groups don't affect LLM tokens), but reduces firewall attack surface and startup time.
4. Improve cache hit rate with prompt prefix stability
Current cache efficiency is ~47%. The prompt is fully static (no run-specific IDs or timestamps injected), which is good. The main driver of cache misses is likely the ambient context (~29K tokens per session), which includes repository metadata that changes between runs.
To maximize cache benefit:
.mdprompt → dynamic tool results). No change needed, but if ambient context is ever extended with dynamic data, keep it at the end.Estimated savings from improvement: ~15–20K tokens/run if cache efficiency reaches 60% (~3–4%).
Expected Impact
Implementation Checklist
toolsets: [pull_requests]undergithub:in.github/workflows/build-test.mdsteps:block for Maven settings.xml pre-configurationcrates.iois not already covered by therustnetwork group; remove if redundantgh aw compile .github/workflows/build-test.mdnpx tsx scripts/ci/postprocess-smoke-workflows.ts