Conversation
…uidelines, narrow toolset, reduce batch size - Replace Step 2.5 'Deep Research' with 'Targeted Context' in contribution-checker.agent.md (removes repo browsing, surrounding code reads, and duplicate PR searches) - Pre-fetch CONTRIBUTING.md once in the pre-agent bash step; pass it inline to each subagent dispatch to eliminate 9 redundant fetches per run - Narrow GitHub toolset from [default] to [pull_requests, repos, issues] - Reduce MAX_EVALUATE from 10 to 5 to cap token usage on high-traffic days - Recompile contribution-check.lock.yml Resolves: copilot-token-optimizer issue (~46% token reduction estimated)" Agent-Logs-Url: https://github.com/github/gh-aw/sessions/b996051a-b125-4b10-a8e1-20f02279380e Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Optimize contribution check for token efficiency
Token optimization for contribution-check: trim deep research, pre-fetch guidelines, narrow toolset, reduce batch cap
Apr 14, 2026
This was referenced Apr 14, 2026
Closed
Contributor
There was a problem hiding this comment.
Pull request overview
Reduces token usage in the scheduled contribution-check workflow by limiting per-PR context gathering, reusing a single CONTRIBUTING.md fetch across subagent calls, narrowing GitHub MCP toolsets, and lowering the per-run PR evaluation cap.
Changes:
- Replace “Deep Research” with “Targeted Context” in the contribution-checker subagent instructions.
- Pre-fetch CONTRIBUTING.md once in the workflow and instruct the orchestrator to inline it into each subagent dispatch.
- Narrow GitHub MCP toolsets to
[pull_requests, repos, issues]and reduce the PR batch cap from 10 to 5.
Show a summary per file
| File | Description |
|---|---|
| .github/workflows/contribution-check.md | Updates orchestrator workflow prompt + pre-agent bash to pre-fetch CONTRIBUTING.md, narrow toolsets, and lower batch size. |
| .github/workflows/contribution-check.lock.yml | Regenerated compiled workflow to reflect toolset + prefetch + batch cap changes. |
| .github/agents/contribution-checker.agent.md | Updates subagent behavior to accept inline guidelines and avoids expensive repo exploration via “Targeted Context”. |
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: 3
| ## Step 1: Fetch Contributing Guidelines | ||
|
|
||
| Fetch the target repository's contributing guidelines. Look for these files in order and use the **first one found**: | ||
| If the CONTRIBUTING.md content was provided inline at the start of this prompt (inside `<contributing-guidelines>` tags), use that content directly and skip this step. If the inline content is `# No CONTRIBUTING.md found`, treat it as missing guidelines and return a single row with verdict `❓` and quality `no-guidelines`. |
| 3. **Check for related issues** — if the PR body references an issue, read that issue to understand the original requirements and acceptance criteria. | ||
| 4. **Check for existing tests** — look at the test directory/files adjacent to the changed code. Understand the testing patterns and frameworks the project uses so your feedback and agentic prompts reference the right tools and conventions. | ||
| 5. **Check for duplicated effort** — search for open PRs that touch the same files or address the same issue to flag potential conflicts. | ||
| - Read the PR diff and changed files carefully to understand what's changing. |
Comment on lines
+123
to
127
| Read the contents of `contributing-guidelines.md` from the workspace root. This file was pre-fetched in the `pre-agent` step and contains the target repository's contributing guidelines. Include it verbatim in every subagent dispatch prompt to avoid redundant fetches. | ||
|
|
||
| Call the contribution-checker subagent for each PR with this prompt: | ||
|
|
||
| ``` |
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 contribution-check workflow was consuming ~2.8M tokens/run (peaking at 11.2M) due to expensive per-PR deep research, redundant CONTRIBUTING.md fetches across all subagent instances, an oversized default GitHub toolset, and a 10-PR batch cap.
Changes
.github/agents/contribution-checker.agent.md<contributing-guidelines>tags to skip redundant fetching; treats# No CONTRIBUTING.md foundsentinel as missing guidelines (❓/no-guidelines).github/workflows/contribution-check.md.github/→docs/), write tocontributing-guidelines.md, log which location succeeded or that none was found[default](30+ tools) →[pull_requests, repos, issues]MAX_EVALUATE=10→MAX_EVALUATE=5Estimated savings
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 -pack /home/REDACTED/work/gh-aw/gh-aw/cmd/gh-aw/main.go(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 TAUnjV2J-Fmj2/eR-c(http block)https://api.github.com/repos/actions/upload-artifact/git/ref/tags/v7/usr/bin/gh gh api /repos/actions/upload-artifact/git/ref/tags/v7 --jq .object.sha(http block)/usr/bin/gh gh api /repos/actions/upload-artifact/git/ref/tags/v7 --jq .object.sha ck(http block)/usr/bin/gh gh api /repos/actions/upload-artifact/git/ref/tags/v7 --jq .object.sha ithub/workflows credential.helper ker/cli-plugins/docker-buildx(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(http block)/usr/bin/gh gh api /repos/astral-sh/setup-uv/git/ref/tags/eac588ad8def6316056a12d4907a9d4d84ff7a3b --jq .object.sha k/gh-aw/gh-aw/.g--irreversible-delete main me: String!) { 6096c38537e2b93ec370a5412a3aceb91df212de(http block)/usr/bin/gh gh api /repos/astral-sh/setup-uv/git/ref/tags/eac588ad8def6316056a12d4907a9d4d84ff7a3b --jq .object.sha ithub/workflows main repository(owner: $owner, name: $name) { hasDiscussionsEnabled } }(http block)https://api.github.com/repos/docker/build-push-action/git/ref/tags/v7/usr/bin/gh gh api /repos/docker/build-push-action/git/ref/tags/v7 --jq .object.sha(http block)/usr/bin/gh gh api /repos/docker/build-push-action/git/ref/tags/v7 --jq .object.sha k/gh-aw/gh-aw config rs_test.go fault_test.go(http block)/usr/bin/gh gh api /repos/docker/build-push-action/git/ref/tags/v7 --jq .object.sha k/gh-aw/gh-aw/.github/workflows --jq de_modules/.bin/sh(http block)https://api.github.com/repos/githubnext/agentics/git/ref/tags/-/usr/bin/gh gh api /repos/githubnext/agentics/git/ref/tags/- --jq .object.sha(http block)/usr/bin/gh gh api /repos/githubnext/agentics/git/ref/tags/- --jq .object.sha b:/usr/lib origin _modules/.bin/sh(http block)If you need me to access, download, or install something from one of these locations, you can either: