Skip to content

perf: optimize secret-digger-copilot token usage#1887

Merged
lpcox merged 1 commit intomainfrom
perf/secret-digger-copilot-token-optimization
Apr 10, 2026
Merged

perf: optimize secret-digger-copilot token usage#1887
lpcox merged 1 commit intomainfrom
perf/secret-digger-copilot-token-optimization

Conversation

@lpcox
Copy link
Copy Markdown
Collaborator

@lpcox lpcox commented Apr 10, 2026

Summary

Addresses the token optimization recommendations from #1879.

Changes

1. Reduced timeout-minutes from 30 → 15

  • Failure runs were spending 31 turns over ~7 minutes before timing out at 30 min
  • This halves the max cost ceiling for runaway failure runs
  • Note: Copilot engine does not support max-turns (only Claude does); timeout-minutes is the available control lever

2. Removed duplicate context from user message

  • Repository, Run ID, Workflow, and Engine lines were already injected by the gh-aw framework into <system> context
  • Removes 4 redundant lines from the per-run unique prompt portion

3. Trimmed shared/secret-audit.md prompt

  • Condensed Investigation Workflow steps 1-4 into 3 concise lines (~450 chars saved per turn)
  • Condensed Background Knowledge Tracking section
  • Removed Security Research Guidelines section (already covered by MISSION section)
  • Added explicit turn budget: "Complete in 6–8 tool calls" with clear guidance
  • Fixed step numbering after condensing

Impact

These prompt changes also affect secret-digger-claude and secret-digger-codex (which import shared/secret-audit.md), but their lock files are unchanged since they were already compiled at this gh-aw version.

Why not max-turns?

The Copilot engine sets supportsMaxTurns: false — it uses max-continuations instead, which controls autopilot sequential runs (not per-run turn count). The turn budget is communicated via prompt instructions as the next best approach.

Closes #1879

Address recommendations from #1879 (token optimization report):

1. Reduce timeout-minutes from 30 to 15
   - Failure runs were spending 31 turns over ~7 min then timing out at 30 min
   - Halves the max cost ceiling for runaway failure runs
   - Note: Copilot engine does not support max-turns; timeout is the
     available control

2. Remove duplicate context from user message
   - Repository, Run ID, Workflow, Engine lines were already injected
     by gh-aw framework into <system> context
   - Removes 4 redundant lines that slightly inflate the per-run unique
     prompt portion

3. Trim shared/secret-audit.md prompt
   - Condensed Investigation Workflow steps 1-4 into 3 concise lines
     (~450 chars saved per turn)
   - Condensed Background Knowledge Tracking section
   - Removed Security Research Guidelines section (covered by MISSION)
   - Added explicit turn budget: "Complete in 6-8 tool calls"
   - Fixed step numbering after condensing

These changes also affect secret-digger-claude and secret-digger-codex
(which import shared/secret-audit.md) but their lock files are unchanged
since the prompt changes are embedded at compile time.

Closes #1879

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 10, 2026 18:48
@lpcox lpcox requested a review from Mossaka as a code owner April 10, 2026 18:48
@github-actions
Copy link
Copy Markdown
Contributor

✅ Coverage Check Passed

Overall Coverage

Metric Base PR Delta
Lines 85.85% 85.95% 📈 +0.10%
Statements 85.76% 85.85% 📈 +0.09%
Functions 87.54% 87.54% ➡️ +0.00%
Branches 78.56% 78.61% 📈 +0.05%
📁 Per-file Coverage Changes (1 files)
File Lines (Before → After) Statements (Before → After)
src/docker-manager.ts 86.3% → 86.6% (+0.36%) 85.9% → 86.2% (+0.35%)

Coverage comparison generated by scripts/ci/compare-coverage.ts

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Optimizes the Secret Digger Copilot workflow to reduce token/cost in failure runs by shortening job timeouts and trimming repeated/verbose prompt content used by the agent.

Changes:

  • Reduced Copilot workflow timeout-minutes from 30 to 15.
  • Removed the “Current Run Context” block from the Copilot workflow prompt.
  • Condensed shared/secret-audit.md (background/workflow text) and added an explicit investigation budget guideline.
Show a summary per file
File Description
.github/workflows/shared/secret-audit.md Trims shared prompt content and adds a turn/tool-call budget to steer shorter investigations.
.github/workflows/secret-digger-copilot.md Lowers timeout and removes redundant per-run context from the user message section.
.github/workflows/secret-digger-copilot.lock.yml Regenerates the compiled workflow to reflect the new timeout/prompt inputs.

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/shared/secret-audit.md:83

  • The new Turn budget guidance mixes concepts (“6–8 tool calls” but then “Load cache state (1 turn) …”), which can be interpreted inconsistently by the agent. Consider using one unit consistently (either “tool calls” or “turns”) and aligning the breakdown accordingly so the budget is unambiguous.
**Turn budget**: Complete your investigation in **6–8 tool calls**. Load cache state (1 turn), investigate deeply (4–5 turns), update cache and report (1–2 turns). Do not exhaustively check all 10 investigation areas in a single run — pick ONE area and go deep.

  • Files reviewed: 3/3 changed files
  • Comments generated: 3

Comment on lines 80 to +84
## Emergency Exit Rule

