Skip to content

Reduce ambient context cost in daily workflows (go-logger, sergo, smoke-copilot)#36852

Merged
pelikhan merged 3 commits into
mainfrom
copilot/ambient-context-optimizer-2026-06-04
Jun 4, 2026
Merged

Reduce ambient context cost in daily workflows (go-logger, sergo, smoke-copilot)#36852
pelikhan merged 3 commits into
mainfrom
copilot/ambient-context-optimizer-2026-06-04

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jun 4, 2026

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

    • Added a pre-activation manifest step in go-logger.md to compute:
      • preflight.json (should_run, SHAs, paths)
      • manifest.json (files needing logger/imports/candidate call sites)
    • Gated agent execution on preflight output so unchanged runs can short-circuit.
    • Replaced iterative discovery guidance with manifest consumption.
    • Added compact structured patch schema guidance for logger diffs.
  • Sergo: flatten prompt structure + externalize examples

    • Refactored sergo.md from heading-heavy/template-heavy form to a compact execution plan.
    • Removed embedded example fences from the base prompt.
    • Added bounded strategy-history loading guidance (recent entries only).
    • Introduced conditional examples skill: .github/skills/sergo-examples/SKILL.md.
  • Smoke Copilot: trim largest static section

    • Condensed ## Test Requirements in smoke-copilot.md while preserving required checks and outputs.
    • Reduced repeated phrasing/instruction overhead in the highest-cost section.
  • Compiled artifacts updated

    • Regenerated:
      • .github/workflows/go-logger.lock.yml
      • .github/workflows/sergo.lock.yml
      • .github/workflows/smoke-copilot.lock.yml

Example (go-logger preflight gate + manifest output):

steps:
  - name: Build deterministic logger manifest
    id: logger_manifest
    run: |
      # writes /tmp/gh-aw/agent/go-logger/preflight.json + manifest.json
      # emits should_run=true|false
if: needs.pre_activation.outputs.should_run == 'true' || github.event_name == 'workflow_dispatch'
jobs:
  pre-activation:
    outputs:
      should_run: ${{ steps.logger_manifest.outputs.should_run }}

Copilot AI and others added 2 commits June 4, 2026 06:14
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
Copilot AI requested a review from pelikhan June 4, 2026 06:20
@pelikhan pelikhan marked this pull request as ready for review June 4, 2026 12:27
Copilot AI review requested due to automatic review settings June 4, 2026 12:27
@pelikhan pelikhan merged commit f4404c3 into main Jun 4, 2026
1 check passed
@pelikhan pelikhan deleted the copilot/ambient-context-optimizer-2026-06-04 branch June 4, 2026 12:28
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 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-logger workflow.
  • 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.yml artifacts.
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
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.

[ambient-context] Daily Ambient Context Optimizer - 2026-06-04

3 participants