Open Z.ai provider-health incidents only for provider-wide evidence, not fork-PR gates or transient `1302` rate limits
Merged
DS
1mo ago+126+126+012345678901234567890123456789-34-34-01234567890123456789
This pull request was posted by Claude Code using claude-opus-5-5 on behalf of David.
Why we make these changes
Since quota diagnostics landed (#10125), every CI Review provider incident has had one of three causes. None of them was a provider outage. Each incident still blocked every Z.ai workflow for 1–2 h.
| Cause | Incidents | Status |
|---|---|---|
Gate ran without ZAI_API_KEY: GitHub withholds secrets from pull_request_review on fork PRs | #10986, #10995, #10999, #11003, #11019, #11024, #11025, #11033 | fixed here |
Z.ai 1302 request-rate 429 that outlasted the runner's 60 s retry | #10921, #11008, #11027, #11032 (and #10310 in UI Security Review) | fixed here |
CREDIT_LIMIT quota rows | #10582, #10583, #10637 | fixed by #10678 |
#9756 and #10213 handled the missing key one event shape at a time. This PR handles it for the whole pull request event family:
- The monitor opens no incident when a
pull_request,pull_request_revieworpull_request_review_commentgate ran without the key. Gates on other events and the scheduled check still open one, so a broken key binding still surfaces. - The runner reports a 429 whose Z.ai code is a documented account or plan limit (1113, 1308–1311, 1313–1321) as a new
plan_limitkind.plan_limitopens the provider incident thatrate_limitused to open. Any other 429 staysrate_limitand is now local to its run, like a timeout or a 529. The same code set decides what the retry transport gives up on. - Runners on older PR branches report every 429 as
rate_limit. An exhausted plan still blocks the next run at its quota check.
In the last 14 days of runner telemetry, most 1302 hits recovered inside the retry window. Runs also succeeded during the same throttling windows.
New public surface
none
User-visible behavior
| Run outcome | Before | After |
|---|---|---|
| Fork PR review, gate has no key | provider incident | run blocked, no incident |
1302/1305 429 outlasts retry | provider incident (rate_limit) | run fails, no incident |
1310, 1316, … 429 | provider incident (rate_limit) | provider incident (plan_limit) |
Verification
- Fork-PR events open no incident, the scheduled check still does:
test_missing_credentials_on_secretless_pull_request_events_leave_the_alert_to_the_scheduled_check - A missing key on other events still opens one:
test_current_configuration_with_missing_credentials_still_creates_an_incident rate_limitstays local,plan_limitopens a provider incident:test_monitor_selects_current_attempt_before_resolving_agent_artifacts- A real runner 1316 result opens one
plan_limitincident:test_real_shim_result_is_idempotently_monitored_and_blocks_other_workflows - Runner classification by Z.ai code:
test_failure_metadata_classifies_typed_errors - Plan-limit codes are not retried:
test_rate_limit_retry_transport_does_not_retry_plan_quota_exhaustion
What changes for existing users
Nothing; this is repository CI tooling.
PR decisions
2026-10-22 · missing key: skip by diagnostic, not event shape · iter -
- Decision: Monitor opens no incident when the gate ran without ZAI_API_KEY; the scheduled check owns that alert
- Why: Third secretless event shape (fork pull_request_review) after #9756 and #10213 patched one shape each; the gate job reads the same repo secret as the scheduled check
- Source: https://github.com/pydantic/pydantic-ai/issues/11025
2026-10-22 · 429 split: rate_limit transient, plan_limit provider · iter -
- Decision: Shim reports Z.ai 1302/1305/no-code 429 as rate_limit (local to run) and other Z.ai codes as plan_limit (provider incident)
- Why: Z.ai documents 1302/1305 as transient; the shim runs from the PR head, so rate_limit must become transient for old branches; an exhausted plan still blocks at the next quota check
- Source: https://docs.z.ai/api-reference/api-code
2026-10-22 · drop the concurrency rationale for the 1h hold · iter -
- Decision: Keep the 1h cool-down for remaining provider kinds; rate_limit no longer opens incidents
- Why: #10356's fast-recurrence evidence was fork-PR missing-key (#9751, #9753) and pre-diagnostic quota_unknown incidents, none a 429
- Source: https://github.com/pydantic/pydantic-ai/pull/10356
2026-10-22 · pre-push review 1 of 3 at f8a9479878c468b7bfa11987035c4babcfe214de · iter -
- Decision: dispatched
- Why: tree 9540996f85bee26e3af39c42e1d8e90bacd1287a; scope f34a32dbbb..f8a947987 full branch; first review
- Source: https://github.com/pydantic/pydantic-ai/tree/ci-review-provider-incidents
2026-10-22 · pre-push review 1 of 3 at f8a9479878c468b7bfa11987035c4babcfe214de · iter -
- Decision: remediated: missing-key skip limited to pull_request* events; one documented plan-limit code set drives retry and classification; AGENTS.md MiniMax line
- Why: 3 findings, all valid; reviewed tree 9540996f85bee26e3af39c42e1d8e90bacd1287a; the Logfire analyst independently asked for the single code list
- Source: https://github.com/pydantic/pydantic-ai/tree/ci-review-provider-incidents
2026-10-22 · missing key: event-scoped after review · iter -
- Decision: Skip run-level missing_api_key incidents only for pull_request, pull_request_review, pull_request_review_comment
- Why: agentic_workflow_guard.py does not pin the gate's ZAI_API_KEY binding, so a global skip would hide a broken binding; non-PR gates and the scheduled check still alert
- Source: https://github.com/pydantic/pydantic-ai/issues/11025
- Supersedes: missing key: skip by diagnostic, not event shape
2026-10-22 · 429 split: documented plan-limit codes only · iter -
- Decision: plan_limit only for documented Z.ai account/plan codes (1308-1311, 1313-1321); unknown and code-less 429s are rate_limit; the transport stops retrying 1311 and 1313-1315
- Why: an unknown code carries no evidence of a plan limit; an exhausted plan still blocks at the next quota check; one list cannot drift
- Source: https://docs.z.ai/api-reference/api-code
- Supersedes: 429 split: rate_limit transient, plan_limit provider
2026-10-22 · pre-push review 2 of 3 at a97f46755d1224c01b2ae0bfe2a4ed6208f9289e · iter -
- Decision: dispatched
- Why: tree efaeef869e887ea5c4e6a89896d136cd17d84230; follow-up scope f8a947987..a97f46755 plus callers; verifies review-1 findings
- Source: https://github.com/pydantic/pydantic-ai/tree/ci-review-provider-incidents
2026-10-22 · pre-push review 2 of 3 at a97f46755d1224c01b2ae0bfe2a4ed6208f9289e · iter -
- Decision: remediated: add documented 429 code 1113 (insufficient balance) to plan-limit codes; fix AGENTS.md cross-reference wording
- Why: prior 3 findings verified fixed; 2 new findings, both valid (1113 confirmed on docs.z.ai api-code page); reviewed tree efaeef869e887ea5c4e6a89896d136cd17d84230
- Source: https://docs.z.ai/api-reference/api-code
2026-10-22 · pre-push review 3 of 3 at 121c6cd1db04a5087f226d9e4cb103db763cb78e · iter -
- Decision: dispatched
- Why: tree 6b115769e7ebec196fb5e8308747cae598324361; follow-up scope a97f46755..121c6cd1d plus callers; verifies review-2 findings; last review in budget
- Source: https://github.com/pydantic/pydantic-ai/tree/ci-review-provider-incidents
2026-10-22 · pre-push review 3 of 3 at 121c6cd1db04a5087f226d9e4cb103db763cb78e · iter -
- Decision: no findings
- Why: review-2 findings verified fixed; reviewed tree 6b115769e7ebec196fb5e8308747cae598324361
- Source: https://github.com/pydantic/pydantic-ai/tree/ci-review-provider-incidents
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.