π The fast, Pythonic way to build MCP servers and clients.
Fix and quiet the triage alerts from 2026-11-02 (#6235)
nate nowack32b39b1b5be9
diff --git a/.github/agentic/flows/agentic_backlog.py b/.github/agentic/flows/agentic_backlog.pyindex f4f228ba5..d198f7dc2 100644--- a/.github/agentic/flows/agentic_backlog.py+++ b/.github/agentic/flows/agentic_backlog.py@@ -35,8 +35,9 @@ class Intake(BaseModel):return "fastmcp-intake-" + digest(identity)[:24]+# `&` excludes HTML character references such as Renovate's `​`.REFERENCE = re.compile(- r"(?:(?<![\w/])#|github\.com/PrefectHQ/fastmcp/issues/)([1-9][0-9]*)\b"+ r"(?:(?<![\w/&])#|github\.com/PrefectHQ/fastmcp/issues/)([1-9][0-9]*)\b")diff --git a/.github/agentic/flows/agentic_review_delivery.py b/.github/agentic/flows/agentic_review_delivery.pyindex 669060e5a..de07e1d81 100644--- a/.github/agentic/flows/agentic_review_delivery.py+++ b/.github/agentic/flows/agentic_review_delivery.py@@ -8,7 +8,12 @@ from prefect import taskfrom flows.agentic_claims import claim_workfrom flows.agentic_intake import heldfrom flows.agentic_review_app import review_client-from flows.agentic_review_publication import before_delivery, post_review, review_body+from flows.agentic_review_publication import (+ EvidenceChanged,+ before_delivery,+ post_review,+ review_body,+)from flows.agentic_stack import digestfrom flows.agentic_stack_policy import Batch, Group, review_revisionfrom flows.agentic_stack_runtime import (@@ -43,11 +48,14 @@ def deliver_reviews(raise ValueError("Review publication is not configured")number = outcome["issue_number"]independent = saved(owner, f"{batch.id}-issue-{number}-triage-review")- if (- independent is None- or independent["run_id"] != outcome["triage_review_run_id"]- or independent["result"] != outcome["adversarial_review"]- ):+ if independent is None:+ raise ValueError("Independent review record is not readable yet")+ if independent["run_id"] != outcome["triage_review_run_id"]:+ raise ValueError(+ f"Review came from run {outcome['triage_review_run_id']}, "+ f"but the retained independent review is run {independent['run_id']}"+ )+ if independent["result"] != outcome["adversarial_review"]:raise ValueError("Review differs from retained independent evidence")verified = outcome.get("verification", [])if len({v["pr_number"] for v in verified}) != len(verified):@@ -86,7 +94,7 @@ def deliver_reviews(or check["head_sha"] != pr["head_sha"]or check["baseline_sha"] != evidence["base_sha"]):- raise ValueError(+ raise EvidenceChanged("Contribution verification is unavailable or stale")revision = digest([check["head_sha"], check["baseline_sha"], app.slug])[@@ -116,7 +124,7 @@ def deliver_reviews() != review_revision(before_delivery(evidence, receipts, app.slug + "[bot]")):- raise ValueError(+ raise EvidenceChanged("Issue or contribution changed after review")@@ -144,6 +152,8 @@ def deliver_reviews(httpx.HTTPError,OSError,) as error:+ if isinstance(error, EvidenceChanged):+ raise EvidenceChanged(str(error), receipts) from errorif not receipts:raise# Keep reviews that are already public visible to the queue.diff --git a/.github/agentic/flows/agentic_review_publication.py b/.github/agentic/flows/agentic_review_publication.pyindex 612beca6f..63643b28c 100644--- a/.github/agentic/flows/agentic_review_publication.py+++ b/.github/agentic/flows/agentic_review_publication.py@@ -11,6 +11,14 @@ from flows.agentic_intake import HOLDfrom flows.agentic_stack_plans import PublicReview+class EvidenceChanged(ValueError):+ """The issue or PR moved after review; the new revision is triaged on its own."""++ def __init__(self, reason: str, posted: list[dict] | None = None):+ super().__init__(reason)+ self.posted = posted or []++def before_delivery(evidence: dict, receipts: list[dict], reviewer: str) -> dict:result = deepcopy(evidence)for receipt in receipts:@@ -104,7 +112,7 @@ def post_review(def current() -> dict:pr = github.request(prefix)if not isinstance(pr, dict) or pr.get("head", {}).get("sha") != head:- raise ValueError("PR head changed after review")+ raise EvidenceChanged("PR head changed after review")text = "\n".join([pr["title"], pr.get("body") or "", *[x["name"] for x in pr["labels"]]])@@ -114,7 +122,7 @@ def post_review(or (pr["draft"] and not allow_draft)or HOLD.search(text)):- raise ValueError("PR is closed, draft or explicitly held")+ raise EvidenceChanged("PR is closed, draft or explicitly held")if pr["user"]["login"] == reviewer:raise ValueError("Reviewer must differ from PR author")return prdiff --git a/.github/agentic/flows/agentic_stack_context.py b/.github/agentic/flows/agentic_stack_context.pyindex 7c1e4c132..ab58ca59e 100644--- a/.github/agentic/flows/agentic_stack_context.py+++ b/.github/agentic/flows/agentic_stack_context.py@@ -148,6 +148,33 @@ def revisions(pr: dict, read: Read) -> dict:}+MAX_CONTRIBUTIONS = 6+++def contributions(prs: list[dict], evidence: dict) -> list[dict]:+ """Keep every linked PR, then fill the bound with the newest title-search matches.++ Generic issue titles match dozens of unrelated PRs by keyword; those matches+ should not stop triage of an issue that has few or no linked PRs.+ """+ linked = [pr for pr in prs if pr.get("discussion_collected") is not False]+ if len(linked) > MAX_CONTRIBUTIONS:+ raise ValueError(+ f"{len(linked)} PRs link this issue; review handles at most {MAX_CONTRIBUTIONS}"+ )+ matches = sorted(+ (pr for pr in prs if pr.get("discussion_collected") is False),+ key=lambda pr: pr.get("updated_at") or "",+ reverse=True,+ )+ room = MAX_CONTRIBUTIONS - len(linked)+ if matches[room:]:+ evidence["omitted_search_matches"] = sorted(+ pr["number"] for pr in matches[room:]+ )+ return sorted(linked + matches[:room], key=lambda pr: pr["number"])++def assessment_context(item: dict, read: Read) -> dict:raw = item["evidence"]if raw.get("complete") is not True:@@ -157,9 +184,7 @@ def assessment_context(item: dict, read: Read) -> dict:evidence["comments"] = discussion(raw.get("comments", []))evidence["timeline"] = events(raw.get("timeline", []))evidence["prs"] = []- if len(raw.get("prs", [])) > 6:- raise ValueError("More than six contributions need a narrower review batch")- for pr in raw.get("prs", []):+ for pr in contributions(raw.get("prs", []), evidence):result = fields(pr,"number title body state draft merged html_url labels base_ref base_sha head_sha head_repository canonical_references",diff --git a/.github/agentic/flows/agentic_stack_controller.py b/.github/agentic/flows/agentic_stack_controller.pyindex 9d60401b2..34bfbebe5 100644--- a/.github/agentic/flows/agentic_stack_controller.py+++ b/.github/agentic/flows/agentic_stack_controller.py@@ -18,6 +18,7 @@ from flows.agentic_intake import policy_outcome, route_intakefrom flows.agentic_native_triage import run_native_triagefrom flows.agentic_reproduction_evidence import validate_reproduction_patchfrom flows.agentic_review_delivery import deliver_reviews+from flows.agentic_review_publication import EvidenceChangedfrom flows.agentic_stack import digestfrom flows.agentic_stack_policy import Batchfrom flows.agentic_stack_runtime import (@@ -225,6 +226,14 @@ def run_batch(batch: Batch, runtime: Runtime) -> dict:result,final_evidence,)+ except EvidenceChanged as error:+ # Freshness revalidation requeues the item, and the+ # GitHub event for the change starts its own triage.+ delivery = {+ "status": "superseded",+ "reason": str(error)[:1000],+ "posted": getattr(error, "posted", []),+ }except (ValueError,RuntimeError,diff --git a/.github/agentic/flows/agentic_triage.py b/.github/agentic/flows/agentic_triage.pyindex bffb8e3c9..4c261f24a 100644--- a/.github/agentic/flows/agentic_triage.py+++ b/.github/agentic/flows/agentic_triage.py@@ -422,12 +422,29 @@ def triage_intake(breaktime.sleep(5)result = finish(plan, current.id, config.scope(), run_id)- if result["review"] and result["review"]["bins"]["operational"]:- reasons = [- f"#{item.get('issue_number', '?')}: {item.get('reason') or item.get('status', 'needs operational attention')}"- for item in result["review"]["bins"]["operational"]- ]+ reasons = attention(result["review"]) if result["review"] else []+ if reasons:return Completed(name="Degraded", data=result, message="; ".join(reasons)[:2000])return result+++# Evidence that moved during the run is requeued by `settle`, and the GitHub+# event for the change starts a fresh triage, so it is not worth an alert.+REQUEUED = frozenset({"stale", "baseline_changed"})+++def attention(review: dict) -> list[str]:+ reasons = []+ for item in review["bins"]["operational"]:+ if item.get("status") in REQUEUED:+ continue+ detail = str(item.get("detail") or "")[:300]+ reason = item.get("reason") or detail or item.get("status")+ if item.get("reason") and detail:+ reason = f"{item['reason']}: {detail}"+ reasons.append(+ f"#{item.get('issue_number', '?')}: {reason or 'stopped without a recorded reason'}"+ )+ return reasonsdiff --git a/.github/agentic/tests/test_agentic_backlog.py b/.github/agentic/tests/test_agentic_backlog.pyindex 0a1309e31..6b142da29 100644--- a/.github/agentic/tests/test_agentic_backlog.py+++ b/.github/agentic/tests/test_agentic_backlog.py@@ -17,7 +17,15 @@ from flows.agentic_backlog import Intake, due, inventory, settlefrom flows.agentic_freshness import revalidatefrom flows.agentic_intake import evidence_revision, policy_outcome, route_intakefrom flows.agentic_stack_runtime import AgentPlan, Runtime, gh_api, record-from flows.agentic_triage import admit, checkpoint, dispatch, finish, latest, retain+from flows.agentic_triage import (+ admit,+ attention,+ checkpoint,+ dispatch,+ finish,+ latest,+ retain,+)def issue(number, **extra):@@ -87,7 +95,7 @@ def test_event_intake_resolves_pull_requests_to_referenced_open_issues(github_seread, responses, requests = github_serverresponses["/repos/PrefectHQ/fastmcp/pulls/7"] = {"number": 7,- "body": "Fixes #5 and https://github.com/PrefectHQ/fastmcp/issues/6; not other/repo#8",+ "body": "Fixes #5 and https://github.com/PrefectHQ/fastmcp/issues/6; not other/repo#8 or ([#​8203](https://redirect.github.com/astral-sh/ruff/pull/8203))",}responses["/repos/PrefectHQ/fastmcp/issues/5"] = issue(5)responses["/repos/PrefectHQ/fastmcp/issues/6"] = issue(6, state="closed")@@ -97,6 +105,7 @@ def test_event_intake_resolves_pull_requests_to_referenced_open_issues(github_seassert [row["issue_number"] for row in result["pending"]] == [5, 9]assert result["coverage"]["pull_requests"] == 1assert "/repos/PrefectHQ/fastmcp/issues/8" not in requests+ assert "/repos/PrefectHQ/fastmcp/issues/8203" not in requestsassert config.scope() != Intake(issues=[1], queue="events").scope()assert Intake(issues=[9]).scope() != config.scope()@@ -496,3 +505,29 @@ def test_different_manual_pr_request_does_not_resume_previous_pr(github_server):Intake(queue="events", branch="main").scope()!= Intake(queue="events", branch="release/3.x").scope())+++def test_only_unrequeued_operational_work_raises_an_alert():+ review = {+ "bins": {+ "operational": [+ {"issue_number": 1, "status": "stale", "reason": "Evidence changed"},+ {"issue_number": 2, "status": "baseline_changed", "reason": "moved"},+ {+ "issue_number": 3,+ "error": "ValueError",+ "detail": "7 PRs link this issue; review handles at most 6",+ },+ {+ "issue_number": 4,+ "reason": "Review delivery failed",+ "detail": "Independent review record is not readable yet",+ },+ ]+ }+ }+ assert attention(review) == [+ "#3: 7 PRs link this issue; review handles at most 6",+ "#4: Review delivery failed: Independent review record is not readable yet",+ ]+ assert attention({"bins": {"operational": review["bins"]["operational"][:2]}}) == []diff --git a/.github/agentic/tests/test_agentic_events.py b/.github/agentic/tests/test_agentic_events.pyindex 14999e2dc..34eafb281 100644--- a/.github/agentic/tests/test_agentic_events.py+++ b/.github/agentic/tests/test_agentic_events.py@@ -211,9 +211,15 @@ def test_failure_alert_shows_the_cause_and_one_run_link(automations):},},)- assert "triage degraded" in message+ assert "triage skipped some issues" in messageassert "#4866: contribution verification did not complete" in message+ assert "retry on later runs" in messageassert message.count("https://app.prefect.cloud/runs/run") == 1+ failed = render_user_template_sync(+ configs["fastmcp-triage-failure-alert"]["actions"][0]["body"],+ {"flow_run": {"id": "run", "state": {"name": "Failed", "message": "boom"}}},+ )+ assert failed.startswith("β triage failed before finishing\nboom\n")def test_notification_announces_admitted_issues_only(automations):diff --git a/.github/agentic/tests/test_agentic_review_publication.py b/.github/agentic/tests/test_agentic_review_publication.pyindex 20830384b..a0223519e 100644--- a/.github/agentic/tests/test_agentic_review_publication.py+++ b/.github/agentic/tests/test_agentic_review_publication.py@@ -21,6 +21,7 @@ from flows import agentic_review_delivery as deliveryfrom flows.agentic_github import GitHubfrom flows.agentic_review_app import ReviewApp, review_clientfrom flows.agentic_review_publication import (+ EvidenceChanged,before_delivery,format_review,post_review,@@ -559,7 +560,16 @@ def test_existing_review_with_crlf_feedback_is_adopted(endpoint):assert receipt["status"] == "already_posted"-def test_partial_delivery_failure_keeps_already_posted_receipts(monkeypatch):+ ("raised", "expected"),+ [+ (ValueError, delivery.PartialReviewDelivery),+ (EvidenceChanged, EvidenceChanged),+ ],+)+def test_partial_delivery_failure_keeps_already_posted_receipts(+ monkeypatch, raised, expected+):@flowdef controller():return None@@ -568,7 +578,7 @@ def test_partial_delivery_failure_keeps_already_posted_receipts(monkeypatch):def post(github, number, head, baseline, reviewer, body, guard):if posted:- raise ValueError("Issue or contribution changed after review")+ raise raised("Issue or contribution changed after review")posted.append({"pr_number": number, "head_sha": head, "status": "posted"})return posted[-1]@@ -628,7 +638,7 @@ def test_partial_delivery_failure_keeps_already_posted_receipts(monkeypatch):"partial-issue-1-triage-review",{"run_id": "review-run", "result": review},)- with pytest.raises((ValueError, RuntimeError)) as failure:+ with pytest.raises(expected) as failure:delivery.deliver_reviews.fn(owner,batch,diff --git a/.github/agentic/tests/test_agentic_stack_context.py b/.github/agentic/tests/test_agentic_stack_context.pyindex 41f2ae201..91440ea7c 100644--- a/.github/agentic/tests/test_agentic_stack_context.py+++ b/.github/agentic/tests/test_agentic_stack_context.py@@ -8,7 +8,12 @@ from urllib.request import urlopenimport pytest-from flows.agentic_stack_context import assessment_context, checks, comparison+from flows.agentic_stack_context import (+ assessment_context,+ checks,+ comparison,+ contributions,+)BASE, REVIEW, HEAD = (letter * 40 for letter in "abc")@@ -175,3 +180,18 @@ def test_comparison_metadata_cannot_overrun_the_model_context(source):assert result["total_commits"] == 100assert result["returned_file_count"] == 1assert not result["tests_executed"]+++def test_title_search_matches_do_not_block_an_issue_with_few_linked_prs():+ def pr(number, linked, updated):+ row = {"number": number, "updated_at": f"2026-11-0{updated}T00:00:00Z"}+ return row if linked else {**row, "discussion_collected": False}++ prs = [pr(3, True, 1)] + [pr(n, False, n - 10) for n in range(11, 18)]+ evidence = {}+ kept = contributions(prs, evidence)+ assert [row["number"] for row in kept] == [3, 13, 14, 15, 16, 17]+ assert evidence["omitted_search_matches"] == [11, 12]++ with pytest.raises(ValueError, match="7 PRs link this issue"):+ contributions([pr(n, True, 1) for n in range(7)], {})diff --git a/.github/agentic/workflows/events/failure-notification.txt.j2 b/.github/agentic/workflows/events/failure-notification.txt.j2index 1a0d036d2..7213fde36 100644--- a/.github/agentic/workflows/events/failure-notification.txt.j2+++ b/.github/agentic/workflows/events/failure-notification.txt.j2@@ -1,3 +1,6 @@-{% set state = flow_run.state.name %}{{ {'Failed': 'β', 'Crashed': 'π₯', 'TimedOut': 'β±οΈ', 'Degraded': 'β οΈ'}.get(state, 'β οΈ') }} triage {{ {'TimedOut': 'timed out'}.get(state, state|lower) }}+{% set state = flow_run.state.name %}{% if state == 'Degraded' %}β οΈ triage skipped some issues+{{ flow_run.state.message or 'See the retained artifacts for which issues and why.' }}+Skipped issues retry on later runs, up to 3 tries. Look only if the same issue repeats.+{% else %}{{ {'Failed': 'β', 'Crashed': 'π₯', 'TimedOut': 'β±οΈ'}.get(state, 'β') }} triage {{ {'TimedOut': 'timed out', 'Crashed': 'crashed'}.get(state, 'failed') }} before finishing{{ flow_run.state.message or 'See the retained artifacts for the failure details.' }}-<{{ flow_run|ui_url }}|run and artifacts>+{% endif %}<{{ flow_run|ui_url }}|run and artifacts>