Skip to content

Commit 7649c7e

Browse files
CopilotlpcoxCopilot
authored
Reduce Copilot token analyzer prompt verbosity to avoid max-ai-credits trips (#4944)
* Initial plan * Reduce copilot token analyzer report verbosity to avoid AI credit cap * Add negative assertion for old verbose section header 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> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Landon Cox <landon.cox@microsoft.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 89eb831 commit 7649c7e

2 files changed

Lines changed: 20 additions & 2 deletions

File tree

.github/workflows/copilot-token-usage-analyzer.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ Create an issue with the following structure:
207207
2. ...
208208

209209
<details>
210-
<summary><b>Per-Workflow Details</b></summary>
210+
<summary><b>Top Per-Workflow Details</b></summary>
211211

212212
#### smoke-copilot
213213
- **Runs**: 3 (links to each run)
@@ -241,4 +241,6 @@ Runs where `token_usage` was null or 0 \u2014 these may not have the api-proxy e
241241
- **All data is pre-downloaded** \u2014 do not attempt to download artifacts or run `gh run download`. Use only the JSON at `/tmp/gh-aw/token-audit/copilot-logs.json`.
242242
- **Wrap verbose output** in `<details>` blocks for progressive disclosure.
243243
- **Round costs** to 2 decimal places, token counts to nearest thousand for readability.
244-
- **Sort workflows** by estimated cost (highest first) in the summary table.
244+
- **Sort workflows** by estimated cost (highest first) in the summary table.
245+
- **Keep output compact**: include detailed bullets for at most the top 10 workflows by token usage; keep remaining workflows in the summary table only.
246+
- **Avoid verbose rewrites**: if output size is high, trim detail instead of repeatedly reformatting the full report.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import * as fs from 'fs';
2+
import * as path from 'path';
3+
4+
const workflowsDir = path.resolve(__dirname, '../../.github/workflows');
5+
const sourcePath = path.join(workflowsDir, 'copilot-token-usage-analyzer.md');
6+
7+
describe('copilot token usage analyzer workflow prompt', () => {
8+
it('includes explicit compact-output guardrails to reduce AI credit usage', () => {
9+
const source = fs.readFileSync(sourcePath, 'utf-8');
10+
11+
expect(source).toContain('<summary><b>Top Per-Workflow Details</b></summary>');
12+
expect(source).not.toMatch(/^##.*Per-Workflow Details/m);
13+
expect(source).toContain('include detailed bullets for at most the top 10 workflows by token usage');
14+
expect(source).toContain('if output size is high, trim detail instead of repeatedly reformatting the full report');
15+
});
16+
});

0 commit comments

Comments
 (0)