Reduce Copilot token analyzer prompt verbosity to avoid max-ai-credits trips#4944
Conversation
✅ Coverage Check PassedOverall Coverage
📁 Per-file Coverage Changes (2 files)
Coverage comparison generated by |
There was a problem hiding this comment.
Pull request overview
This PR reduces the verbosity of the Copilot Token Usage Analyzer’s generated issue content by adding explicit compact-output constraints to the workflow prompt, helping avoid intermittently tripping the max-ai-credits guardrail. It also adds a regression test to ensure the prompt retains these compact-output guardrails over time.
Changes:
- Renames the report section header to “Top Per-Workflow Details” to signal intentional truncation.
- Adds explicit prompt guidance to cap detailed bullets to the top 10 workflows by token usage and to trim detail instead of repeatedly reformatting large output.
- Adds a Jest test asserting the presence of these compact-output guardrails in the workflow prompt.
Show a summary per file
| File | Description |
|---|---|
scripts/ci/copilot-token-usage-analyzer-workflow.test.ts |
Adds a regression test asserting compact-output guardrails exist in the workflow prompt. |
.github/workflows/copilot-token-usage-analyzer.md |
Updates the prompt/report template and guidelines to encourage bounded, compact reporting. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 2/2 changed files
- Comments generated: 1
| expect(source).toContain('<summary><b>Top Per-Workflow Details</b></summary>'); | ||
| expect(source).toContain('include detailed bullets for at most the top 10 workflows by token usage'); | ||
| expect(source).toContain('if output size is high, trim detail instead of repeatedly reformatting the full report'); | ||
| }); |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Running in direct BYOK mode (AWF_AUTH_TYPE=github-oidc + AWF_AUTH_AZURE_* + COPILOT_PROVIDER_BASE_URL) via api-proxy → Azure OpenAI (Foundry, o4-mini-aw) authenticated via Microsoft Entra Overall: PASS
|
This comment has been minimized.
This comment has been minimized.
Ensures the old '## Per-Workflow Details' header cannot be accidentally reintroduced alongside the new compact '<summary>' version. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
🏗️ Build Test Suite Results
Overall: 8/8 ecosystems passed — ✅ PASS
|
Smoke Test: Copilot PAT Auth — PASS ✅
Overall: PASS | Auth mode: PAT (COPILOT_GITHUB_TOKEN)
|
✅ Smoke Test: Copilot BYOK (Direct) Mode — PASS
Status: Running in direct BYOK mode (
|
🤖 Smoke Test Results — PASS
PR: Reduce Copilot token analyzer prompt verbosity to avoid max-ai-credits trips Overall: PASS ✅
|
|
Merged PRs:
Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "registry.npmjs.org"See Network Configuration for more information.
|
Smoke Test: Services Connectivity
Overall: FAIL
|
|
|
Smoke Test Results
Overall Status: FAIL Last 2 Merged PRs:
Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "localhost"See Network Configuration for more information.
|
Daily Copilot Token Usage Analyzer intermittently hit the configured
max-ai-creditsguardrail due to overly verbose report generation behavior. This change tightens prompt constraints so the agent emits a bounded, compact report instead of spending extra turns on repeated output reshaping.Prompt constraints (workflow source)
copilot-token-usage-analyzer.mdguidance to explicitly cap verbose detail:Regression coverage
scripts/ci/copilot-token-usage-analyzer-workflow.test.tsto assert these compact-output guardrails remain present in the workflow prompt.