Skip to content

Optimize dead-code-remover prompt to cut turn count and context growth#35065

Merged
pelikhan merged 9 commits into
mainfrom
copilot/agentic-token-optimizer-dead-code-removal
May 26, 2026
Merged

Optimize dead-code-remover prompt to cut turn count and context growth#35065
pelikhan merged 9 commits into
mainfrom
copilot/agentic-token-optimizer-dead-code-removal

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 26, 2026

The Dead Code Removal Agent was running ~57-turn executions with high cache amplification, primarily from fragmented safety checks, split verification commands, and verbose inline prompt content. This updates the workflow prompt to reduce per-run turns while preserving dead-code safety gates.

  • Discovery moved to a small sub-agent

    • Replaced Phase 1/2 prose with an inline discover-candidates sub-agent contract.
    • Standardized stdout JSON shape for parent-agent consumption: skip + candidates.
    • Kept required exclusions for shared test helpers and cache-based dedupe behavior.
  • Phase 4 safety checks collapsed to one bash block per function

    • Consolidated caller grep, WASM check, console_wasm check, and constant/embed scan into a single execution unit per candidate.
    • Added path normalization guidance and kept skip semantics for live non-test/WASM usages.
  • Phase 6 verification chained + circuit breaker

    • Converted multi-block verification into one chained command flow.
    • Added explicit soft/hard turn-budget guidance with a >35-turn circuit breaker that skips go test and continues with reduced verification.
  • PR body instructions compressed

    • Replaced the large inline PR template with a compact required-structure contract (functions table, tests section, verification checklist, run URL).
func="FunctionName"
file="pkg/path/file.go"
file="${file#./}"

echo "=== Caller check ==="
grep -rn -m 5 "$func" --include="*.go" .

if [[ "$file" == "pkg/workflow/"* || "$file" == "pkg/console/"* ]]; then
  echo "=== WASM check ==="
  grep -n "$func" cmd/gh-aw-wasm/main.go || true
fi

if [[ "$file" == "pkg/console/"* ]]; then
  echo "=== console_wasm check ==="
  grep -n "$func" pkg/console/console_wasm.go || true
fi

Copilot AI and others added 8 commits May 26, 2026 22:27
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Remove dead code in token optimizer to improve efficiency Optimize dead-code-remover prompt to cut turn count and context growth May 26, 2026
Copilot AI requested a review from pelikhan May 26, 2026 22:40
@pelikhan pelikhan marked this pull request as ready for review May 26, 2026 22:48
Copilot AI review requested due to automatic review settings May 26, 2026 22:48
@pelikhan pelikhan merged commit 61c61a7 into main May 26, 2026
1 check failed
@pelikhan pelikhan deleted the copilot/agentic-token-optimizer-dead-code-removal branch May 26, 2026 22:48
Copilot AI review requested due to automatic review settings May 26, 2026 23:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[agentic-token-optimizer] [Token Optimizer] Dead Code Removal Agent — reduce 57-turn runs by consolidating bash calls and adding sub-agent discovery

2 participants