Skip to content

fix: gate PR Sous Chef agent launches on trusted refresh - #11280

Merged
lpcox merged 4 commits into
mainfrom
copilot/optimize-copilot-tokens-again
Nov 7, 2026
Merged

lpcox merged 4 commits into
mainfrom
copilot/optimize-copilot-tokens-again

Conversation

Copilot AI commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

29 of 35 inspected agent runs failed refreshing repeatedly selected PRs, spending ~10 AIC per run without producing value.

  • Pre-agent gating

    • Run the full target refresh before emitting eligibility. Incomplete metadata produces an empty queue and sanitized summary reason.
    • Recognize closed/merged PRs before requiring nullable branch metadata; retain fail-closed pagination checks.
  • Failure backoff

    • Cache failures by PR/HEAD: 30-minute exponential backoff, capped at four hours.
    • Exclude backed-off candidates before rotation; reconsider new HEADs immediately. Retain at most 100 records for 24 hours.
  • Smaller agent surface

    • Move API access into trusted host jobs, remove CLI-proxy, and explicitly disable compiler-default GitHub tooling:
      tools:
        edit: false
        github: false
        bash:
          - "cat /tmp/gh-aw/agent/pr-sous-chef-queue.json"
    • Move operator guidance outside the prompt, reducing authored prompt size by 62%; regenerate and post-process the lock.
  • Writer boundary unchanged

    • Preserve safe-output-only writes, isolated writer credentials, and exact target/body/HEAD validation.

Copilot AI linked an issue Nov 7, 2026 that may be closed by this pull request
9 tasks
Copilot AI changed the title [WIP] Optimize Copilot token usage for PR Sous Chef fix: gate PR Sous Chef agent launches on trusted refresh Nov 7, 2026
Copilot AI requested a review from lpcox November 7, 2026 20:10
@lpcox
lpcox marked this pull request as ready for review November 7, 2026 20:13
Copilot AI adaptive review requested due to automatic review settings November 7, 2026 20:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The compiled-lock checks do not exclude gh:* permissions or --difc-proxy-host, so regeneration could reintroduce the removed CLI-proxy access without failing tests.

1 open issue
What changed in this PR

Reduces wasted PR Sous Chef agent launches by refreshing targets before startup and backing off repeated metadata failures, addressing #11255 while preserving safe-output-only writes and writer validation.

Changes:

  • Gates agent startup on a successful trusted refresh and handles closed or merged PRs before validating nullable branch metadata.
  • Adds bounded, persistent per-PR/HEAD failure backoff so other candidates can proceed.
  • Removes agent-side GitHub tooling, shortens the prompt, and updates tests and the compiled workflow.
File Description
scripts/​ci/​pr-sous-chef.test.ts Adds refresh, backoff, metadata, and workflow safety coverage.
scripts/​ci/​pr-sous-chef.cjs Implements trusted refresh gating and bounded failure-state handling.
.github/​workflows/​pr-sous-chef.md Adds host-side cache steps, reduces agent access, and moves operator guidance outside the prompt.
.github/​workflows/​pr-sous-chef.lock.yml Regenerates the workflow with caching and reduced agent tooling and permissions.

Review effort: Max (auto)

Comment thread scripts/ci/pr-sous-chef.test.ts Resolved
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

✅ Copilot review passed with no inline comments.

@copilot Add the ready-for-aw label to this PR to trigger agentic CI smoke tests.

Comment thread .github/workflows/pr-sous-chef.lock.yml Resolved
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

✅ Coverage Check Passed

Overall Coverage

Metric Base PR Delta
Lines 93.76% 93.80% 📈 +0.04%
Statements 92.31% 92.35% 📈 +0.04%
Functions 93.00% 93.02% 📈 +0.02%
Branches 86.56% 86.67% 📈 +0.11%
📁 Per-file Coverage Changes (6 files)
File Lines (Before → After) Statements (Before → After)
src/cloud-hypervisor/enclave-session-diagnostics.ts 100.0% → 100.0% (+0.00%) 97.5% → 97.6% (+0.06%)
src/enclave/host-executor-server.ts 91.2% → 91.2% (+0.00%) 90.1% → 89.8% (-0.29%)
src/cloud-hypervisor/host-enclave-executor.ts 93.0% → 93.0% (+0.01%) 90.7% → 90.7% (+0.04%)
src/enclave/docker-host-executor.ts 94.8% → 95.9% (+1.02%) 89.4% → 90.8% (+1.40%)
src/enclave/public-debug-artifacts.ts 94.7% → 96.0% (+1.32%) 93.3% → 94.4% (+1.13%)
src/enclave/docker-host-storage.ts 69.4% → 71.5% (+2.12%) 66.0% → 68.5% (+2.47%)

