Fix the gh-aw recovery dispatch, `noop` limit, CI Review deadline and open-issue prefetches, and retire stale task incidents

Merged
DS
1mo ago
+929-422

This pull request was posted by Claude Code using claude-opus-5-5 on behalf of David.

Fixes the gh-aw infrastructure bugs behind this month's operational-alert issues. Addresses #12139, #11096, #11820 and the task incidents named in item 2 without closing them; #12139, #11096 and #11820 close by hand once a recovery run shows the model executed.

New public surface: none. Every change is under .github/.

Workflow behavior, before and after

  1. Recovery dispatch 404. GitHubClient.send built repos/<repo>/ for an empty path, so default_branch() failed every workflow_dispatch with recovery_issue in the gate (runs 41710465686, 41710470745, 41710476148).
  2. noop limit (E002). gh-aw allows one noop per run; a second call spent the single tool retry and the next ended the run. This is the crash behind the task incidents #12438, #12448, #12454, #12457 and #12477. _RecoverMCPToolErrors now answers a safe output past its limit with a result, and CI Review's model is no longer offered noop (its stale-PR skip step writes the only one); its prompt now says so.
  3. CI Review deadline. Inside the 5-minute reserve, CI Review is offered only submit_pull_request_review and create_pull_request_review_comment, and each Bash command stops when the reserve starts. A call to a withheld tool is answered, not charged as an unknown tool.
  4. Checkout of a moved PR. Skip a PR that closed or moved on while queued now runs before Check out the PR head, which skips a PR the step skipped.
  5. Duplicate [aw] Failed jobs issues. Every Z.AI source sets safe-outputs.report-failed-jobs: false, provider-health-reporting enforces it, and the 14 locks are recompiled with gh-aw v0.86.2. That step filed all 24 [aw] Failed jobs issues of 2026-11-04, 19 of them during a Z.AI 1302 rate-limit burst; the provider-health controller already tracks these failures. The compiler also drops actions: read, and issues: write where nothing else used it, from the conclusion jobs.
  6. Context prefetch cap. prefetch-github-context.sh dropped the open-issue list once it reached 1000; the repository has over 1,200 open issues. The cap is now 10,000, and a list that reaches it is still rejected.
  7. Stale Issues Finder corpus. prefetch-open-issues.sh listed issues with --search "sort:updated-asc", and GitHub search returns at most 1,000 results whatever --limit asks for, so the finder saw 1,000 of 1,237 open issues. It now lists without search, sorts by updatedAt locally, and fails the step when the list reaches its cap of 10,000.
  8. Summariser fallback (#11820). Both fallbacks of _compact_history keep the run's first request ahead of the tail, which otherwise starts with an assistant message that Z.AI rejects (HTTP 400, code 1214).
  9. Retired task incidents. The hourly provider-health run closes a task incident whose PR is merged or closed, or whose head moved off the SHA in its key, and comments the PR state it read. A failed read or write leaves that incident open without stopping provider recovery. The monitor job gains pull-requests: read.
  10. Shim telemetry. The summariser runs as history-summariser inside a compact history span whose gh_aw.compaction.outcome is done, failed, timed_out or discarded. The root agent-run span records gh_aw.total_usage.*, which includes delegates, resumes and the summariser. service.version is a digest of the shim's sources, which names the code that ran even when CI Review runs the shim from a PR head.

Verification

What changes for existing users: nothing; these workflows are repository infrastructure.

Carried over by #10347
  • SAFE_OUTPUT_TOOL_PREFIX: safe-output tools are matched only through _safe_output_type, so #10347's prefix tuple changes that one function.
  • _CIReviewToolPolicy must join build_agent()'s capabilities, with its Bash name changed to the Coder shell tool's name.
  • _RecoverMCPToolErrors.wrap_tool_execute carries over with the class.
  • compact_history(preserve_prompt=True) keeps messages[0] on every path; this PR's fallback change is then redundant there.
  • _RecordRunTotals, the compact history span and service_version move with build_agent() and configure_observability.
  • shared/prompts/pydantic-ai-pr-review.md tells CI Review that noop is unavailable. Keep _CIReviewToolPolicy withholding it, or drop that sentence.
Telemetry baseline (Logfire, 10-15 to 11-03)
  • CI Review on the current shim: 55 of 66 runs posted a review, 8 died on E002, 3 timed out.
  • Every E002 was a spent noop. 40 of the 45 runs that called noop first did so inside the final window.
  • 5 of the 6 runs whose Bash call crossed minute 23 posted no review.
  • The only summariser timeout in 32 runs produced the only 1214.
  • The summariser's span was a second invoke_agent agent, a timeout ended it UNSET, a discarded summary left no trace, and the root span's usage counted only the root's own requests.
PR decisions

2026-11-03 · C1/C2 scoped to CI Review, not every review run · iter -

  • Decision: Withholding noop, the reserve narrowing and the Bash cap apply to CI Review only; E002 recovery applies to every safe-output tool
  • Why: UI Security imports shared/security-findings.md, which ends a private report with noop, and needs report_security_finding in the reserve; the defects were reproduced on CI Review
  • Source: https://github.com/pydantic/pydantic-ai/issues/12250
  • Session: 01664f52-0b64-4f5f-a844-70b441a8bb03

2026-11-03 · Withhold CI Review tools from the request, not the toolset · iter -

  • Decision: _CIReviewToolPolicy drops withheld tools from model_request_parameters and answers calls to them, instead of a PrepareTools filter
  • Why: A PrepareTools filter makes the name unknown; tool_manager charges unknown names against the single tool retry, so a second call ends the run, and rigor.md/tool-hints.md still name noop
  • Source: https://github.com/pydantic/pydantic-ai/issues/12139
  • Session: 01664f52-0b64-4f5f-a844-70b441a8bb03

2026-11-03 · report-failed-jobs false in all 14 Z.AI sources · iter -

  • Decision: Set safe-outputs.report-failed-jobs: false in every Z.AI source, not only CI Review
  • Why: The guard rule provider-health-reporting covers every Z.AI source, and every Z.AI lock compiled the Report failed jobs step
  • Source: https://github.com/pydantic/pydantic-ai/issues/12249
  • Session: 01664f52-0b64-4f5f-a844-70b441a8bb03

2026-11-03 · Prefetch cap raised, truncation still rejected · iter -

  • Decision: corpus_limit 1000 -> 10000; a list that reaches the cap is still dropped with a warning
  • Why: A silently partial corpus defeats duplicate checks, and the prompts already handle a missing corpus; 1,223 open issues fetched in about 10 s
  • Source: https://github.com/pydantic/pydantic-ai/issues/12139
  • Session: 01664f52-0b64-4f5f-a844-70b441a8bb03

2026-11-04 · AGENTS.md wording signed off · iter -

  • Decision: David signed off the three AGENTS.md hunks as drafted: CI Review noop sentence, report-failed-jobs rule, hourly task-retire rule
  • Why: Instruction text needs David's sign-off before the PR opens (relayed in local-notes/dispatch-20261104T000549Z.md)
  • Source: https://github.com/pydantic/pydantic-ai/blob/main/.github/workflows/AGENTS.md
  • Session: 01664f52-0b64-4f5f-a844-70b441a8bb03

2026-11-04 · Compile locks with a scratchpad gh-aw v0.86.2 · iter -

  • Decision: Download gh-aw v0.86.2 darwin-arm64 into the session scratchpad, verify its digest against the release, recompile the 14 Z.AI locks with it; leave the global v0.88.2 alone; if the download is blocked again, stop and report the exact denial text, no other route
  • Why: David's choice; every lock is built with v0.86.2 and compiler-version-drift rejects mixed versions (relayed in local-notes/dispatch-20261104T000549Z.md)
  • Source: https://github.com/github/gh-aw/releases/tag/v0.86.2
  • Session: 01664f52-0b64-4f5f-a844-70b441a8bb03

2026-11-04 · Fold prefetch-open-issues.sh into this PR · iter -

2026-11-04 · Changed shapes for items 2, 3, 5, 6 accepted · iter -

  • Decision: Manager accepted: E002 answered at the toolset wrapper; CI Review-only request-level withholding and Bash cap; report-failed-jobs in all 14 Z.AI sources; prefetch cap 10000 with truncation still rejected
  • Why: Each rests on the code evidence in the stop-point report (relayed in local-notes/dispatch-20261104T000549Z.md)
  • Source: https://github.com/pydantic/pydantic-ai/issues/12139
  • Session: 01664f52-0b64-4f5f-a844-70b441a8bb03

2026-11-04 · Fold the Logfire telemetry gaps into this PR · iter -

  • Decision: Give the summariser a distinct span name and an outcome attribute, put delegate tokens on the root span, add a resource attribute recording the shim revision; keep to what the Logfire analyst found and state it in the PR body
  • Why: David's choice, so the post-deploy comparison sees the summariser and full run tokens (relayed in local-notes/dispatch-20261104T000549Z.md)
  • Source: https://github.com/pydantic/pydantic-ai/issues/11820
  • Session: 01664f52-0b64-4f5f-a844-70b441a8bb03

2026-11-04 · Stale Issues Finder prefetch drops --search · iter -

  • Decision: List open issues without --search and sort by updatedAt with jq; drop ISSUE_LIMIT: 1000 from the source so the script default of 10000 applies
  • Why: Live: gh issue list --search returns 1000 of 1237 open issues even at --limit 10000; GitHub search caps results at 1,000, so a raised cap alone would pass the length check while truncated
  • Source: https://github.com/pydantic/pydantic-ai/blob/main/.github/scripts/prefetch-open-issues.sh
  • Session: 168bbeda-751f-409c-9bf6-86afba878d7b

2026-11-04 · Capped open-issue list fails the step · iter -

2026-11-04 · agentics-maintenance.yml left out of the recompile · iter -

  • Decision: Restored agentics-maintenance.yml after gh aw compile; only the 14 locks are committed
  • Why: The compiler drops the description comment #11093 added by hand to every hand-written workflow
  • Source: https://github.com/pydantic/pydantic-ai/pull/11093
  • Session: 168bbeda-751f-409c-9bf6-86afba878d7b

2026-11-04 · pre-push review 1 of 3 at 309cd99e9fbecc2b179932a43e7c6c76594a0688 · iter -

2026-11-04 · pre-push review 1 of 3 at 309cd99e9fbecc2b179932a43e7c6c76594a0688 · iter -

  • Decision: 7 findings. Fixed in f70557bde: #1 a failed retirement comment or close escaped and skipped hourly provider recovery; #7 E002 marker scoped to its class. Dismissed: #2 (E002 arrives as a bare McpError chained as the ModelRetry cause), #4 (recovery and retirement rules cover disjoint cases; the edit would drop manual close of a recovered task incident), #6 (the reply names the safe-output type like the existing reminder, so the prefix rename leaves it). Pending sign-off: #3 rigor.md/tool-hints.md still advise noop to CI Review; #5 guard table row omits report-failed-jobs
  • Why: reviewed tree 0d8d2f47aaa2614e07c2e2b6e9a95551029cab32; E002 evidence local-notes/triage/cluster-workflow-failures.md (JSON-RPC -32602) and mcp.py _call_tool_checked cause=e
  • Source: https://github.com/pydantic/pydantic-ai/tree/fix/gh-aw-incident-causes
  • Session: 168bbeda-751f-409c-9bf6-86afba878d7b

2026-11-04 · Guard table row names failed-job reporting · iter -

  • Decision: provider-health-* row reads "generic failure-as-issue or failed-job reporting left enabled"
  • Why: David signed off the wording as drafted; the guard now also rejects report-failed-jobs (pre-push review 1 finding 5) (relayed in local-notes/dispatch-20261104T233739Z.md)
  • Source: https://github.com/pydantic/pydantic-ai/blob/main/.github/workflows/AGENTS.md
  • Session: 168bbeda-751f-409c-9bf6-86afba878d7b

2026-11-04 · CI Review prompt says noop is unavailable · iter -

  • Decision: Add to shared/prompts/pydantic-ai-pr-review.md exactly: "noop is not available in this workflow; when in doubt, submit a COMMENT review." (option B); rigor.md and tool-hints.md unchanged
  • Why: David chose B; the committed prompt is live: run 41935101823 logged LOGFIRE_READ_EXTERNAL_VARIABLES not set, using the committed default (relayed in local-notes/dispatch-20261104T233739Z.md)
  • Source: https://github.com/pydantic/pydantic-ai/actions/runs/41935101823
  • Session: 168bbeda-751f-409c-9bf6-86afba878d7b

2026-11-04 · pre-push review 2 of 3 at 61ae00d244f1a5e0e5158d3860a6e6077d915ee7 · iter -

2026-11-04 · pre-push review 2 of 3 at 61ae00d244f1a5e0e5158d3860a6e6077d915ee7 · iter -

2026-11-04 · pre-push review 3 of 3 at 222719334ec5bfcf116d4ef6970d0db66f02d7cb · iter -

2026-11-05 · pre-push review 3 of 3 moved to f9cc66ac8c020c0544a4e26a3f4b604ec5f75504 · iter -

  • Decision: the reservation at 222719334 was not dispatched; review 3 runs on the merge of main instead
  • Why: main touched .github/workflows/AGENTS.md and the UI Security source and lock; the lock conflicted and was recompiled with gh-aw v0.86.2, so the merge is not an exempt delta
  • Source: https://github.com/pydantic/pydantic-ai/tree/fix/gh-aw-incident-causes
  • Session: 168bbeda-751f-409c-9bf6-86afba878d7b

2026-11-05 · pre-push review 3 of 3 at f9cc66ac8c020c0544a4e26a3f4b604ec5f75504 · iter -

2026-11-05 · Manual-close rule scoped to task incidents the hourly run does not retire · iter -

  • Decision: AGENTS.md: "For workflow incidents, and task incidents the hourly run does not retire, inspect ..." and "The run comments the pull request state it read once, then closes the incident."; the manual-dispatch sentence stays (option A)
  • Why: David chose A; pre-push reviews 1 and 3 both read the unscoped manual-close sentence as contradicting the retirement paragraph (relayed in local-notes/dispatch-20261105T003455Z.md)
  • Source: https://github.com/pydantic/pydantic-ai/pull/12570
  • Session: 168bbeda-751f-409c-9bf6-86afba878d7b

Checklist

  • No breaking changes in accordance with the version policy.
  • Any permitted compatibility impact has a label, warning, migration and release note, and an exact API-check waiver if the gate reports it.
  • PR title is fit for the release changelog.