Conversation
…fficiency guidance Agent-Logs-Url: https://github.com/github/gh-aw/sessions/957dfe49-1532-4eeb-aba9-20f065883a3d Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
pelikhan
May 1, 2026 01:59
View session
pelikhan
approved these changes
May 1, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the Copilot Token Optimizer workflow prompt to better match mode: gh-proxy usage and to encourage token-efficient GitHub API access patterns (bash + gh api --jq + targeted slicing).
Changes:
- Add a new “Data Access Guidelines” section with
gh api --jqexamples intended to reduce token waste from large JSON payloads. - Update Phase 2/3 instructions to reference extracting only frontmatter/prompt slices from workflow sources instead of generic “cli-proxy” wording.
- Pass
GH_AW_GITHUB_REPOSITORYinto the “Interpolate variables and render templates” step in the locked workflow.
Show a summary per file
| File | Description |
|---|---|
| .github/workflows/copilot-token-optimizer.md | Adds/updates prompt guidance for token-efficient gh api --jq usage and targeted extraction of workflow source sections. |
| .github/workflows/copilot-token-optimizer.lock.yml | Adds GH_AW_GITHUB_REPOSITORY env var to the interpolate/render step environment. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comments suppressed due to low confidence (1)
.github/workflows/copilot-token-optimizer.md:226
- This
awkcommand does not extract only the prompt body after the closing---. As written, it starts printing after the first---, so it includes the entire frontmatter (and the closing delimiter) in the output. Update the command to begin output only after the second---delimiter so the “prompt body only” instruction is accurate.
# Extract the prompt body only (everything after the closing ---)
gh api "repos/$REPO/contents/$WF_PATH" --jq '.content' | base64 -d \
| awk 'f; /^---$/{f=1}'
- Files reviewed: 2/2 changed files
- Comments generated: 4
|
|
||
| # Extract frontmatter only (tools, features, network, permissions) | ||
| gh api "repos/$REPO/contents/$WF_PATH" --jq '.content' | base64 -d \ | ||
| | awk '/^---$/{n++; if(n==2) exit} n==1' |
| uses: actions/github-script@373c709c69115d41ff229c7e5df9f8788daa9553 # v9 | ||
| env: | ||
| GH_AW_PROMPT: /tmp/gh-aw/aw-prompts/prompt.txt | ||
| GH_AW_GITHUB_REPOSITORY: ${{ github.repository }} |
|
|
||
| ## Data Access Guidelines | ||
|
|
||
| All GitHub API access goes through the `gh` CLI via the cli-proxy — there are **no GitHub MCP tools** available. Always filter API responses with `--jq` or pipe through `jq` to extract only the fields you need. Loading full JSON payloads into context wastes tokens; every extra field is overhead. |
|
|
||
| # ✅ Combine multi-step reads into one bash block with pipes | ||
| gh api "repos/$REPO/contents/.github/workflows/my-workflow.md" \ | ||
| --jq '.content' | base64 -d | sed -n '1,/^---$/{ /^---$/d; p }' | head -40 |
This was referenced May 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The token optimizer workflow prompt still referenced vague "cli-proxy" guidance and lacked concrete instructions for token-efficient GitHub API access, despite the frontmatter already declaring
mode: gh-proxy.Changes
New "Data Access Guidelines" section — explicitly declares no GitHub MCP tools are available; provides
✅/❌examples showinggh api --jqfiltering vs. loading full unfiltered payloads into context:Phase 2 analysis matrix — "Tool usage" row now references
gh api --jq '.content' | base64 -d | sed -n …to extract only frontmatter instead of the generic "via cli-proxy" phrase.Phase 3 (Read Workflow Source) — replaced the paragraph with concrete bash snippets using
gh api --jq+awkone-liners to slice out frontmatter or prompt body independently, avoiding full-file loads.