Skip to content

perf(contribution-check): cut token/tool overhead per #5558#5576

Merged
lpcox merged 1 commit into
mainfrom
perf/contribution-check-token-optim-5558
Jun 26, 2026
Merged

perf(contribution-check): cut token/tool overhead per #5558#5576
lpcox merged 1 commit into
mainfrom
perf/contribution-check-token-optim-5558

Conversation

@lpcox

@lpcox lpcox commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

Implements the actionable recommendations from #5558 to reduce the token/tool overhead of the Contribution Check workflow (ranked #1 by total AIC). All review data is pre-fetched in steps:, so the agent only needs to read three context files and emit a single add_comment (or noop).

Changes

# Recommendation Applied
2 Stop loading GitHub tools tools.github: false (see note)
3 max-turns 5 → 3
4 strict false → true
5 Tighten prompt's tool constraint

⚠️ Important correction to recommendation #2

The issue suggested removing the tools: block entirely. That backfires on this gh-aw version: with no explicit tools.github, gh-aw auto-injects a read-only GitHub MCP server with a broader toolset (context,repos,issues,pull_requests) than the original gh-proxy/[pull_requests] config — adding tool schemas and a github-mcp-server container, the opposite of the goal.

The correct way to drop GitHub tools is the explicit github: false (same pattern as doc-maintainer.md). This removes the github-mcp-server and cli-proxy containers and eliminates the ~5.3 stray GitHub API calls/run. The compiled lock file shrinks by ~150 lines (86 KB → 79 KB). edit: is kept so the agent can read the pre-fetched files; the safeoutputs MCP that backs add_comment is unaffected.

strict mode

