delight: pre-compute sampling + tighten tools to cut ~530K tokens/run#29227
Merged
delight: pre-compute sampling + tighten tools to cut ~530K tokens/run#29227
Conversation
…avings) - Add pre-agent-steps to pre-compute file sampling and memory loads (eliminates ~6 exploratory agent turns, ~365K tokens/run) - Remove unused edit: tool (workflow is read-only, ~25K tokens/run) - Tighten bash allow-list: remove grep -r '*' docs and cat *, add scoped path-specific commands (~100K tokens/run) - Drop unused shared/jqschema.md import (~40K tokens/run) - Update prompt to reference pre-computed /tmp/gh-aw/agent/ files Resolves #copilot-token-optimizer issue for delight.md workflow" Agent-Logs-Url: https://github.com/github/gh-aw/sessions/5a95abc6-619c-4888-b650-517387fd25ca Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Optimize Delight workflow to reduce read-only run tokens
delight: pre-compute sampling + tighten tools to cut ~530K tokens/run
Apr 30, 2026
pelikhan
approved these changes
Apr 30, 2026
Contributor
|
Hey One small thing to note before this lands:
If you'd like a hand addressing this, here's a ready-to-use prompt:
|
Contributor
There was a problem hiding this comment.
Pull request overview
Optimizes the delight agentic workflow to reduce token usage by precomputing sampling/memory inputs ahead of agent start and tightening the tool allow-list.
Changes:
- Add
pre-agent-stepsto pre-sample docs/workflows/validation targets and pre-load delight memory JSON into/tmp/gh-aw/agent/. - Remove unused
edit:tool schema and dropshared/jqschema.mdimport to reduce prompt/tooling overhead. - Tighten bash allow-list and update workflow instructions to consume the precomputed
/tmp/gh-aw/agent/*artifacts.
Show a summary per file
| File | Description |
|---|---|
| .github/workflows/delight.md | Adds pre-agent sampling + memory preload, removes unused tooling/import, updates bash allow-list and prompt instructions accordingly. |
| .github/workflows/delight.lock.yml | Regenerated compiled workflow reflecting updated imports, pre-agent step insertion, and updated tool allow-list. |
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/delight.md:70
grep -rl "messages:" .github/workflows/ --include="*.md"searches recursively under.github/workflows/, so the sample list can include.github/workflows/shared/*.md. The bash allow-list only permitscat .github/workflows/*.md(top-level), so the agent may not be able to read the sampled workflow file. Either scope the grep to only top-level workflows, or expand the allow-list / pre-copy sampled files into/tmp/gh-aw/agent/similarly to the docs sampling.
# Sample workflows with messages (pre-compute instead of agent grep)
grep -rl "messages:" .github/workflows/ --include="*.md" | shuf -n 2 > /tmp/gh-aw/agent/workflow-samples.txt
# Sample validation files
- Files reviewed: 2/2 changed files
- Comments generated: 1
Comment on lines
+67
to
+69
| find docs/src/content/docs \( -name '*.md' -o -name '*.mdx' \) | shuf -n 2 > /tmp/gh-aw/agent/doc-samples.txt | ||
| # Sample workflows with messages (pre-compute instead of agent grep) | ||
| grep -rl "messages:" .github/workflows/ --include="*.md" | shuf -n 2 > /tmp/gh-aw/agent/workflow-samples.txt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
delight.mdwas burning 34 inference turns on a fully read-only run (0 write actions, 0.49% output tokens) — half of those turns were pure file discovery and memory loading that the agent was re-doing from scratch each run.Changes
pre-agent-steps— pre-samples doc files, message workflows, and validation files; pre-loads both memory JSON files into/tmp/gh-aw/agent/before the agent starts, eliminating ~6 exploratory turns (~365K tokens)edit:tool — never invoked; tool schema was included in every turn's context (~25K tokens)grep -r '*' docsandcat *; replaced with path-scoped equivalents (cat docs/src/content/docs/*.md,cat /tmp/gh-aw/agent/*, etc.) (~100K tokens)shared/jqschema.mdimport — adds JSON schema tooling context irrelevant to this workflow's narrative/prose output (~40K tokens)/tmp/gh-aw/agent/files instead of issuing discovery commandsEstimated total savings: ~530K tokens/run (~25% of 2.08M baseline).
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/usr/bin/gh gh repo view --json owner,name --jq .owner.login + "/" + .name ache/go/1.25.8/x64/pkg/tool/linu-nolocalimports(http block)/usr/bin/gh gh repo view owner/repo(http block)/usr/bin/gh gh repo view owner/repo --no�� g_.a(http block)https://api.github.com/orgs/test-owner/actions/secrets/usr/bin/gh gh api /orgs/test-owner/actions/secrets --jq .secrets[].name on' --ignore-path ../../../.prettierignore(http block)https://api.github.com/repos/actions/ai-inference/git/ref/tags/v1/usr/bin/gh gh api /repos/actions/ai-inference/git/ref/tags/v1 --jq [.object.sha, .object.type] | @tsv -stringintconv -tests /usr/bin/git se 9776527/b033/vetrev-parse ache/go/1.25.8/x--show-toplevel git rev-�� --show-toplevel ache/go/1.25.8/xTest User /usr/bin/git se 9776527/b084/vet/opt/hostedtoolcache/node/24.14.1/x64/bin/npm .cfg git(http block)https://api.github.com/repos/actions/checkout/git/ref/tags/v3/usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v3 --jq [.object.sha, .object.type] | @tsv --show-toplevel x_amd64/vet /usr/bin/gh --local credential.usernrev-parse x_amd64/vet gh api /repos/actions/github-script/git/ref/tags/v9 --jq /usr/bin/git lGitmaster_brancgit lGitmaster_brancrev-parse x_amd64/vet git(http block)https://api.github.com/repos/actions/checkout/git/ref/tags/v5/usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v5 --jq [.object.sha, .object.type] | @tsv 1145-15138/test-1641644721/.github/workflows 9776527/b288/vet.cfg 9776527/b399/agentdrain.test !../../../pkg/wogh --ignore-path ../../../.prettierignore 9776527/b399/agentdrain.test e=/t�� t0 /tmp/go-build3879776527/b040/vet.cfg(http block)/usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v5 --jq [.object.sha, .object.type] | @tsv --show-toplevel ortcfg /usr/bin/git 1145-15138/test-tr 9776527/b276/vet\n ache/go/1.25.8/x: git rev-�� --show-toplevel ache/go/1.25.8/xrev-parse /usr/bin/git 9776527/b399/_pkgit /tmp/go-build387rev-parse ache/go/1.25.8/x--show-toplevel git(http block)/usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v5 --jq [.object.sha, .object.type] | @tsv --show-toplevel git /usr/bin/git /tmp/gh-aw-test-git remote /usr/bin/git git rev-�� --show-toplevel git /usr/bin/git --show-toplevel git 64/pkg/tool/linu--show-toplevel git(http block)https://api.github.com/repos/actions/checkout/git/ref/tags/v6/usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v6 --jq [.object.sha, .object.type] | @tsv -unreachable=false =develop /opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/vet(http block)/usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v6 --jq [.object.sha, .object.type] | @tsv ithub/workflows/ace-editor.md -trimpath x_amd64/vet l github.com/githurev-parse -lang=go1.25 x_amd64/vet t-30�� sistency_GoAndJavaScript2915998623/001/test-inlined-imports-enabled-with-env-template-expressiongit remote /usr/bin/git .github/workflowgit -nolocalimports -importcfg git(http block)/usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v6 --jq [.object.sha, .object.type] | @tsv bility_SameInputSameOutput2908380976/001/stability-test.md(http block)https://api.github.com/repos/actions/github-script/git/ref/tags/v8/usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v8 --jq [.object.sha, .object.type] | @tsv --show-toplevel x_amd64/vet /usr/bin/git g_.a /tmp/go-build387log e/git git rev-�� --show-toplevel e/git /usr/bin/git T_hjJlGy4 tname) /opt/hostedtoolc--show-toplevel git(http block)https://api.github.com/repos/actions/github-script/git/ref/tags/v9/usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v9 --jq [.object.sha, .object.type] | @tsv(http block)/usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v9 --jq [.object.sha, .object.type] | @tsv -dirty" -o gh-aw ./cmd/gh-aw(http block)/usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v9 --jq [.object.sha, .object.type] | @tsv ithub/workflows/-errorsas(http block)https://api.github.com/repos/actions/setup-go/git/ref/tags/v4/usr/bin/gh gh api /repos/actions/setup-go/git/ref/tags/v4 --jq [.object.sha, .object.type] | @tsv /repos/actions/github-script/git/ref/tags/v9 --jq /usr/bin/sh fGO1rOfss(http block)https://api.github.com/repos/actions/setup-node/git/ref/tags/v4/usr/bin/gh gh api /repos/actions/setup-node/git/ref/tags/v4 --jq [.object.sha, .object.type] | @tsv s/test.md git /opt/hostedtoolcache/node/24.14.1/x64/bin/node get --local x_amd64/vet node /tmp�� /tmp/TestHashConsistency_GoAndJavaScript2915998623/001/test-complex-frontmatter-with-tools.md x_amd64/vet /opt/hostedtoolcache/node/24.14.1/x64/bin/node get --local x_amd64/vet node(http block)/usr/bin/gh gh api /repos/actions/setup-node/git/ref/tags/v4 --jq [.object.sha, .object.type] | @tsv --show-toplevel 64/pkg/tool/linu-test.v=true /usr/bin/git te 'scripts/**/*git .cfg 64/pkg/tool/linu--show-toplevel git rev-�� --show-toplevel 64/pkg/tool/linuremote2 /usr/bin/git mpiledOutput3279git on x_amd64/vet git(http block)https://api.github.com/repos/actions/setup-node/git/ref/tags/v6/usr/bin/gh gh api /repos/actions/setup-node/git/ref/tags/v6 --jq [.object.sha, .object.type] | @tsv '/tmp/TestParseDefaultBranchFromLsRemoteWithRealremote.origin.url '/tmp/TestParseDefaultBranchFromLsRemoteWithRealGitcustom_branch2409304913/001' ache/go/1.25.8/x64/pkg/tool/linux_amd64/link s -ifaceassert -nilfunc ache/go/1.25.8/x64/pkg/tool/linux_amd64/link -ato�� 9776527/b431/parser.test -buildtags ache/go/1.25.8/x64/pkg/tool/linux_amd64/compile -errorsas -ifaceassert -nilfunc ache/go/1.25.8/x64/pkg/tool/linux_amd64/compile(http block)/usr/bin/gh gh api /repos/actions/setup-node/git/ref/tags/v6 --jq [.object.sha, .object.type] | @tsv runs/20260430-011145-15138/test-3866451571 -trimpath kflows/test-expires.lock.yml -p github.com/githurev-parse -lang=go1.25 gh estl�� /repos/actions/github-script/git/ref/tags/v9 --jq /usr/bin/git -c=4 -nolocalimports -importcfg git(http block)/usr/bin/gh gh api /repos/actions/setup-node/git/ref/tags/v6 --jq [.object.sha, .object.type] | @tsv bility_SameInputSameOutput2908380976/001/stability-test.md(http block)https://api.github.com/repos/actions/upload-artifact/git/ref/tags/v4/usr/bin/gh gh api /repos/actions/upload-artifact/git/ref/tags/v4 --jq [.object.sha, .object.type] | @tsv /tmp/TestGuardPolicyMinIntegrityOnlymin-integrity_with_explicit_repo824905333/001 rev-parse /usr/bin/infocmp s ithub/workflows/rev-parse ithub/workflows/--show-toplevel infocmp -1 git git om/myorg/myrepo.git ithub/workflows/git ithub/workflows/rev-parse x_amd64/vet git(http block)https://api.github.com/repos/github/gh-aw-actions/git/ref/tags/v0.1.2/usr/bin/gh gh api /repos/github/gh-aw-actions/git/ref/tags/v0.1.2 --jq [.object.sha, .object.type] | @tsv f/tags/v6 64/pkg/tool/linuconfig sv LsRemoteWithRealgit LsRemoteWithRealrev-parse x_amd64/link infocmp -1 xterm-color x_amd64/link /usr/bin/git git status --porgit on x_amd64/compile git(http block)https://api.github.com/repos/github/gh-aw-actions/git/ref/tags/v1.0.0/usr/bin/gh gh api /repos/github/gh-aw-actions/git/ref/tags/v1.0.0 --jq [.object.sha, .object.type] | @tsv /tmp/TestGuardPolicyMinIntegrityOnlyCompiledOutput2344698764/001 config ache/go/1.25.8/x64/pkg/tool/linux_amd64/vet remote.origin.urgit --get nfig/composer/ve--show-toplevel ache/go/1.25.8/x64/pkg/tool/linux_amd64/vet(http block)https://api.github.com/repos/github/gh-aw-actions/git/ref/tags/v1.2.3/usr/bin/gh gh api /repos/github/gh-aw-actions/git/ref/tags/v1.2.3 --jq [.object.sha, .object.type] | @tsv --show-toplevel git /tmp/go-build3879776527/b431/parser.test --local --get sh /tmp/go-build3879776527/b431/parser.test -tes�� -test.paniconexit0 -test.v=true ache/node/24.14.1/x64/bin/node -test.timeout=10git -test.run=^Test -test.short=true--show-toplevel git(http block)https://api.github.com/repos/github/gh-aw/actions/runs/usr/bin/gh gh run list --json databaseId,number,url,status,conclusion,workflowName,createdAt,startedAt,updatedAt,event,headBranch,headSha,displayTitle --limit 100 --created >=2026-04-23(http block)/usr/bin/gh gh run list --json databaseId,number,url,status,conclusion,workflowName,createdAt,startedAt,updatedAt,event,headBranch,headSha,displayTitle --limit 100 --created >=2026-03-31(http block)/usr/bin/gh gh run list --json databaseId,number,url,status,conclusion,workflowName,createdAt,startedAt,updatedAt,event,headBranch,headSha,displayTitle --limit 100 --created >=2026-01-30(http block)https://api.github.com/repos/github/gh-aw/actions/runs/1/artifacts/usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/1/artifacts --jq .artifacts[].name --others 64/pkg/tool/linux_amd64/link(http block)/usr/bin/gh gh run download 1 --dir test-logs/run-1(http block)https://api.github.com/repos/github/gh-aw/actions/runs/12345/artifacts/usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/12345/artifacts --jq .artifacts[].name go-udiff@v0.4.1/export.go 64/pkg/tool/linux_amd64/vet rkflow/js/**/*.jgit(http block)/usr/bin/gh gh run download 12345 --dir test-logs/run-12345 64/src/internal/fuzz/counters_supported.go 64/pkg/tool/linux_amd64/vet(http block)https://api.github.com/repos/github/gh-aw/actions/runs/12346/artifacts/usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/12346/artifacts --jq .artifacts[].name(http block)/usr/bin/gh gh run download 12346 --dir test-logs/run-12346 .cfg x_amd64/vet(http block)https://api.github.com/repos/github/gh-aw/actions/runs/2/artifacts/usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/2/artifacts --jq .artifacts[].name .cfg 64/pkg/tool/linux_amd64/vet(http block)/usr/bin/gh gh run download 2 --dir test-logs/run-2(http block)https://api.github.com/repos/github/gh-aw/actions/runs/3/artifacts/usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/3/artifacts --jq .artifacts[].name .cfg 64/pkg/tool/linux_amd64/compile(http block)/usr/bin/gh gh run download 3 --dir test-logs/run-3(http block)https://api.github.com/repos/github/gh-aw/actions/runs/4/artifacts/usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/4/artifacts --jq .artifacts[].name --others 64/pkg/tool/linux_amd64/link(http block)/usr/bin/gh gh run download 4 --dir test-logs/run-4 piler_customsteps_test.go .cfg(http block)https://api.github.com/repos/github/gh-aw/actions/runs/5/artifacts/usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/5/artifacts --jq .artifacts[].name 64/src/testing/internal/testdeps/deps.go 64/pkg/tool/linux_amd64/vet(http block)/usr/bin/gh gh run download 5 --dir test-logs/run-5 go 64/pkg/tool/linux_amd64/compile(http block)https://api.github.com/repos/github/gh-aw/actions/workflows/usr/bin/gh gh workflow list --json name,state,path on' --ignore-path ../../../.prettierignore(http block)/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(http block)/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(http block)https://api.github.com/repos/github/gh-aw/contents/.github/workflows/shared/reporting.md/tmp/go-build3879776527/b404/cli.test /tmp/go-build3879776527/b404/cli.test -test.testlogfile=/tmp/go-build3879776527/b404/testlog.txt -test.paniconexit0 -test.v=true -test.parallel=4 -test.timeout=10m0s -test.run=^Test -test.short=true(http block)https://api.github.com/repos/github/gh-aw/git/ref/tags/v0.47.4/usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v0.47.4 --jq [.object.sha, .object.type] | @tsv --show-toplevel ortcfg /usr/bin/git edcfg(http block)https://api.github.com/repos/github/gh-aw/git/ref/tags/v1.0.0/usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v1.0.0 --jq [.object.sha, .object.type] | @tsv se 9776527/b050/vet.cfg k(http block)https://api.github.com/repos/github/gh-aw/git/ref/tags/v1.2.3/usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v1.2.3 --jq [.object.sha, .object.type] | @tsv get --local x_amd64/vet core.hooksPath(http block)https://api.github.com/repos/github/gh-aw/git/ref/tags/v2.0.0/usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v2.0.0 --jq [.object.sha, .object.type] | @tsv get --local x_amd64/vet core.hooksPath(http block)/usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v2.0.0 --jq [.object.sha, .object.type] | @tsv get --local x_amd64/vet copilot.originalgit(http block)/usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v2.0.0 --jq [.object.sha, .object.type] | @tsv --local credential.username x_amd64/vet(http block)https://api.github.com/repos/github/gh-aw/git/ref/tags/v3.0.0/usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v3.0.0 --jq [.object.sha, .object.type] | @tsv ithub/workflows k/gh-aw/gh-aw/pkg/cli/workflows/main x_amd64/vet copilot.originalgit(http block)https://api.github.com/repos/nonexistent/action/git/ref/tags/v999.999.999/usr/bin/gh gh api /repos/nonexistent/action/git/ref/tags/v999.999.999 --jq [.object.sha, .object.type] | @tsv se 9776527/b064/vet.cfg x_amd64/compile(http block)https://api.github.com/repos/nonexistent/repo/actions/runs/12345/usr/bin/gh gh run view 12345 --repo nonexistent/repo --json status,conclusion /../../.prettiergit(http block)https://api.github.com/repos/owner/repo/actions/workflows/usr/bin/gh gh workflow list --json name,state,path --repo owner/repo ode_modules/.bin/sh(http block)/usr/bin/gh gh workflow list --json name,state,path --repo owner/repo _modules/.bin/sh http.https://git/opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/vet(http block)/usr/bin/gh gh workflow list --repo owner/repo --json name,path,state .cfg ./../.prettieriggit(http block)https://api.github.com/repos/test-owner/test-repo/actions/secrets/usr/bin/gh gh api /repos/test-owner/test-repo/actions/secrets --jq .secrets[].name on' --ignore-path ../../../.prettierignore(http block)https://api.github.com/repos/test/repo/usr/bin/gh gh api /repos/test/repo --jq .default_branch util.test(http block)If you need me to access, download, or install something from one of these locations, you can either: