Skip to content

Precompute test-quarantine Part 1 gathering in pre-activation - #67167

Merged
wtgodbe merged 2 commits into
dotnet:mainfrom
wtgodbe:infrastructure/precompute-quarantine-part1
Jun 11, 2026
Merged

wtgodbe merged 2 commits into
dotnet:mainfrom
wtgodbe:infrastructure/precompute-quarantine-part1

Conversation

@wtgodbe

@wtgodbe wtgodbe commented Jun 11, 2026

Copy link
Copy Markdown
Member

Problem

The daily test-quarantine agentic workflow has failed for 9+ consecutive days, each time tripping the per-run effective-token cap (GH_AW_MAX_EFFECTIVE_TOKENS) while still gathering Part 1 failure data — it dies before creating any quarantine PR/issue. Effective tokens are ~10× raw input and every agent turn re-sends the whole conversation, so the in-loop Azure DevOps/Helix gathering (build lists, resultsbyBuild, and multi-MB Helix console logs across ~200 builds) is the dominant cost.

Fix

Move all Part 1 (Sources A/B/C) gathering into a deterministic Aggregate Part 1 failures pre-activation step, which runs outside the firewall at zero effective-token cost, and inject one compact JSON blob (part1_data, ~170 KB, validated against 30 days of real data) into the agent prompt. The agent now makes zero AzDO/Helix calls for Part 1 — it only does judgment + output creation. This mirrors the existing Verify Source B PRs pre-activation pattern.

Highlights

  • Reliable Helix resolution: job id + work-item name come from the AzDO test-result-detail comment field instead of fragile build-timeline parsing; individual tests also carry their real errorMessage/stackTrace.
  • Correctness preserved: a compact builds metadata map (def, startedUtc, finishedUtc, sourceVersion, pr) keeps the Step 1.2 Case B "failure after the unquarantine landed" timing check and the Source B "PR modified its own test" exclusion working without any agent AzDO call.
  • Source C: downloads Helix console logs and extracts only [FAIL] blocks, probing multiple builds until one is found, bounded by a global download budget so a regression spell can't download gigabytes.
  • Output safety: emit() guarantees the blob stays under the 1 MB GITHUB_OUTPUT limit by progressively shedding optional enrichment (never the per-test counts) and fails loud rather than letting GitHub silently truncate into corrupt JSON.

Part 2 (passing-data + source mapping) is intentionally left in the agent loop and will be addressed separately.

Reviewed adversarially across multiple models; all flagged correctness issues (output size guard, Source C multi-occurrence probing + graceful truncation, Helix coord guards, fail-loud on malformed inputs, uncapped per-test build IDs) were addressed and unit-tested.

The daily test-quarantine workflow has failed for 9+ consecutive days by
tripping the per-run effective-token cap (GH_AW_MAX_EFFECTIVE_TOKENS) while
still gathering Part 1 failure data -- it died before creating any PR/issue.
Effective tokens are ~10x raw input and every agent turn re-sends the whole
conversation, so the in-loop AzDO/Helix gathering (build lists, resultsbyBuild,
and multi-MB Helix console logs across ~200 builds) was the dominant cost.

Move all Part 1 (Sources A/B/C) gathering into a deterministic
"Aggregate Part 1 failures" pre-activation step, which runs outside the
firewall at zero effective-token cost, and inject one compact JSON blob
(part1_data, ~170 KB, validated against 30 days of real data) into the agent
prompt. The agent now makes ZERO AzDO/Helix calls for Part 1 -- it only does
judgment and output creation. This mirrors the existing "Verify Source B PRs"
pre-activation pattern.

Highlights:
- Helix job id + work-item name come from the AzDO test-result-detail `comment`
  field (reliable) instead of fragile build-timeline parsing; individual tests
  also carry their real errorMessage/stackTrace.
- A compact `builds` metadata map (def, startedUtc, finishedUtc, sourceVersion,
  pr) preserves the Step 1.2 Case B timing and Source B self-PR-exclusion checks
  without any agent AzDO call.
- Source C downloads Helix console logs and extracts only [FAIL] blocks, probing
  multiple builds until one is found, bounded by a global download budget.
- emit() guarantees the output stays under the 1 MB GITHUB_OUTPUT limit by
  shedding optional enrichment (never the per-test counts) and fails loud rather
  than letting GitHub silently truncate into corrupt JSON.

Part 2 (passing-data + source mapping) is intentionally left in the agent loop
and will be addressed separately.

Co-authored-by: Copilot <[email protected]>
Copilot AI review requested due to automatic review settings June 11, 2026 21:10
@wtgodbe
wtgodbe requested a review from a team as a code owner June 11, 2026 21:10
@github-actions github-actions Bot added the needs-area-label Used by the dotnet-issue-labeler to label those issues which couldn't be triaged automatically label Jun 11, 2026

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

Moves the expensive Part 1 (Sources A/B/C) Azure DevOps + Helix failure gathering out of the agent loop and into a deterministic pre-activation step, injecting a compact JSON blob into the agent prompt to avoid effective-token exhaustion in the daily test-quarantine workflow.

Changes:

  • Adds a new pre-activation step (Aggregate Part 1 failures) that gathers Source A/B failures, enriches with result details/Helix coordinates, and extracts Source C [FAIL] blocks from Helix console logs within bounded size/budget.
  • Injects the aggregated part1_data into the agent prompt and updates Part 1 instructions to require using the injected data (no AzDO/Helix calls in-loop).
  • Regenerates the gh-aw compiled workflow lock file to wire the new output through prompt rendering.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
.github/workflows/test-quarantine.md Adds Part 1 pre-aggregation step + updates agent instructions to consume injected part1_data.
.github/workflows/test-quarantine.lock.yml Regenerated compiled workflow to plumb part1_data output into the agent prompt environment.

Comment thread .github/workflows/test-quarantine.md Outdated
Comment on lines +507 to +520
def helix_console_blocks(job_id, wi_name):
files, _ = fetch(f"{HELIX}/jobs/{job_id}/workitems/{urllib.parse.quote(wi_name)}/files")
seq = files if isinstance(files, list) else files.get("Files", files.get("files", []))
link = None
for f in seq:
nm = f.get("Name") or f.get("name") or ""
if nm.startswith("console."):
link = f.get("Link") or f.get("link")
break
if not link:
return None, 0
raw, _ = fetch(link, raw=True, timeout=180)
text = raw.decode("utf-8", "replace")
return extract_fail_blocks(text), len(text)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good catch — fixed in 2c156cd to return len(raw) (the actual downloaded byte count) instead of len(text), so both the download budget and the reported log_bytes are byte-accurate.

The console-log size returned by helix_console_blocks() feeds the
byte-denominated download budget and the reported log_bytes, but it used
len(text) (a decoded character count). Use len(raw) so the budget and
log_bytes are accurate.

Co-authored-by: Copilot <[email protected]>
@wtgodbe
wtgodbe merged commit cddc35c into dotnet:main Jun 11, 2026
10 checks passed
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-preview6 milestone Jun 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-area-label Used by the dotnet-issue-labeler to label those issues which couldn't be triaged automatically

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants