Retry Z.AI request-rate 429s for up to 10 minutes, run the gh-aw shim and its library from one commit, and retire concluded dispatch incidents

Merged
DS
1mo ago
+298-81

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

Why we make these changes: follow-up to #12570. Four problems in the Z.AI-backed gh-aw workflows, each fixed below: rate-limited Z.AI requests gave up after 60 s and ended runs; the UI Security docs claimed an approval gate its Environment does not have; the base branch's shim crashed importing an older PR head's library; and a manual dispatch's task incident never retired.

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

Workflow behavior, before and after

  1. Z.AI 1302 rate limits. The shim's 429 transport (rate_limit_retry_transport) gave up after 60 s. In the 190-minute 1302 burst of 2026-11-04, 9.6% of rate-limited requests gave up, and every give-up in a main agent ended its run (15 UI Security, 4 CI Review). The window is now 10 minutes. The backoff is unchanged: full jitter, from 1 s, doubling, capped at 16 s.

    • In that burst each retry passed about one time in five, however long its request had waited (0.14–0.25 across retries 1–11). No 429 carried retry-after. The number of attempts the window allows therefore sets the give-up rate: an estimated one request in a million or fewer at 10 minutes, about 0.07% if the pass rate halves. Rate-limited requests still average about 6 attempts.
    • Retries stop before the next wait would end inside the run's 5-minute time reserve, which keeps time to emit the safe output. A rate limit that outlasts the retries still fails as rate_limit, local to the run, instead of reaching the deadline as time_limit, which opens a task incident. Every request keeps at least 60 s of retries, inside the reserve too. The shortest window before a reserve is Feature Digest's 8 minutes.
    • Account and plan-limit codes (1113, 1308–1321) still fail fast and open a provider incident.
  2. ui-security-review Environment. The Environment has no required reviewers, but manual-approval: ui-security-review, the UI Security workflow's comments and .github/workflows/AGENTS.md described a maintainer approving each run. The field is removed, so activation no longer runs in that Environment and the lock no longer says "Manual approval required". The comments and AGENTS.md no longer describe an approval. The Environment holds no secrets or variables. The lock is recompiled with gh-aw v0.86.2.

  3. Shim and library from one commit. A run that checks out a PR head gets .github restored from the base branch, so the shim from the base imported the PR head's pydantic_ai_slim. On a head older than a symbol the shim imports, it died at import: run 42064142025 on #10643 failed with ImportError: cannot import name 'CapabilityLoadDeltaPart'. prewarm-pydantic-ai-runner.sh now checks out $GITHUB_SHA at /tmp/gh-aw/runner-src, failing the job if it cannot, and the launcher runs the shim from there. The reviewed workspace stays at the PR head. Under workflow_run, CI Review now runs main's shim instead of the PR head's. pull_request and pull_request_review runs now use the shim from the PR's merge commit instead of the base branch's; both workflows already run that commit's workflow file, and roles: limits who triggers them. The 10 locks that import shared/pre-agent-steps.md, and pydantic-ai-stale-issues-finder, which inlines the step, are recompiled for the updated step comment; only their frontmatter hash changes.

  4. Manual-dispatch task incidents. A dispatch's task key names its run, so its incident blocked nothing once the run concluded, yet no sweep retired it (#12632). The hourly run now retires it once that run has concluded, or once GitHub no longer has the run: GitHub deletes only a completed run or one older than two weeks, and a deleted run cannot be re-run.

Verification

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

PR decisions

2026-11-05 · 1302 retry window 600s, sized by attempts · iter -

  • Decision: RATE_LIMIT_RETRY_SECS = 600; keep wait_random_exponential(multiplier=1, max=16) and full jitter
  • Why: Logfire 2026-11-04 burst: per-retry pass ~0.2 flat over retries 1-11, no retry-after; est. give-up <=1e-6 at 600s, 0.07% if pass rate halves; manager chose 600 over 300 from David: "more retries, lets leverage exponential backoff. we're not in a rush, we prefer to be stable"
  • Source: https://github.com/pydantic/pydantic-ai/commit/fd68220fd61f366f764dfbcdd6582ef0c9629d42
  • Session: 66eeeb2e-e4cb-4a91-a592-3dd991f93792