Coverage comparison generated by scripts/ci/compare-coverage.ts

@lpcox

lpcox commented Nov 7, 2026

Copy link
Copy Markdown
Collaborator

PR sous-chef: human handoff (not merge-ready certification).

Human review or current-head review evidence is still needed.
A maintainer should inspect the worker's local-validation evidence, outstanding review decisions, and current HEAD before manually applying ready-for-aw. This label authorizes expensive agentic CI; do not add it until satisfied.
This handoff is not human review acceptance or proof that all required CI passed on this HEAD. Agent pushes can leave CI stale, and an existing label does not prove a new HEAD was tested. Docker/KVM suites not run locally must be disclosed by the worker.

Sous-chef kind: handoff
Sous-chef head: 9407282
Sous-chef state: c86083666424c3558f1fb96b11c55e53c7f6854200388997d846b7ba4fcf6636

Generated by PR Sous Chef · copilot · auto (Claude Sonnet 5.5) · ~12 AIC · ⌖ ~13 AIC · ⊞ 10.9K · ◷

@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

✅ Smoke Copilot BYOK AOAI (api-key) completed. Copilot AOAI BYOK (api-key) mode operational. 🔓

🔑 BYOK (AOAI api-key) report filed by Smoke Copilot BYOK AOAI (api-key)

@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

✅ Smoke Claude passed

Generated by Smoke Claude for #11280

@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

🔌 Smoke Services is testing service connectivity for this pull request...

@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

❌ Smoke Copilot BYOK reports failed. BYOK mode investigation needed...

🔑 BYOK report filed by Smoke Copilot BYOK

@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

🚀 Security Guard has started processing this pull request

@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

✨ The prophecy is fulfilled... Smoke Codex has completed its mystical journey. The stars align. 🌟

🔮 The oracle has spoken through Smoke Codex

@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Chroot tests passed! Smoke Chroot - All security and functionality tests succeeded.

Tested by Smoke Chroot

@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

📡 Smoke OTel Tracing completed. All tracing scenarios validated. ✅

📡 OTel tracing validated by Smoke OTel Tracing

@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

🪪 Smoke Copilot BYOK AOAI (Entra) is testing Azure OpenAI BYOK (Entra / GitHub OIDC) mode on this pull request...

@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

🛡️ Smoke Copilot Network Isolation confirmed the egress allowlist is enforced. ✅

🛡️ Egress verdict from Smoke Copilot Network Isolation

@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤

📰 BREAKING: Report filed by Smoke Copilot

@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

💎 Smoke Gemini is crystallizing results on this pull request...

@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Smoke Cloud Hypervisor completed. Cloud Hypervisor + Copilot passed.

Cloud Hypervisor + Copilot smoke test by Smoke Cloud Hypervisor

@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

✅ Build Test Suite completed successfully!

Generated by Build Test Suite for #11280

@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Cloud Hypervisor + Copilot smoke test

  1. Merged PR lookup: PASS
  2. github.com connectivity: PASS (HTTP 200)
  3. File write/read: PASS
  4. example.com blocked: PASS (HTTP 000)

Overall: PASS

Cloud Hypervisor + Copilot smoke test by Smoke Cloud Hypervisor
Add label ready-for-aw to run again

@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

GitHub MCP Testing: ✅
GitHub.com Connectivity: ✅
File Write/Read Test: ✅
BYOK Inference Test: ✅
Running in direct BYOK mode (COPILOT_PROVIDER_API_KEY + COPILOT_PROVIDER_BASE_URL) via api-proxy → Azure OpenAI (Foundry, o4-mini-aw)
Overall: PASS @Copilot @lpcox

🔑 BYOK (AOAI api-key) report filed by Smoke Copilot BYOK AOAI (api-key)
Add label ready-for-aw to run again

@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

OTEL smoke test

  • ✅ S1: otel.js loads; exports startRequestSpan, setTokenAttributes, setBudgetAttributes, endSpan, endSpanError, routerCallTracing, shutdown, isEnabled
  • ✅ S2: OTEL tests 3 suites / 75 tests passed
  • ✅ S3: env-passthrough.ts forwards GITHUB_AW_OTEL_TRACE_ID/PARENT_SPAN_ID; api-proxy-env-config.ts forwards OTEL vars
  • ✅ S4: onUsage hook present in token-tracker-http.js
  • ⚠️ S5: otel.jsonl has 1 line (agent-level); no api-proxy spans exported (api-proxy not necessarily active in this run)

📡 OTel tracing validated by Smoke OTel Tracing
Add label ready-for-aw to run again

