Recheck Z.ai provider health when a queued agent job starts, so incidents opened during the wait stop inference
This pull request was posted by Claude Code using claude-opus-5-5 on behalf of David.
Why we make these changes
Every Z.ai workflow decides provider health in provider_health when it starts, but its agent job then queues for the engine concurrency slot: over the last 14 days that decision was a median 5.1 h old when a CI Review agent started. During provider incident #10572, 16 queued CI Review runs still reached the model and failed on 1310, and 31 sent their detection pass to the blocked provider. Run 38967083667 passed its gate at 21:07Z and started its agent at 03:13Z, six minutes after #10572 opened.
Every Z.ai agent job now reruns the default-branch agent_provider_health.py check as its first pre-agent step, replaces the provider-health artifact, and fails before the engine step unless ready. A noop would not stop inference: detection runs on any agent output.
New public surface
none
User-visible behavior
| A queued run whose provider is blocked by the time its agent starts | Before | After |
|---|---|---|
Model and detection | run against the blocked provider | not started |
| Run conclusion | failure | failure, before the engine step |
| Incident | from the shim result, if any | reuses the blocking incident, or opens one quota_exhausted incident |
Healthy runs add one quota call and a few GitHub API reads at agent start; the first model request follows the decision by about a minute.
Verification
- The shipped CI Review agent-job shape fails the new guard; the repaired shape passes:
test_provider_health_agent_start_catches_the_queued_ci_review_defect - Rechecks that cannot stop inference fail it:
test_provider_health_agent_start_rejects_a_recheck_that_cannot_stop_inference - A ready gate followed by an incident or exhausted quota blocks at agent start, and the monitor reconciles the replaced decision:
test_agent_start_recheck_blocks_a_stale_ready_gate_and_replaces_its_decision - Failures of the new steps stay unclassified:
test_attempt_stage_uses_real_setup_and_no_step_job_shapes - A pre-engine agent failure skips detection's model call: run 39817057326. A real blocked recheck has not run yet; the first incident after merge will show it.
- All 13 locks compiled with gh-aw v0.86.2, the version on
main.
What changes for existing users
Nothing; this is repository CI tooling.
PR decisions
2026-10-22 · pre-push review 1 of 3 at d4527790321ef331cada896fb750ca5676468d11 · iter -
- Decision: dispatched
- Why: tree f1a66698a369f2fe90c8efb7125730de604a4be8; scope 767f526777..d452779032 full branch; first review
- Source: https://github.com/pydantic/pydantic-ai/tree/provider-health-agent-start-gate
2026-10-22 · agent-start block fails the job, not a noop · iter -
- Decision: A blocked agent-start recheck exits 1 before the engine step instead of writing a noop to safe outputs
- Why: detection runs on any agent output_types (noop included) and would send one Z.ai request to the blocked provider; a pre-Execute failure leaves output_types empty so detection skips
- Source: https://github.com/pydantic/pydantic-ai/blob/767f5267778e24a6f227dbf4f91017aedc43e220/.github/workflows/pydantic-ai-pr-review.lock.yml#L1449-L1462
2026-10-22 · pre-push review 1 of 3 at d4527790321ef331cada896fb750ca5676468d11 · iter -
- Decision: remediated: agent-start step failures unclassified by monitor; guard binds fetched path to executed path; header comment and AGENTS.md artifact wording fixed
- Why: tree f1a66698a369f2fe90c8efb7125730de604a4be8; scope 767f526777..d452779032 full branch; 4 findings, all accepted
- Source: https://github.com/pydantic/pydantic-ai/tree/provider-health-agent-start-gate
2026-10-22 · pre-push review 2 of 3 at f751ca17f9d9b5d3d5a29d9e8d2c97694f50f4b6 · iter -
- Decision: dispatched
- Why: tree 5fcf956f355a62d2b673d2b66c7e07284c021dc7; scope d452779032..f751ca17f9 delta plus callers; verifies 4 call-1 findings
- Source: https://github.com/pydantic/pydantic-ai/tree/provider-health-agent-start-gate
2026-10-22 · pre-push review 2 of 3 at f751ca17f9d9b5d3d5a29d9e8d2c97694f50f4b6 · iter -
- Decision: no findings
- Why: tree 5fcf956f355a62d2b673d2b66c7e07284c021dc7; scope d452779032..f751ca17f9 delta plus callers; all 4 call-1 findings verified fixed
- Source: https://github.com/pydantic/pydantic-ai/tree/provider-health-agent-start-gate
2026-10-22 · agent-start block fails the job, not a noop · iter -
- Decision: A blocked agent-start recheck exits 1 before the engine step instead of writing a noop to safe outputs
- Why: detection runs on any agent output_types, noop included; during incident #10572 the detection jobs of 31 stale-head noop runs each retried against the blocked provider (65-66 rejected 1310 requests in each of 3 sampled logs). Run 39817057326 failed in a pre-agent step and its detection skipped Execute
- Source: https://github.com/pydantic/pydantic-ai/actions/runs/39817057326
- Supersedes: agent-start block fails the job, not a noop
2026-10-22 · pre-push review 3 of 3 at b46504e6879fd26d7bf99a45fb7958b4df30331f · iter -
- Decision: dispatched
- Why: tree 753d64111ac8544267ab7ebfc164b3662c86c1d9; scope f751ca17f9..b46504e687 one AGENTS.md sentence
- Source: https://github.com/pydantic/pydantic-ai/tree/provider-health-agent-start-gate
2026-10-22 · pre-push review 3 of 3 at b46504e6879fd26d7bf99a45fb7958b4df30331f · iter -
- Decision: no findings
- Why: tree 753d64111ac8544267ab7ebfc164b3662c86c1d9; scope f751ca17f9..b46504e687 one AGENTS.md sentence; review budget exhausted
- Source: https://github.com/pydantic/pydantic-ai/tree/provider-health-agent-start-gate
2026-10-22 · douwebot finding: single source for agent-start step names · iter -
- Decision: AGENT_START_HEALTH_STEPS constant in agent_provider_health.py; guard requires the compiled steps carry those names
- Why: the monitor matches the steps by name; a rename in shared/provider-health.md passed the guard and would reclassify a block as a setup failure. Review budget exhausted (3 of 3); pushed on local checks
- Source: https://github.com/pydantic/pydantic-ai/pull/11048#discussion_r4352312257
Checklist
- No breaking changes in accordance with the version policy.
- Any permitted compatibility impact has a label, warning, migration, release note, and exact API-check waiver.
- PR title is fit for the release changelog.