Skip to content

feat(smoke-copilot): token optimization — reduce turns, drop heavy import, pre-fetch PR context#24639

Closed
Copilot wants to merge 5 commits intomainfrom
copilot/copilot-token-optimizer-turn-count-reduction
Closed

feat(smoke-copilot): token optimization — reduce turns, drop heavy import, pre-fetch PR context#24639
Copilot wants to merge 5 commits intomainfrom
copilot/copilot-token-optimizer-turn-count-reduction

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 5, 2026

Smoke Copilot is the #2 token consumer at 20M tokens/week. Per-request cost is stable at ~63K tokens, so turn count is the only lever. All 9 audited runs flagged resource_heavy_for_domain and poor_agentic_control.

Changes

  • max-continuations: 2 → 1 — disables autopilot continuation windows; caps runs at ~20–30 turns and eliminates the 62-turn/4.2M-token outlier pattern
  • Drop github-queries-mcp-script.md import — 444-line file (~6,500 tokens) loaded every turn for a single discussion query; step 8 now calls list_discussions via GitHub MCP directly
  • Efficiency rule in prompt — instructs the agent to complete all 12 tests in ≤15 tool calls, discouraging re-verification turns
  • Pre-fetch PR context before agent starts — new bash step writes PR metadata and first 3 changed files (with patch) to separate JSON files before the agent runs:
    steps:
      - name: Pre-fetch PR context
        if: github.event_name == 'pull_request'
        env:
          GH_TOKEN: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}
          PR_NUMBER: ${{ github.event.pull_request.number }}
          REPO: ${{ github.repository }}
        run: |
          gh pr view "$PR_NUMBER" --repo "$REPO" --json number,title,author,assignees \
            > /tmp/gh-aw/agent/smoke-pr-meta.json
          gh api "/repos/$REPO/pulls/$PR_NUMBER/files" \
            --jq '[.[0:3] | .[] | {filename, patch}]' \
            > /tmp/gh-aw/agent/smoke-pr-files.json
    Agent reads these files instead of making GitHub API calls for PR metadata and diff.
  • Simplify Test 12 — removes the reply-to-comment sub-test (3+ additional turns: list comments → parse ID → reply); agent uses pre-fetched file context for the inline comment instead

Estimated savings