2026-11-05 · retry stops before the run time reserve · iter -

  • Decision: Stop when the next wait ends inside RUN_TIME_RESERVE_SECS; every request keeps 60s of retries, inside the reserve too
  • Why: Past the deadline a run fails as time_limit (task incident); rate_limit stays local; the 60s floor keeps the prior window inside the reserve
  • Source: https://github.com/pydantic/pydantic-ai/commit/7ecb6163af
  • Session: 66eeeb2e-e4cb-4a91-a592-3dd991f93792

2026-11-06 · ui-security-review approval wording signed off · iter -

2026-11-06 · drop manual-approval from UI Security · iter -

  • Decision: Remove manual-approval: ui-security-review; activation no longer runs in the Environment; lock header claim gone
  • Why: David chose "Drop the field"; Environment has protection_rules [] and no secrets or variables, so the field only produced a false approval claim
  • Source: https://github.com/pydantic/pydantic-ai/commit/6622aaf0ee
  • Session: 66eeeb2e-e4cb-4a91-a592-3dd991f93792

2026-11-06 · fold: shim runs against the PR head's library · iter -

  • Decision: Fix in this PR: run the shim and pydantic-ai-slim from one commit ($GITHUB_SHA checkout), reviewed workspace stays at PR head
  • Why: David chose "Fix now in the follow-up PR"; run 42064142025 on #10643 died with ImportError CapabilityLoadDeltaPart because main's restored shim imported the PR head's older library
  • Source: https://github.com/pydantic/pydantic-ai/actions/runs/42064142025
  • Session: 66eeeb2e-e4cb-4a91-a592-3dd991f93792

2026-11-06 · fold: retire dispatch-key task incidents · iter -

  • Decision: Retire a workflow_dispatch task incident once its run has concluded; keep AGENTS.md's manual-close sentence accurate
  • Why: David approved folding it in; _task_retirement returns None for dispatch keys, so a failed manual dispatch's incident never retires (#12632)
  • Source: https://github.com/pydantic/pydantic-ai/issues/12632
  • Session: 66eeeb2e-e4cb-4a91-a592-3dd991f93792

2026-11-06 · dispatch-retirement wording signed off · iter -

2026-11-06 · dispatch incidents visible up to ~1 hour · iter -

  • Decision: Accept that a failed manual dispatch's task incident closes at the next hourly sweep
  • Why: Manager's call; David approved auto-retiring failed manual-dispatch incidents with this fix
  • Source: https://github.com/pydantic/pydantic-ai/issues/12632
  • Session: 66eeeb2e-e4cb-4a91-a592-3dd991f93792

2026-11-06 · sandbox proof via CI Review dispatch on #10643 · iter -

  • Decision: After push, dispatch pydantic-ai-pr-review.lock.yml from this branch with aw_context item_number 10643; confirm no ImportError and normal publish/skip; link run in PR body
  • Why: Manager's call (option b); David already approved a CI Review dispatch on #10643; proves both the sandbox path and the skew case
  • Source: https://github.com/pydantic/pydantic-ai/actions/runs/42064142025
  • Session: 66eeeb2e-e4cb-4a91-a592-3dd991f93792

2026-11-06 · detection telemetry out of scope · iter -

  • Decision: Drop threat-detection telemetry from this PR; bug-hunter and parity have no telemetry gap
  • Why: David: "i want to stop calling glm via the claude cli. claude cli is made for claude, other models perform terribly at it." Routed to the engine-migration lane
  • Source: https://github.com/pydantic/pydantic-ai/actions/runs/42064093118
  • Session: 66eeeb2e-e4cb-4a91-a592-3dd991f93792

