Add tool-usage efficiency hints to copilot-token-optimizer Phase 2 prompt#28827
Add tool-usage efficiency hints to copilot-token-optimizer Phase 2 prompt#28827
Conversation
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/80fb6381-531e-4789-867d-df6fd9990398 Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
… recompile lock file Agent-Logs-Url: https://github.com/github/gh-aw/sessions/80fb6381-531e-4789-867d-df6fd9990398 Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds more specific “tool-usage efficiency” anti-pattern checks to the copilot-token-optimizer Phase 2 prompt so audits produce more actionable token-saving recommendations, and refreshes the compiled action pin lock data.
Changes:
- Add a new “Tool-Usage Efficiency Patterns” subsection with concrete anti-patterns to detect during run audits.
- Update
ruby/setup-rubyaction pin fromv1.305.0tov1.306.0(incl. SHA) in the compiled pin data.
Show a summary per file
| File | Description |
|---|---|
.github/workflows/copilot-token-optimizer.md |
Extends Phase 2 analysis guidance with explicit tool-usage anti-pattern detection bullets. |
pkg/workflow/data/action_pins.json |
Updates the pinned ruby/setup-ruby version and SHA in workflow action pin data. |
pkg/actionpins/data/action_pins.json |
Mirrors the same ruby/setup-ruby pin update in the actionpins package dataset. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 3/3 changed files
- Comments generated: 2
|
|
||
| - **Batch independent reads**: look for sequential file reads or API calls that could be requested in a single tool-use block — each extra turn repeats the full context | ||
| - **Chain bash commands**: look for separate bash tool calls that could be combined with `&&` — each call adds a full context echo | ||
| - **Prefer typed tools**: look for `bash cat`, `bash grep`, `bash find -name` when `view`, `grep`, `glob` would return more concise output |
There was a problem hiding this comment.
The prompt recommends using view, grep, and glob as “typed tools”, but those tool names aren’t documented as GH-AW built-in tools in the repo’s Tools reference (docs/src/content/docs/reference/tools.md lists edit, bash, github, etc.). This risks the optimizer producing recommendations that can’t be applied to actual runs. Consider rewording this bullet to reference the documented tools (e.g., edit for file reads / edits) or to describe the behavior generically (e.g., “prefer built-in file read/search tools over shelling out”) without naming potentially-nonexistent tools.
| - **Prefer typed tools**: look for `bash cat`, `bash grep`, `bash find -name` when `view`, `grep`, `glob` would return more concise output | |
| - **Prefer built-in file read/search tools over shelling out**: look for `bash cat`, `bash grep`, or `bash find -name` when documented built-in tools could return more concise output |
| - **Batch independent reads**: look for sequential file reads or API calls that could be requested in a single tool-use block — each extra turn repeats the full context | ||
| - **Chain bash commands**: look for separate bash tool calls that could be combined with `&&` — each call adds a full context echo | ||
| - **Prefer typed tools**: look for `bash cat`, `bash grep`, `bash find -name` when `view`, `grep`, `glob` would return more concise output | ||
| - **Consolidate GitHub API sequences**: look for multiple sequential `gh api` calls that could be combined into fewer round-trips with `jq` filtering |
There was a problem hiding this comment.
This new guidance encourages consolidating gh api sequences, but repository guidance for Copilot workflows explicitly discourages direct GitHub CLI API reads in prompts in favor of GitHub MCP tools (see AGENTS.md:176). Given the firewall restrictions called out in the PR description, gh api calls may be blocked and lead to retries/token waste. Consider changing this bullet to focus on consolidating GitHub MCP calls (toolset selection + narrowing fields/limits) or, if gh api is intentionally used here, add a brief note explaining why it’s acceptable for this workflow and how to avoid blocked endpoints (e.g., prefer REST over GraphQL when needed).
| - **Consolidate GitHub API sequences**: look for multiple sequential `gh api` calls that could be combined into fewer round-trips with `jq` filtering | |
| - **Consolidate GitHub reads**: prefer fewer, narrower GitHub MCP calls by selecting only the needed tool, fields, and limits; if `gh api` is required for this workflow, avoid blocked endpoints and prefer REST over GraphQL when restrictions apply |
The
copilot-token-optimizerPhase 2 analysis matrix lacks specific anti-pattern detection guidance, resulting in generic rather than actionable optimization recommendations.Changes
.github/workflows/copilot-token-optimizer.md: Added### Tool-Usage Efficiency Patternssubsection between the analysis matrix and the Rules block, listing five anti-patterns the agent should actively detect:&&bash cat/grep/findwhere typed tools (view/grep/glob) return more concise outputgh apicalls combinable into fewer round-trips viajqLock file: Recompiled via
make recompile(204/204 workflows).Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
https://api.github.com/graphql/usr/bin/gh /usr/bin/gh api graphql -f query=query($owner: String!, $name: String!) { repository(owner: $owner, name: $name) { hasDiscussionsEnabled } } -f owner=github -f name=gh-aw(http block)/usr/bin/gh /usr/bin/gh api graphql -f query=query($owner: String!, $name: String!) { repository(owner: $owner, name: $name) { hasDiscussionsEnabled } } -f owner=github -f name=gh-aw 67d-df6fd9990398-C(http block)/usr/bin/gh /usr/bin/gh api graphql -f query=query($owner: String!, $name: String!) { repository(owner: $owner, name: $name) { hasDiscussionsEnabled } } -f owner=github -f name=gh-aw 67d-df6fd9990398-1(http block)https://api.github.com/repos/actions/checkout/git/ref/tags/v6/usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v6 --jq [.object.sha, .object.type] | @tsv(http block)https://api.github.com/repos/actions/setup-node/git/ref/tags/v6/usr/bin/gh gh api /repos/actions/setup-node/git/ref/tags/v6 --jq [.object.sha, .object.type] | @tsv(http block)https://api.github.com/repos/astral-sh/setup-uv/git/ref/tags/eac588ad8def6316056a12d4907a9d4d84ff7a3b/usr/bin/gh gh api /repos/astral-sh/setup-uv/git/ref/tags/eac588ad8def6316056a12d4907a9d4d84ff7a3b --jq [.object.sha, .object.type] | @tsv(http block)https://api.github.com/repos/github/gh-aw/usr/bin/gh gh api /repos/github/gh-aw --jq .default_branch(http block)If you need me to access, download, or install something from one of these locations, you can either: