Reduce ambient context cost in daily workflows (go-logger, sergo, smoke-copilot)#36852
Merged
Merged
Conversation
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] Update daily ambient context optimizer findings
Reduce ambient context cost in daily workflows (go-logger, sergo, smoke-copilot)
Jun 4, 2026
pelikhan
approved these changes
Jun 4, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR aims to reduce recurring context/token overhead in daily agent workflows by making expensive discovery more deterministic (manifest/preflight), trimming always-on prompt bulk, and regenerating compiled lock workflows accordingly.
Changes:
- Added a deterministic preflight/manifest step and attempted gating for the
go-loggerworkflow. - Refactored
sergo’s base prompt into a compact execution plan and moved format examples into an optional skill. - Condensed
smoke-copilot’s “Test Requirements” section and regenerated affected.lock.ymlartifacts.
Show a summary per file
| File | Description |
|---|---|
| .github/workflows/smoke-copilot.md | Condenses the Test Requirements section to reduce static prompt bulk. |
| .github/workflows/smoke-copilot.lock.yml | Regenerated compiled workflow artifact for the updated smoke-copilot prompt. |
| .github/workflows/sergo.md | Flattens/shortens Sergo’s workflow prompt and adds guidance to load bounded history. |
| .github/workflows/sergo.lock.yml | Regenerated compiled workflow artifact for the updated Sergo prompt. |
| .github/workflows/go-logger.md | Adds deterministic manifest/preflight generation and introduces a gate intended to skip unchanged runs. |
| .github/workflows/go-logger.lock.yml | Regenerated compiled workflow artifact reflecting the go-logger changes (but currently contains a broken gate). |
| .github/skills/sergo-examples/SKILL.md | New optional skill containing Sergo format/examples moved out of the base prompt. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 7/7 changed files
- Comments generated: 3
Comment on lines
19
to
+23
| steps: | ||
| - name: Build deterministic logger manifest | ||
| id: logger_manifest | ||
| run: | | ||
| set -euo pipefail |
Comment on lines
90
to
93
| jobs: | ||
| activation: | ||
| if: needs.pre_activation.outputs.should_run == 'true' || github.event_name == 'workflow_dispatch' | ||
| runs-on: ubuntu-slim |
Comment on lines
+447
to
451
| - id: logger_manifest | ||
| name: Build deterministic logger manifest | ||
| run: "set -euo pipefail\ncache_dir=\"/tmp/gh-aw/cache-memory/go-logger\"\nout_dir=\"/tmp/gh-aw/agent/go-logger\"\nmkdir -p \"$cache_dir\" \"$out_dir\"\n\ncurrent_sha=\"$(git rev-parse HEAD)\"\ncurrent_files=\"$out_dir/current-files.txt\"\nprocessed_files=\"$cache_dir/processed-files.txt\"\nfind pkg -name '*.go' -type f ! -name '*_test.go' | sort > \"$current_files\"\n[ -f \"$processed_files\" ] || : > \"$processed_files\"\n\nnew_files=\"$out_dir/new-files.txt\"\ncomm -23 \"$current_files\" \"$processed_files\" > \"$new_files\" || true\n\nlast_sha=\"\"\nif [ -f \"$cache_dir/last-run.json\" ]; then\n last_sha=\"$(jq -r '.commit_sha // empty' \"$cache_dir/last-run.json\" 2>/dev/null || true)\"\nfi\n\nfiles_needing_logger=\"$out_dir/files-needing-logger.txt\"\nfiles_missing_logger_import=\"$out_dir/files-missing-logger-import.txt\"\ncall_sites=\"$out_dir/call-sites.tsv\"\n: > \"$files_needing_logger\"\n: > \"$files_missing_logger_import\"\n: > \"$call_sites\"\n\nwhile IFS= read -r rel; do\n [ -f \"$rel\" ] || continue\n if ! grep -q \"var log = logger.New\" \"$rel\"; then\n echo \"$rel\" >> \"$files_needing_logger\"\n fi\n if grep -q \"log\\\\.\" \"$rel\" && ! grep -q '\"github.com/github/gh-aw/pkg/logger\"' \"$rel\"; then\n echo \"$rel\" >> \"$files_missing_logger_import\"\n fi\n while IFS=: read -r line_number match_line; do\n function_name=\"$(printf '%s' \"$match_line\" | sed -E 's/^[[:space:]]*func[[:space:]]+([A-Za-z0-9_]+).*/\\\\1/')\"\n printf \"%s\\\\t%s\\\\t%s\\\\n\" \"$rel\" \"$line_number\" \"$function_name\" >> \"$call_sites\"\n done < <(grep -nE \"^[[:space:]]*func[[:space:]]+[A-Za-z0-9_]+\" \"$rel\" || true)\ndone < \"$current_files\"\n\njq -n \\\n --argjson files_needing_logger \"$(jq -R -s 'split(\\\"\\\\n\\\") | map(select(length > 0))' \"$files_needing_logger\")\" \\\n --argjson missing_logger_import \"$(jq -R -s 'split(\\\"\\\\n\\\") | map(select(length > 0))' \"$files_missing_logger_import\")\" \\\n --argjson candidate_call_sites \"$(jq -R -s 'split(\\\"\\\\n\\\") | map(select(length > 0) | split(\\\"\\\\t\\\") | {file: .[0], line: (.[1] | tonumber), function: .[2]})' \"$call_sites\")\" \\\n '{files_needing_logger: $files_needing_logger, missing_logger_import: $missing_logger_import, candidate_call_sites: $candidate_call_sites}' \\\n > \"$out_dir/manifest.json\"\n\nshould_run=true\nif [ \"$current_sha\" = \"$last_sha\" ] && [ ! -s \"$new_files\" ]; then\n should_run=false\nfi\necho \"{\\\"should_run\\\": \\\"$should_run\\\", \\\"current_sha\\\": \\\"$current_sha\\\", \\\"last_sha\\\": \\\"$last_sha\\\", \\\"manifest\\\": \\\"$out_dir/manifest.json\\\", \\\"new_files\\\": \\\"$new_files\\\"}\" > \"$out_dir/preflight.json\"\necho \"should_run=$should_run\" >> \"$GITHUB_OUTPUT\"\n" | ||
| - name: Setup Go | ||
| uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0 |
This was referenced Jun 4, 2026
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.
Daily optimizer findings showed token burn was dominated by turn proliferation (go-logger), structural prompt overhead (sergo), and verbose static requirements (smoke-copilot), not just raw prompt size. This PR reduces recurring context load by front-loading deterministic preprocessing and removing always-on prompt bulk.
Go Logger: deterministic preflight + manifest-first flow
go-logger.mdto compute:preflight.json(should_run, SHAs, paths)manifest.json(files needing logger/imports/candidate call sites)Sergo: flatten prompt structure + externalize examples
sergo.mdfrom heading-heavy/template-heavy form to a compact execution plan..github/skills/sergo-examples/SKILL.md.Smoke Copilot: trim largest static section
## Test Requirementsinsmoke-copilot.mdwhile preserving required checks and outputs.Compiled artifacts updated
.github/workflows/go-logger.lock.yml.github/workflows/sergo.lock.yml.github/workflows/smoke-copilot.lock.ymlExample (go-logger preflight gate + manifest output):