2026-11-06 · pre-push review 1 of 3 at 5f89c792b5cecdb01aa45d53139f1993c6152636 · iter -

2026-11-06 · pre-push review 1 of 3 outcome at 5f89c792b5cecdb01aa45d53139f1993c6152636 · iter -

2026-11-06 · pre-push review 2 of 3 at ebb9e2a5bdc81e59dcb1ea1ffc13c9769ac221cf · iter -

2026-11-06 · pre-push review 2 of 3 outcome at ebb9e2a5bdc81e59dcb1ea1ffc13c9769ac221cf · iter -

2026-11-06 · push 0302e08750 on exempt delta from ebb9e2a5bd · iter -

2026-11-06 · proof run 42148443402: skew fixed, run hit time_limit · iter -

  • Decision: Count the skew fix as proven under the AWF sandbox; report the run's time_limit and task incident #12679 to the manager, no code change
  • Why: Launcher logged runner=/tmp/gh-aw/runner-src/... exists=yes, no ImportError, 110 turns, review published on #10643; time_limit followed two sub-agent ReadTimeouts with no 429 in the run, so no change in this PR spent the time
  • Source: https://github.com/pydantic/pydantic-ai/actions/runs/42148443402
  • Session: 85331a36-9671-4d0f-b178-8dbb010e0182

2026-11-06 · run 42148443402 accepted as the skew proof · iter -

2026-11-06 · task incidents #12679 and #10695 closed by hand · iter -

2026-11-06 · upstream gh-aw api-proxy token issue posted · iter -

2026-11-06 · douwebot thread: pull_request runs use the merge commit's shim · iter -

  • Decision: Valid; documented in prewarm-pydantic-ai-runner.sh comment and PR body, covering pull_request_review too; no code change
  • Why: Base-restore covers .github, so pull_request runs used the base shim; $GITHUB_SHA is the merge commit there. No new privilege: roles [admin, maintainer, write] gate both workflows, which already run the merge commit's workflow file
  • Source: https://github.com/pydantic/pydantic-ai/pull/12674#discussion_r4488507359
  • Session: 85331a36-9671-4d0f-b178-8dbb010e0182

2026-11-06 · push 73ce780d64 on exempt delta from ebb9e2a5bd · iter -

2026-11-06 · pre-push review 3 of 3 at cefa4ac75eb29478e061fe99bbf0ee18de4f3d61 · iter -

2026-11-06 · douwebot review body: stale-issues pre-warm comment · iter -

2026-11-06 · douwebot thread: retire a dispatch incident whose run is gone · iter -

  • Decision: Do: a 404 on the dispatch run retires the incident ('Dispatch run no longer exists.'); other read failures still leave it open; AGENTS.md wording unchanged
  • Why: GitHub deletes only completed runs or runs over two weeks old (github/docs delete-a-workflow-run.md), so a deleted run can never be re-run; the signed-off 'has concluded' wording stays true
  • Source: https://github.com/pydantic/pydantic-ai/pull/12674#discussion_r4492293585
  • Session: 1fcd0512-2a49-431a-ba19-cf3d41ce1ef8

2026-11-06 · pre-push review 3 of 3 outcome at cefa4ac75eb29478e061fe99bbf0ee18de4f3d61 · iter -

2026-11-06 · final metadata check at cefa4ac75e · iter -

  • Decision: Applied: Why-we-make-these-changes line and Files-changed links for the six proving tests. Rejected: Closes #12632
  • Why: #12632 is a task-incident issue already closed, so the PR cannot close it; it stays a related reference in item 4 (rule: related but non-closing issues go in the explanation)
  • Source: https://github.com/pydantic/pydantic-ai/issues/12632
  • Session: 1fcd0512-2a49-431a-ba19-cf3d41ce1ef8

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.