If you have nothing substantive to report after completing your investigation, call `noop` with a summary message instead of producing empty or minimal output. Never produce output shorter than one complete sentence.

## Security Research Guidelines
**Turn budget**: Complete your investigation in **6–8 tool calls**. Load cache state (1 turn), investigate deeply (4–5 turns), update cache and report (1–2 turns). Do not exhaustively check all 10 investigation areas in a single run — pick ONE area and go deep.

- Be thorough and systematic
- Try unusual and creative approaches
- Don't repeat the same techniques every run
- Document everything in cache-memory
- Focus on finding real security boundary violations
- This security testing is conducted within a sandboxed environment specifically designed for this purpose
If you have nothing substantive to report after completing your investigation, call `noop` with a summary message instead of producing empty or minimal output. Never produce output shorter than one complete sentence.
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Turn budget paragraph is currently placed under the "## Emergency Exit Rule" heading, even though it’s not part of the emergency exit behavior. Consider moving it to its own heading (e.g., "## Turn Budget") or placing it near the Investigation Workflow so the document structure matches the content.

This issue also appears on line 82 of the same file.

See below for a potential fix:

## Turn Budget

**Turn budget**: Complete your investigation in **6–8 tool calls**. Load cache state (1 turn), investigate deeply (4–5 turns), update cache and report (1–2 turns). Do not exhaustively check all 10 investigation areas in a single run — pick ONE area and go deep.

## Emergency Exit Rule

Copilot uses AI. Check for mistakes.
timeout-minutes: 30
timeout-minutes: 15
---

Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "Current Run Context" block removal also drops the "Runner: Check your environment carefully" instruction, which is not redundant with the injected GitHub context. If that guidance is still desired for agent behavior/safety, consider keeping it (e.g., as a single line above the main instruction) while removing only the truly duplicate context lines.

Suggested change
Runner: Check your environment carefully.

Copilot uses AI. Check for mistakes.
Comment on lines 149 to 153
GH_AW_GITHUB_EVENT_ISSUE_NUMBER: ${{ github.event.issue.number }}
GH_AW_GITHUB_EVENT_PULL_REQUEST_NUMBER: ${{ github.event.pull_request.number }}
GH_AW_GITHUB_REPOSITORY: ${{ github.repository }}
GH_AW_GITHUB_RUN_ID: ${{ github.run_id }}
GH_AW_GITHUB_WORKFLOW: ${{ github.workflow }}
GH_AW_GITHUB_WORKSPACE: ${{ github.workspace }}
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this lock file, GH_AW_GITHUB_WORKFLOW is no longer passed into prompt rendering/substitution, which means the workflow name won’t appear in the <github-context> block (unlike the Claude/Codex Secret Digger workflows). If keeping workflow name in the system context is still intended, re-introduce GH_AW_GITHUB_WORKFLOW in these env/substitution lists so it can be injected.

Copilot uses AI. Check for mistakes.
@github-actions

This comment has been minimized.

@github-actions
Copy link
Copy Markdown
Contributor

Smoke test results:

  • PR titles: "refactor: use gh aw logs for token analysis workflows"; "chore: upgrade gh-aw to v0.68.0 and auto-discover lock files"
  • GitHub MCP last 2 merged PRs: ✅
  • safeinputs-gh PR query: ❌
  • Playwright github.com title check: ✅
  • Tavily web search: ❌
  • File write + bash cat verify: ✅
  • Discussion query + mystical discussion comment: ❌
  • Build (npm ci && npm run build): ✅
    Overall status: FAIL

🔮 The oracle has spoken through Smoke Codex

@github-actions
Copy link
Copy Markdown
Contributor

🏗️ Build Test Suite Results

Ecosystem Project Build/Install Tests Status
Bun elysia 1/1 passed ✅ PASS
Bun hono 1/1 passed ✅ PASS
C++ fmt N/A ✅ PASS
C++ json N/A ✅ PASS
Deno oak N/A 1/1 passed ✅ PASS
Deno std N/A 1/1 passed ✅ PASS
.NET hello-world N/A ✅ PASS
.NET json-parse N/A ✅ PASS
Go color 1/1 passed ✅ PASS
Go env 1/1 passed ✅ PASS
Go uuid 1/1 passed ✅ PASS
Java gson 1/1 passed ✅ PASS
Java caffeine 1/1 passed ✅ PASS
Node.js clsx All passed ✅ PASS
Node.js execa All passed ✅ PASS
Node.js p-limit All passed ✅ PASS
Rust fd 1/1 passed ✅ PASS
Rust zoxide 1/1 passed ✅ PASS

Overall: 8/8 ecosystems passed — ✅ PASS

Generated by Build Test Suite for issue #1887 · ● 729K ·

@lpcox lpcox merged commit 28db5ac into main Apr 10, 2026
61 of 64 checks passed
@lpcox lpcox deleted the perf/secret-digger-copilot-token-optimization branch April 10, 2026 19:29
@github-actions
Copy link
Copy Markdown
Contributor

Smoke Test Results

Overall: PASS

💥 [THE END] — Illustrated by Smoke Claude

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

⚡ Copilot Token Optimization2026-04-10 — Secret Digger (Copilot)

2 participants