@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor
  • Retain actionable public enclave result failures and audit evidence ✅
  • fix: align Docker enclave verification and retain failure evidence ✅
  • GitHub PR details ✅
  • Playwright title check ❌
  • File write/read ✅
  • Build AWF ✅
  • Overall status: FAIL

🔮 The oracle has spoken through Smoke Codex
Add label ready-for-aw to run again

@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Chroot Version Comparison

Runtime Host Version Chroot Version Match?
Python Python 3.12.16 Python 3.12.16 ✅ YES
Node.js v24.22.2 v2.98.0 ❌ NO
Go go1.22.12 go1.22.12 ✅ YES

Result: failed. The Node.js versions differ, so the smoke-chroot label was not added.

Tested by Smoke Chroot
Add label ready-for-aw to run again

@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Smoke Test: Copilot BYOK (Direct Mode) ✅ PASS

✅ GitHub.com connectivity (HTTP 200)
✅ File write/read verification
✅ GitHub MCP connectivity
✅ BYOK inference (agent → api-proxy → api.githubcopilot.com)

Running in direct BYOK mode via COPILOT_PROVIDER_API_KEY

🔑 BYOK report filed by Smoke Copilot BYOK
Add label ready-for-aw to run again

@github-actions github-actions Bot added smoke-copilot-byok smoke-copilot-network-isolation Copilot network-isolation egress smoke test labels Nov 7, 2026
@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

EGRESS_RESULT allow=pass deny=pass

  • ✅ Allowed domain (api.github.com → 200)
  • ✅ Blocked domain (example.com blocked)

Overall: PASS — @lpcox

🛡️ Egress verdict from Smoke Copilot Network Isolation
Add label ready-for-aw to run again

@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Smoke (Copilot): PRs: "fix: gate PR Sous Chef agent launches on trusted refresh"

  • GitHub MCP ✅
  • github.com 200 ✅
  • File write/read ✅

Overall: PASS. cc @Copilot @lpcox

📰 BREAKING: Report filed by Smoke Copilot
Add label ready-for-aw to run again

@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

🏗️ Build Test Suite Results

Ecosystem Project Build/Install Tests Status
Bun elysia ✅ 1/1 passed ✅ PASS
Bun hono ✅ 1/1 passed ✅ PASS
C++ fmt ✅ N/A ✅ PASS
C++ json ✅ N/A ✅ PASS
Deno oak N/A 1/1 passed ✅ PASS
Deno std N/A 1/1 passed ✅ PASS
.NET hello-world ✅ N/A ✅ PASS
.NET json-parse ✅ N/A ✅ PASS
Go color ✅ 1 pkg ok ✅ PASS
Go env ✅ 1 pkg ok ✅ PASS
Go uuid ✅ 1 pkg ok ✅ PASS
Java gson ❌ 0 (not run) ❌ FAIL
Java caffeine ❌ 0 (not run) ❌ FAIL
Node.js clsx ✅ passed ✅ PASS
Node.js execa ✅ passed ✅ PASS
Node.js p-limit ✅ passed ✅ PASS
Rust fd ✅ 1/1 passed ✅ PASS
Rust zoxide ✅ 1/1 passed ✅ PASS

Overall: 7/8 ecosystems passed — FAIL

Java failure: Maven could not resolve maven-resources-plugin:3.4.0 from Maven Central. The transfer failed with (internal_error) Unexpected error through the configured squid-proxy:3128 proxy. The default ~/.m2 repository was also not accessible (LocalRepositoryNotAccessibleException). A disposable local repo at /tmp/gh-aw/agent/m2 gave the same transfer error.

.NET note: The first run crashed in first-time-use setup because /run/user/1001 does not exist. It passed after setting DOTNET_CLI_HOME and XDG_RUNTIME_DIR to writable temp dirs.

The build-test label was not added because of the Java failures.

Generated by Build Test Suite for #11280 · copilot · auto (Claude Sonnet 5.5) · ~26 AIC · ⊞ 5.9K · ◷
Add label ready-for-aw to run again

@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Smoke Test: Claude Engine Validation

Check Result
API status ✅ PASS
gh check ✅ PASS
File status ✅ PASS

Overall result: PASS

Generated by Smoke Claude for #11280 · claude · haiku45 · ~36 AIC · ⊞ 6.3K · ◷
Add label ready-for-aw to run again

@lpcox
lpcox merged commit 1cff5b1 into main Nov 7, 2026
139 of 149 checks passed
@lpcox
lpcox deleted the copilot/optimize-copilot-tokens-again branch November 7, 2026 22:08

This branch had an error being deployed

1 failed deployment
aoai-model — 94072820 Deployed Nov 7, 2026 by lpcox via conclusion #2286
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

⚡ Copilot Token Optimization2026-11-07 — PR Sous Chef

4 participants