Enabling strict: true required removing the internal sandbox.mcp.version: "latest" key, which strict mode disallows (it's an internal implementation detail).

Verification

  • gh aw compile contribution-check → 0 errors, 0 warnings.
  • Lock no longer contains github-mcp-server, GITHUB_TOOLSETS, or a cli-proxy container; safeoutputs MCP + add_comment preserved.
  • scripts/ci/contribution-check-workflow.test.ts updated (max-turns: 53) and passing.

Risk note (max-turns)

max-turns: 3 maps to the api-proxy maxRuns: 3 hard cap. If the agent ever needs a 4th LLM invocation it will receive the terminal 403 (max_runs_exceeded) that surfaces as a misleading "authentication failed" engine error (cf. #5552). Removing GitHub tools frees up the turns previously wasted on stray gh calls, so the linear read→comment task should fit comfortably in 3 — but a live test PR (per the issue's checklist) is the right way to confirm before relying on it.

Out of scope

Recommendation #1 (all Copilot runs report null token_usage) is a separate, systemic api-proxy telemetry-export investigation, not a per-workflow change. Not addressed here.

Refs #5558

Token-optimization pass on the Contribution Check workflow (ranked #1
by total AIC). All review data is already pre-fetched in `steps:`, so
the agent only needs to read three context files and emit a single
`add_comment` (or noop) safe-output.

Changes:
- tools: disable GitHub tools (`github: false`) instead of the previous
  `gh-proxy`/`pull_requests` config. NOTE: simply *removing* the tools
  block makes gh-aw auto-inject a read-only GitHub MCP server with a
  *broader* toolset (context,repos,issues,pull_requests), which is the
  opposite of the optimization goal. Explicit `github: false` drops the
  github-mcp-server and cli-proxy containers entirely and prevents the
  ~5.3 stray GitHub API calls/run the agent was making despite the
  prompt forbidding them. (lock file shrinks ~150 lines.) Keep `edit:`
  so the agent can read the pre-fetched files.
- strict: false -> true (also required removing the internal
  `sandbox.mcp.version` key, which strict mode disallows).
- max-turns: 5 -> 3 (linear task: read files -> compare -> comment).
- Prompt: add an explicit "only add_comment or noop" tool constraint.
- Recompiled contribution-check.lock.yml; updated the workflow test's
  max-turns assertion 5 -> 3.

Out of scope: recommendation #1 (all Copilot runs report null
token_usage) is a separate, systemic api-proxy telemetry-export
investigation, not a per-workflow change.

Refs #5558

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 26, 2026 15:52
@github-actions

Copy link
Copy Markdown
Contributor

✅ Coverage Check Passed

Overall Coverage

Metric Base PR Delta
Lines 98.24% 98.28% 📈 +0.04%
Statements 98.17% 98.21% 📈 +0.04%
Functions 99.53% 99.53% ➡️ +0.00%
Branches 94.00% 94.00% ➡️ +0.00%
📁 Per-file Coverage Changes (1 files)
File Lines (Before → After) Statements (Before → After)
src/workdir-setup.ts 92.7% → 94.5% (+1.82%) 92.7% → 94.5% (+1.82%)

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

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.

Pull request overview

Reduces Copilot token/tool overhead in the Contribution Check agentic workflow by removing GitHub MCP tooling from the agent runtime, tightening execution constraints, and updating the compiled lock + CI test to match.

Changes:

  • Lowered the agent turn cap from 5 → 3 and enabled strict: true for tighter runtime behavior.
  • Disabled GitHub MCP tools for the agent via tools.github: false while keeping tools.edit so the agent can read the pre-fetched context files.
  • Tightened the prompt to explicitly limit post-read tool usage to add_comment (max 1) or noop, and updated the workflow test + regenerated the lock file accordingly.
Show a summary per file
File Description
scripts/ci/contribution-check-workflow.test.ts Updates the workflow guard test to expect max-turns: 3.
.github/workflows/contribution-check.md Applies the workflow-level optimization knobs (turn cap, strict mode, tool disablement) and strengthens the prompt’s tool-use constraints.
.github/workflows/contribution-check.lock.yml Regenerates the compiled lock to reflect the updated workflow configuration and removed GitHub MCP/cli-proxy components.

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 3/3 changed files
  • Comments generated: 0
  • Review effort level: Low

@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Smoke Copilot BYOK AOAI (Entra) completed. Copilot AOAI BYOK (Entra) mode operational. 🔓

@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Build Test Suite completed successfully!

@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Smoke Claude passed

@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

🔑 Smoke Copilot PAT PAT auth validated. All systems operational. ✅

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Security Guard has started processing this pull request

@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Smoke Copilot BYOK completed. Copilot BYOK mode operational. 🔓

@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

🔌 Smoke Services — All services reachable! ✅

@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Smoke Gemini completed. All facets verified. 💎

@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Contribution Check failed. Please review the logs for details.

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test: Claude Engine Validation

  • API check: ✅ PASS
  • gh check: ✅ PASS
  • File check: ✅ PASS

Overall result: PASS

Generated by Smoke Claude for issue #5576 · 37.2 AIC · ⊞ 3.3K ·

@github-actions

Copy link
Copy Markdown
Contributor

🔥 Smoke Test: Copilot PAT — PASS

Test Result
GitHub MCP connectivity
GitHub.com HTTP ✅ 200
File write/read

Overall: PASS · Auth mode: PAT (COPILOT_GITHUB_TOKEN)

cc @lpcox

🔑 PAT report filed by Smoke Copilot PAT

@github-actions

Copy link
Copy Markdown
Contributor

🔬 Smoke Test Results

Test Status
GitHub MCP connectivity ✅ PASS
GitHub.com HTTP ✅ PASS (200)
File write/read ⚠️ N/A (pre-step data unavailable)

PR: perf(contribution-check): cut token/tool overhead per #5558
Author: @lpcox

Overall: PASS

📰 BREAKING: Report filed by Smoke Copilot

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test: Copilot BYOK (Direct) Mode ✅

PASS — All smoke tests confirmed.

✅ GitHub MCP connectivity verified (2 recent closed PRs)
✅ BYOK inference path working (agent → api-proxy sidecar → api.githubcopilot.com)

Running in direct BYOK mode via COPILOT_PROVIDER_API_KEY.

🔑 BYOK report filed by Smoke Copilot BYOK

@github-actions

Copy link
Copy Markdown
Contributor

Smoke test summary

  • fix: propagate apiProxy.auth OIDC config fields to all layers
  • [Test Coverage] security: test coverage for compose-sanitizer, domain-validation, and domain-matchers
  • GitHub read checks ✅
  • Playwright GitHub title ✅
  • File write/read ✅
  • Build (npm ci && npm run build) ✅
    Overall: PASS

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • registry.npmjs.org

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "registry.npmjs.org"

See Network Configuration for more information.

🔮 The oracle has spoken through Smoke Codex

@github-actions

Copy link
Copy Markdown
Contributor

🔬 Smoke Test: API Proxy OpenTelemetry Tracing

Scenario Result Detail
1. Module Loading otel.js loads cleanly; exports startRequestSpan, setTokenAttributes, setBudgetAttributes, endSpan, endSpanError, shutdown, isEnabled + test helpers. isEnabled() returns true (FileSpanExporter fallback active when no OTLP endpoint set).
2. Test Suite otel.test.js: 39/39 passed; otel-fanout.test.js: 20/20 passed (59 total, 0 failures).
3. Env Var Forwarding src/services/api-proxy-env-config.ts forwards GH_AW_OTLP_ENDPOINTS, OTEL_EXPORTER_OTLP_ENDPOINT, OTEL_EXPORTER_OTLP_HEADERS, GITHUB_AW_OTEL_TRACE_ID, GITHUB_AW_OTEL_PARENT_SPAN_ID, and OTEL_SERVICE_NAME (default: awf-api-proxy) to the api-proxy container.
4. Token Tracker Integration token-tracker-http.js exposes onUsage callback (line 283/324); called after normalized usage extraction — OTEL hook point confirmed.
5. OTEL Diagnostics No spans exported — api-proxy container not started in this sandbox (Docker-in-Docker not supported). Expected for static analysis runs; spans will appear in live integration tests.

Summary: All functional scenarios pass. Scenario 5 is a runtime-only check that requires a live container; its absence here is expected.

📡 OTel tracing validated by Smoke OTel Tracing

@github-actions

Copy link
Copy Markdown
Contributor

@lpcox
GitHub MCP PRs: perf(contribution-check): cut token/tool overhead per #5558; Split squid config tests by concern ✅
GitHub.com connectivity: ✅
File write/read: ✅
Direct BYOK inference: ✅

Running in direct BYOK mode (AWF_AUTH_TYPE=github-oidc + AWF_AUTH_AZURE_* + COPILOT_PROVIDER_BASE_URL) via api-proxy → Azure OpenAI (Foundry, o4-mini-aw) authenticated via Microsoft Entra

Overall: PASS

🪪 BYOK (AOAI Entra) report filed by Smoke Copilot BYOK AOAI (Entra)

@github-actions

Copy link
Copy Markdown
Contributor

Chroot Smoke Test Results

Runtime Host Version Chroot Version Match?
Python Python 3.12.13 Python 3.12.3
Node.js v24.17.0 v22.23.0
Go go1.22.12 go1.22.12

Overall: ❌ Not all tests passed — Python and Node.js versions differ between host and chroot.

Tested by Smoke Chroot

@github-actions

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/1 passed ✅ PASS
Go env 1/1 passed ✅ PASS
Go uuid 1/1 passed ✅ PASS
Java gson 1/1 passed ✅ PASS
Java caffeine 1/1 passed ✅ PASS
Node.js clsx all passed ✅ PASS
Node.js execa all passed ✅ PASS
Node.js p-limit all passed ✅ PASS
Rust fd 1/1 passed ✅ PASS
Rust zoxide 1/1 passed ✅ PASS

Overall: 8/8 ecosystems passed — ✅ PASS

Generated by Build Test Suite for issue #5576 · 35.9 AIC · ⊞ 7.8K ·

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test Results

  • ❌ GitHub MCP Testing (Tools not found)
  • ❌ GitHub.com Connectivity (Connection blocked)
  • ✅ File Writing Testing
  • ✅ Bash Tool Testing

Overall status: FAIL

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • localhost

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "localhost"

See Network Configuration for more information.

💎 Faceted by Smoke Gemini

@github-actions

Copy link
Copy Markdown
Contributor

perf(contribution-check): cut token/tool overhead per #5558
Split squid config tests by concern
GitHub MCP connectivity: ✅
github.com connectivity: ✅
File I/O: ✅
BYOK inference: ✅
Running in direct BYOK mode (COPILOT_PROVIDER_API_KEY + COPILOT_PROVIDER_BASE_URL) via api-proxy → Azure OpenAI (Foundry, o4-mini-aw)
Overall: PASS

@lpcox

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

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test Results — Services Connectivity

Check Result
Redis PING ❌ Timeout (RC=124)
PostgreSQL pg_isready ❌ No response
PostgreSQL SELECT 1 ❌ Timeout (RC=124)

Overall: FAILhost.docker.internal is unreachable from this sandbox. All three connections timed out with no response.

🔌 Service connectivity validated by Smoke Services

@lpcox lpcox merged commit 3378a60 into main Jun 26, 2026
88 of 90 checks passed
@lpcox lpcox deleted the perf/contribution-check-token-optim-5558 branch June 26, 2026 18:17
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.

2 participants