Change Savings
max-continuations: 1 2–3M tokens per outlier run
Drop github-queries-mcp-script.md ~104K tokens/run (~1.7M/week)
Pre-fetch PR context 600K–2.5M tokens/run on PR events
Simplify Test 12 ~5–10 turns per PR run
Efficiency rule ~15% fewer turns

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
    • Triggering command: /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)
    • Triggering command: /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 nalysis.md dit.md (http block)
    • Triggering command: /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 nalysis.md dit.md ; \ fi (http block)
  • https://api.github.com/orgs/test-owner/actions/secrets
    • Triggering command: /usr/bin/gh gh api /orgs/test-owner/actions/secrets --jq .secrets[].name go1.25.8 -c=4 -nolocalimports -importcfg /tmp/go-build1205206761/b396/importcfg -pack /tmp/go-build1205206761/b396/_testmain.go env -json 1.4.1/internal/xcontext/xcontext.go x_amd64/compile GOINSECURE GOMOD GOMODCACHE x_amd64/compile (http block)
    • Triggering command: /usr/bin/gh gh api /orgs/test-owner/actions/secrets --jq .secrets[].name --write ../../../**/*.jsGOMOD 64/bin/go --ignore-path ../../../.pretti-c k/_temp/uv-pytho"prettier" --check '**/*.cjs' '**/*.ts' '**/*.json' --ignore-path ../../../.prettierignore go env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
  • https://api.github.com/repos/actions/ai-inference/git/ref/tags/v1
    • Triggering command: /usr/bin/gh gh api /repos/actions/ai-inference/git/ref/tags/v1 --jq .object.sha --show-toplevel x_amd64/vet /usr/bin/git _.a JtV1iahb4 x_amd64/vet git init�� GOMODCACHE x_amd64/vet /usr/bin/git g_.a cjNZiRS1g 64/pkg/tool/linu--show-toplevel git (http block)
  • https://api.github.com/repos/actions/checkout/git/ref/tags/v3
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v3 --jq .object.sha xterm-color -extld=gcc /usr/bin/git gh-aw.wasm ./cmgit GO111MODULE x_amd64/compile git -C /tmp/compile-all-instructions-test-973243111/.github/workflows l /usr/bin/gh -json eyset.go x_amd64/compile gh (http block)
  • https://api.github.com/repos/actions/checkout/git/ref/tags/v5
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v5 --jq .object.sha g_.a 5206761/b031/vet.cfg .cfg GOINSECURE GOMOD GOMODCACHE ache/go/1.25.8/x^remote\..*\.gh-resolved$ (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v5 --jq .object.sha --get-regexp ^remote\..*\.gh-resolved$ /usr/bin/git 3940767713/.githgit .cfg 64/pkg/tool/linu--show-toplevel git rev-�� --show-toplevel 64/pkg/tool/linux_amd64/vet /usr/bin/git 079588/b192/_pkggit .cfg x_amd64/link git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v5 --jq .object.sha --show-toplevel /opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/vet /usr/bin/git vaScript34454229git '/tmp/TestParseDrev-parse /opt/hostedtoolc--show-toplevel git rev-�� --show-toplevel /opt/hostedtoolcache/go/1.25.8/xsecurity /usr/bin/git licyMinIntegritygit /tmp/go-build120rev-parse 1/x64/bin/node git (http block)
  • https://api.github.com/repos/actions/checkout/git/ref/tags/v6
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v6 --jq .object.sha user.name Test User /opt/hostedtoolcache/node/24.14.1/x64/bin/node -json GO111MODULE x_amd64/vet node /tmp�� /home/REDACTED/work/gh-aw/gh-aw/.github/workflows/agentic-observability-kit.md x_amd64/vet /opt/hostedtoolcache/node/24.14.1/x64/bin/node _.a GO111MODULE x_amd64/vet /opt/hostedtoolcache/node/24.14.1/x64/bin/node (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v6 --jq .object.sha --git-dir x_amd64/vet /usr/bin/git _.a elect.go x_amd64/vet git rev-�� --show-toplevel x_amd64/vet /usr/bin/git _.a nLaxVxxol 64/pkg/tool/linu--show-toplevel git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v6 --jq .object.sha -aw-actions/git/ref/tags/v1.2.3 ortcfg /usr/bin/git t.go t_test.go /opt/hostedtoolc--show-toplevel git rev-�� --show-toplevel /opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linuTest User /usr/bin/git -unreachable=falgit /tmp/go-build120rev-parse 5206761/b355/vet--show-toplevel git (http block)
  • https://api.github.com/repos/actions/github-script/git/ref/tags/v8
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v8 --jq .object.sha -json GO111MODULE x_amd64/asm GOINSECURE GOMOD GOMODCACHE x_amd64/asm env -json GO111MODULE x_amd64/compile GOINSECURE GOMOD GOMODCACHE x_amd64/compile (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v8 --jq .object.sha -json GO111MODULE x_amd64/compile GOINSECURE GOMOD GOMODCACHE x_amd64/compile env -json GO111MODULE x_amd64/vet GOINSECURE GOMOD GOMODCACHE x_amd64/vet (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v8 --jq .object.sha -json GO111MODULE x_amd64/compile GOINSECURE GOMOD GOMODCACHE x_amd64/compile env adata/main.go GO111MODULE x_amd64/compile GOINSECURE GOMOD GOMODCACHE x_amd64/compile (http block)
  • https://api.github.com/repos/actions/setup-go/git/ref/tags/v4
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-go/git/ref/tags/v4 --jq .object.sha /tmp/gh-aw-test-runs/20260405-015757-35399/test-484000682 epo}/actions/runs/2/artifacts /usr/bin/git e GO111MODULE x_amd64/vet git rev-�� --show-toplevel x_amd64/vet /usr/bin/git _.a GO111MODULE 64/pkg/tool/linu--show-toplevel git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-go/git/ref/tags/v4 --jq .object.sha -json GO111MODULE ache/node/24.14.1/x64/bin/node GOINSECURE GOMOD GOMODCACHE sh t-62�� bility_SameInputSameOutput152720631/001/stability-test.md GOPROXY t GOSUMDB GOWORK 64/bin/go /opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/vet (http block)
  • https://api.github.com/repos/actions/setup-node/git/ref/tags/v4
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-node/git/ref/tags/v4 --jq .object.sha --git-dir resolved$ /usr/bin/git -json GO111MODULE x_amd64/vet git conf�� user.email test@example.com /usr/bin/git _.a GO111MODULE 64/pkg/tool/linu--show-toplevel git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-node/git/ref/tags/v4 --jq .object.sha -json GO111MODULE /home/REDACTED/work/gh-aw/gh-aw/node_modules/.bin/sh GOINSECURE GOMOD GOMODCACHE sh -c licyTrustedUsersExpressionCompiledOutput381107772/001 GOPROXY 194039/b436/vet.cfg l GOWORK 64/bin/go /opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/asm (http block)
  • https://api.github.com/repos/actions/upload-artifact/git/ref/tags/v4
    • Triggering command: /usr/bin/gh gh api /repos/actions/upload-artifact/git/ref/tags/v4 --jq .object.sha runs/20260405-015757-35399/test-2530429267/custom/workflows -buildtags /usr/lib/git-core/git l -ifaceassert -nilfunc /usr/lib/git-core/git unpa�� --pack_header=2,3 l /usr/bin/git -json GO111MODULE x_amd64/compile git (http block)
  • https://api.github.com/repos/astral-sh/setup-uv/git/ref/tags/eac588ad8def6316056a12d4907a9d4d84ff7a3b
    • Triggering command: /usr/bin/gh gh api /repos/astral-sh/setup-uv/git/ref/tags/eac588ad8def6316056a12d4907a9d4d84ff7a3b --jq .object.sha (http block)
  • https://api.github.com/repos/github/gh-aw
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw --jq .visibility (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw --jq .visibility ithub/workflows/ci-doctor.md ithub/workflows/claude-code-user-docs-review.md r: $owner, name: $name) { hasDiscussionsEnabled } } gpg.program (http block)
  • https://api.github.com/repos/github/gh-aw-actions/git/ref/tags/v0.1.2
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw-actions/git/ref/tags/v0.1.2 --jq .object.sha GOMODCACHE IwtLslUObn8g /usr/bin/git _.a GO111MODULE x_amd64/vet git rev-�� --show-toplevel x_amd64/vet /usr/bin/git _.a GO111MODULE 64/pkg/tool/linu--show-toplevel git (http block)
  • https://api.github.com/repos/github/gh-aw-actions/git/ref/tags/v1.0.0
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw-actions/git/ref/tags/v1.0.0 --jq .object.sha UpdateDiscussionFieldEnforcementgo1.25.8 -buildtags /usr/lib/git-core/git l -ifaceassert -nilfunc /usr/lib/git-core/git main�� run l /usr/bin/git --detach GO111MODULE x_amd64/compile git (http block)
  • https://api.github.com/repos/github/gh-aw-actions/git/ref/tags/v1.2.3
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw-actions/git/ref/tags/v1.2.3 --jq .object.sha g/timeutil/format.go g/timeutil/format_test.go /usr/bin/git -errorsas -ifaceassert -nilfunc git add . -tests epo.git -json GO111MODULE x_amd64/compile git (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/1/artifacts
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/1/artifacts --jq .artifacts[].name .cfg 64/pkg/tool/linux_amd64/vet GOINSECURE 079588/b011/ GOMODCACHE 64/pkg/tool/linux_amd64/vet env 079588/b180/_pkg_.a GO111MODULE stants.test GOINSECURE 079588/b011/memmrev-parse ache/go/1.25.8/x--show-toplevel stants.test (http block)
    • Triggering command: /usr/bin/gh gh run download 1 --dir test-logs/run-1 .cfg 64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/vet env 2406123643 O8a-/w8uJjXynBhCHi02xO8a- 64/pkg/tool/linux_amd64/compile GOINSECURE nal/fips140tls GOMODCACHE 64/pkg/tool/linux_amd64/compile (http block)
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/1/artifacts --jq .artifacts[].name GO111MODULE ache/go/1.25.8/x64/bin/go GOINSECURE GOMOD GOMODCACHE go env y_with_repos=public_2674056947/001 GO111MODULE 1/x64/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/node-gyp-bin/node GOINSECURE GOMOD GOMODCACHE go (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/12345/artifacts
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/12345/artifacts --jq .artifacts[].name g/stringutil/ansi.go 64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/vet env b/workflows .cfg x_amd64/compile GOINSECURE /go-yaml GOMODCACHE x_amd64/compile (http block)
    • Triggering command: /usr/bin/gh gh run download 12345 --dir test-logs/run-12345 GO111MODULE 64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/vet env 079588/b170/_pkg_.a .cfg 64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD 079588/b011/syma--show-toplevel 64/pkg/tool/linux_amd64/vet (http block)
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/12345/artifacts --jq .artifacts[].name GO111MODULE 1/x64/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/node-gyp-bin/sh GOINSECURE GOMOD GOMODCACHE go env 3334606081/.github/workflows GO111MODULE ache/go/1.25.8/x64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/12346/artifacts
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/12346/artifacts --jq .artifacts[].name .cfg 64/pkg/tool/linux_amd64/vet GOINSECURE l GOMODCACHE 64/pkg/tool/linux_amd64/vet env b/workflows I_fS/lEXOLD1Q0N_qtyQmI_fS 64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linutest@example.com (http block)
    • Triggering command: /usr/bin/gh gh run download 12346 --dir test-logs/run-12346 .cfg 64/pkg/tool/linux_amd64/vet GOINSECURE g/x/crypto/interconfig GOMODCACHE 64/pkg/tool/linuTest User env 079588/b169/_pkg_.a vMoO/r1c5PlYHcFDLvhFNvMoO 64/pkg/tool/linux_amd64/link GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linuremote.origin.url (http block)
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/12346/artifacts --jq .artifacts[].name GO111MODULE n-dir/sh GOINSECURE GOMOD GOMODCACHE go env 3334606081/.github/workflows GO111MODULE ndor/bin/sh GOINSECURE GOMOD GOMODCACHE go (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/2/artifacts
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/2/artifacts --jq .artifacts[].name GO111MODULE 64/pkg/tool/linux_amd64/vet GOINSECURE 079588/b011/ GOMODCACHE 64/pkg/tool/linux_amd64/vet env 079588/b154/_pkg_.a GO111MODULE util.test GOINSECURE fips140/ecdh ache/go/1.25.8/x--show-toplevel util.test (http block)
    • Triggering command: /usr/bin/gh gh run download 2 --dir test-logs/run-2 GO111MODULE 64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linutest@example.com env 2406123643 GO111MODULE .cfg GOINSECURE g/x/text/transforev-parse GOMODCACHE ache/go/1.25.8/x64/pkg/tool/linu-trimpath (http block)
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/2/artifacts --jq .artifacts[].name mLsRemoteWithRealGitcustom_branch831304713/001' ache/go/1.25.8/x64/bin/go GOINSECURE GOMOD GOMODCACHE go env '**/*.ts' '**/*.json' --ignore-path ../../../.pr**/*.json GO111MODULE n-dir/node GOINSECURE GOMOD GOMODCACHE go (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/3/artifacts
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/3/artifacts --jq .artifacts[].name .cfg 64/pkg/tool/linux_amd64/vet GOINSECURE 079588/b011/ GOMODCACHE 64/pkg/tool/linux_amd64/vet env 079588/b159/_pkg_.a GO111MODULE 64/pkg/tool/linux_amd64/compile GOINSECURE 079588/b011/rt0_rev-parse ache/go/1.25.8/x--show-toplevel 64/pkg/tool/linux_amd64/compile (http block)
    • Triggering command: /usr/bin/gh gh run download 3 --dir test-logs/run-3 GO111MODULE 64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linuTest User env 2406123643 go .cfg GOINSECURE hpke GOMODCACHE ache/go/1.25.8/x64/pkg/tool/linux_amd64/link (http block)
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/3/artifacts --jq .artifacts[].name GO111MODULE tions/setup/js/node_modules/.bin/node GOINSECURE GOMOD GOMODCACHE go 1/x6�� y_with_repos_array_c3517176655/001 GO111MODULE ache/go/1.25.8/x64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/4/artifacts
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/4/artifacts --jq .artifacts[].name .cfg 64/pkg/tool/linux_amd64/vet GOINSECURE 079588/b011/ GOMODCACHE 64/pkg/tool/linux_amd64/vet env til.go o x_amd64/compile GOINSECURE 079588/b011/sys_rev-parse ache/go/1.25.8/x--show-toplevel x_amd64/compile (http block)
    • Triggering command: /usr/bin/gh gh run download 4 --dir test-logs/run-4 GO111MODULE 64/pkg/tool/linu-nolocalimports GOINSECURE 079588/b078/ GOMODCACHE 64/pkg/tool/linu/tmp/go-build1205206761/b451/_testmain.go env 079588/b202/_pkg_.a .cfg .cfg GOINSECURE g/x/text/unicoderev-parse ache/go/1.25.8/x--show-toplevel ache/go/1.25.8/x64/pkg/tool/linu-importcfg (http block)
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/4/artifacts --jq .artifacts[].name GO111MODULE ache/go/1.25.8/x64/bin/go GOINSECURE GOMOD GOMODCACHE go env y_with_repos_array_c3517176655/0remote.origin.url GO111MODULE 86_64/node GOINSECURE GOMOD GOMODCACHE go (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/5/artifacts
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/5/artifacts --jq .artifacts[].name .cfg 64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/vet env l.go l_test.go x_amd64/link GOINSECURE fips140/ecdsa GOMODCACHE x_amd64/link (http block)
    • Triggering command: /usr/bin/gh gh run download 5 --dir test-logs/run-5 .cfg 64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/vet env 079588/b203/_pkg_.a eFae/0ahu769BnKYz-hV-eFae ache/go/1.25.8/x64/pkg/tool/linu-nilfunc GOINSECURE g/x/text/unicoderev-parse GOMODCACHE ache/go/1.25.8/x64/pkg/tool/linu-tests (http block)
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/5/artifacts --jq .artifacts[].name GO111MODULE 1/x64/bin/npx GOINSECURE GOMOD GOMODCACHE go env y_with_repos_array_c3517176655/001 GO111MODULE ache/go/1.25.8/x64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
  • https://api.github.com/repos/github/gh-aw/actions/workflows
    • Triggering command: /usr/bin/gh gh workflow list --json name,state,path -json (http block)
    • Triggering command: /usr/bin/gh gh run list --json databaseId,number,url,status,conclusion,workflowName,createdAt,startedAt,updatedAt,event,headBranch,headSha,displayTitle --workflow nonexistent-workflow-12345 --limit 100 GOMOD GOMODCACHE x_amd64/vet env -json GO111MODULE x_amd64/vet GOINSECURE GOMOD GOMODCACHE x_amd64/vet (http block)
    • Triggering command: /usr/bin/gh gh run list --json databaseId,number,url,status,conclusion,workflowName,createdAt,startedAt,updatedAt,event,headBranch,headSha,displayTitle --workflow nonexistent-workflow-12345 --limit 6 079588/b047/ GOMODCACHE 64/pkg/tool/linux_amd64/vet env 079588/b123/_pkg_.a .cfg 64/pkg/tool/linux_amd64/vet GOINSECURE /go-yaml/token 079588/b047/syma--show-toplevel 64/pkg/tool/linux_amd64/vet (http block)
  • https://api.github.com/repos/github/gh-aw/git/ref/tags/v0.47.4
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v0.47.4 --jq .object.sha --show-toplevel 64/pkg/tool/linux_amd64/vet /usr/bin/git 079588/b131/_pkggit .cfg 64/pkg/tool/linu--show-toplevel git rev-�� --show-toplevel 64/pkg/tool/linux_amd64/vet /usr/bin/git se 5206761/b015/vet-c k git (http block)
  • https://api.github.com/repos/github/gh-aw/git/ref/tags/v1.0.0
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v1.0.0 --jq .object.sha edOutput1805599675/001 .cfg 64/pkg/tool/linux_amd64/vet GOINSECURE /go-yaml/lexer GOMODCACHE 64/pkg/tool/linutest@example.com env WTp5/H9VjfFv7QroIIAr-WTp5 .cfg ache/go/1.25.8/x64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE ache/go/1.25.8/x64/pkg/tool/linuTest User (http block)
  • https://api.github.com/repos/github/gh-aw/git/ref/tags/v1.2.3
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v1.2.3 --jq .object.sha -json GO111MODULE x_amd64/link GOINSECURE GOMOD s/js_js.s x_amd64/link env successfully" GO111MODULE x_amd64/vet GOINSECURE GOMOD GOMODCACHE x_amd64/vet (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v1.2.3 --jq .object.sha -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
  • https://api.github.com/repos/github/gh-aw/git/ref/tags/v2.0.0
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v2.0.0 --jq .object.sha -json GO111MODULE x_amd64/vet GOINSECURE GOMOD GOMODCACHE x_amd64/vet env -json irent.go x_amd64/vet GOINSECURE GOMOD GOMODCACHE x_amd64/vet (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v2.0.0 --jq .object.sha -json GO111MODULE x_amd64/vet GOINSECURE GOMOD GOMODCACHE x_amd64/vet env 0174404/001 0174404/002/work x_amd64/vet GOINSECURE GOMOD GOMODCACHE x_amd64/vet (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v2.0.0 --jq .object.sha -json GO111MODULE x_amd64/compile GOINSECURE GOMOD GOMODCACHE x_amd64/compile env -json 6b1868bc5cc05d4b-nolocalimports x_amd64/vet GOINSECURE GOMOD GOMODCACHE x_amd64/vet (http block)
  • https://api.github.com/repos/github/gh-aw/git/ref/tags/v3.0.0
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v3.0.0 --jq .object.sha -json GO111MODULE x_amd64/vet GOINSECURE GOMOD GOMODCACHE x_amd64/vet env -json GO111MODULE x_amd64/vet GOINSECURE GOMOD GOMODCACHE x_amd64/vet (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v3.0.0 --jq .object.sha re GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
  • https://api.github.com/repos/githubnext/agentics/git/ref/tags/-
    • Triggering command: /usr/bin/gh gh api /repos/githubnext/agentics/git/ref/tags/- --jq .object.sha (http block)
  • https://api.github.com/repos/nonexistent/action/git/ref/tags/v999.999.999
    • Triggering command: /usr/bin/gh gh api /repos/nonexistent/action/git/ref/tags/v999.999.999 --jq .object.sha edOutput1805599675/001 .cfg 64/pkg/tool/linux_amd64/vet GOINSECURE /go-yaml/printerrev-parse GOMODCACHE 64/pkg/tool/linux_amd64/vet env Ahfx/EOBK6ELuzyeu-LDGAhfx GO111MODULE ache/go/1.25.8/x64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE ache/go/1.25.8/x^remote\..*\.gh-resolved$ (http block)
  • https://api.github.com/repos/nonexistent/repo/actions/runs/12345
    • Triggering command: /usr/bin/gh gh run view 12345 --repo nonexistent/repo --json status,conclusion GOINSECURE fips140/check GOMODCACHE x_amd64/vet env 079588/b240/_pkg_.a wDwi/8TvZlM4P0nfuVfRvwDwi .cfg GOINSECURE t/internal/langurev-parse GOMODCACHE ache/go/1.25.8/x64/pkg/tool/linu-extld=gcc (http block)
    • Triggering command: /usr/bin/gh gh run view 12345 --repo nonexistent/repo --json status,conclusion GOINSECURE GOMOD GOMODCACHE go env b/workflows GO111MODULE 64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/vet (http block)
  • https://api.github.com/repos/owner/repo/actions/workflows
    • Triggering command: /usr/bin/gh gh workflow list --json name,state,path --repo owner/repo x_amd64/compile GOINSECURE GOMOD GOMODCACHE x_amd64/compile env -json n/codec.go x_amd64/compile GOINSECURE GOMOD GOMODCACHE x_amd64/compile (http block)
    • Triggering command: /usr/bin/gh gh workflow list --json name,state,path --repo owner/repo -importcfg /tmp/go-build1205206761/b413/importcfg -pack /home/REDACTED/work/gh-aw/gh-aw/pkg/gitutil/gitutil.go /home/REDACTED/work/gh-aw/gh-aw/pkg/gitutil/gitutil_test.go env -json ag.go x_amd64/compile GOINSECURE GOMOD GOMODCACHE x_amd64/compile (http block)
    • Triggering command: /usr/bin/gh gh workflow list --json name,state,path --repo owner/repo 64/bin/go --ignore-path ../../../.pretti-c /usr/bin/git go env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
  • https://api.github.com/repos/owner/repo/contents/file.md
    • Triggering command: /tmp/go-build1205206761/b396/cli.test /tmp/go-build1205206761/b396/cli.test -test.testlogfile=/tmp/go-build1205206761/b396/testlog.txt -test.paniconexit0 -test.v=true -test.parallel=4 -test.timeout=10m0s -test.run=^Test -test.short=true GOINSECURE GOMOD GOMODCACHE go env -json GO111MODULE x_amd64/compile GOINSECURE GOMOD GOMODCACHE x_amd64/compile (http block)
    • Triggering command: /tmp/go-build853194039/b396/cli.test /tmp/go-build853194039/b396/cli.test -test.testlogfile=/tmp/go-build853194039/b396/testlog.txt -test.paniconexit0 -test.v=true -test.parallel=4 -test.timeout=10m0s -test.run=^Test -test.short=true .prettierignore --log-level=erroenv /usr/bin/git node /hom�� --write ../../../**/*.jsGOMOD 64/bin/go --ignore-path ../../../.pretti-c ch go (http block)
  • https://api.github.com/repos/test-owner/test-repo/actions/secrets
    • Triggering command: /usr/bin/gh gh api /repos/test-owner/test-repo/actions/secrets --jq .secrets[].name -json GO111MODULE x_amd64/compile GOINSECURE GOMOD GOMODCACHE x_amd64/compile env -json x86.go x_amd64/compile GOINSECURE GOMOD GOMODCACHE x_amd64/compile (http block)
    • Triggering command: /usr/bin/gh gh api /repos/test-owner/test-repo/actions/secrets --jq .secrets[].name --write ../../../**/*.jsGOMOD 64/bin/go --ignore-path ../../../.pretti-c /usr/bin/git go env -json GO111MODULE de GOINSECURE GOMOD GOMODCACHE go (http block)

If you need me to access, download, or install something from one of these locations, you can either:

- Reduce max-continuations from 2 to 1 (prevents 62-turn outlier runs)
- Remove github-queries-mcp-script.md import (saves ~6,500 tokens/turn)
- Step 8: use list_discussions GitHub MCP directly instead of mcp-script
- Add EFFICIENCY RULE: complete all tests in ≤15 tool calls
- Add pre-fetch bash step for PR metadata and changed files
- Simplify Test 12: remove reply sub-test, use pre-fetched context"

Agent-Logs-Url: https://github.com/github/gh-aw/sessions/6d5cb569-c991-4faa-bdaf-07dc154c6d9a

Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
Copilot AI changed the title [WIP] Optimize token usage for Smoke Copilot feat(smoke-copilot): token optimization — reduce turns, drop heavy import, pre-fetch PR context Apr 5, 2026
Copilot finished work on behalf of lpcox April 5, 2026 02:07
Copilot AI requested a review from lpcox April 5, 2026 02:07
@lpcox lpcox marked this pull request as ready for review April 5, 2026 02:10
Copilot AI review requested due to automatic review settings April 5, 2026 02:10
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

This PR reduces Smoke Copilot token usage by limiting turn count, removing a large prompt import, and pre-fetching PR context so the agent can avoid GitHub API calls during the run.

Changes:

  • Reduce continuation turns (max-continuations: 2 → 1) and add an explicit tool-call efficiency constraint.
  • Remove shared/github-queries-mcp-script.md import and replace the discussion query step with list_discussions.
  • Add a workflow step to pre-fetch PR metadata + the first few PR file patches into /tmp/gh-aw/agent/* for later use by the agent; simplify Test 12 accordingly.
Show a summary per file
File Description
.github/workflows/smoke-copilot.md Updates the workflow manifest/prompt to reduce turns, drop the heavy import, add PR prefetch, and adjust the discussion + PR review tests.
.github/workflows/smoke-copilot.lock.yml Regenerates the compiled workflow to reflect the manifest changes (removed mcp-script tools/imports, added prefetch + DIFC proxy handling, updated prompt rendering).

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: 2

Comment thread .github/workflows/smoke-copilot.md Outdated
Comment thread .github/workflows/smoke-copilot.md Outdated
lpcox and others added 3 commits April 4, 2026 19:18
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
The lock file was compiled against stale shared imports, causing
TestHashConsistencyAcrossLockFiles to fail with a hash mismatch.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@pelikhan pelikhan closed this Apr 5, 2026
@pelikhan
Copy link
Copy Markdown
Collaborator

pelikhan commented Apr 5, 2026

Smoke copilot is a big test. It's heavy by design...

@github-actions github-actions bot deleted the copilot/copilot-token-optimizer-turn-count-reduction branch April 12, 2026 02:59
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.

[copilot-token-optimizer] Token Optimization: Smoke Copilot — Turn-Count Reduction Opportunities

4 participants