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
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
-
Z.AI
1302rate limits. The shim's 429 transport (rate_limit_retry_transport) gave up after 60 s. In the 190-minute1302burst 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 astime_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.
- 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
-
ui-security-reviewEnvironment. The Environment has no required reviewers, butmanual-approval: ui-security-review, the UI Security workflow's comments and.github/workflows/AGENTS.mddescribed a maintainer approving each run. The field is removed, soactivationno longer runs in that Environment and the lock no longer says "Manual approval required". The comments andAGENTS.mdno longer describe an approval. The Environment holds no secrets or variables. The lock is recompiled with gh-aw v0.86.2. -
Shim and library from one commit. A run that checks out a PR head gets
.githubrestored from the base branch, so the shim from the base imported the PR head'spydantic_ai_slim. On a head older than a symbol the shim imports, it died at import: run 42064142025 on #10643 failed withImportError: cannot import name 'CapabilityLoadDeltaPart'.prewarm-pydantic-ai-runner.shnow checks out$GITHUB_SHAat/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. Underworkflow_run, CI Review now runs main's shim instead of the PR head's.pull_requestandpull_request_reviewruns 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, androles:limits who triggers them. The 10 locks that importshared/pre-agent-steps.md, andpydantic-ai-stale-issues-finder, which inlines the step, are recompiled for the updated step comment; only their frontmatter hash changes. -
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
- Item 1:
test_rate_limit_retry_backs_off_exponentially_and_hands_a_longer_1302_burst_to_the_sdk(the schedule, and a burst longer than the window fails as before),test_rate_limit_retry_rides_out_a_1302_burst_shorter_than_its_window,test_rate_limit_retry_leaves_the_run_time_reserve_to_the_safe_output. - Item 2:
agentic_workflow_guard.py checkpasses on the recompiled lock. - Item 3:
test_prewarm_stages_the_workflow_commit_whatever_the_workspace_holds,test_launcher_runs_the_staged_runner. Live: CI Review dispatched from this branch on #10643, run 42148443402. The launcher ran the staged shim (runner=/tmp/gh-aw/runner-src/.github/scripts/pydantic-ai-runner exists=yes) with noImportError, the agent ran 110 turns, and its review was published. The run then reached CI Review's 28-minute limit after two sub-agent read timeouts; no request in it was rate-limited. That timeout is observed here, not fixed by this PR. - Item 4:
test_scheduled_recovery_retires_dispatch_task_incidents_once_their_run_concluded.
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 -
- Decision: Ship the AGENTS.md and workflow-comment wording exactly as drafted in 0ef7dd05c4
- Why: David chose "Sign off" (relayed by manager 2026-11-06T00:12Z)
- Source: https://github.com/pydantic/pydantic-ai/commit/0ef7dd05c4
- Session: 66eeeb2e-e4cb-4a91-a592-3dd991f93792
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 -
- Decision: Ship the AGENTS.md task-incident retirement wording exactly as drafted in 061c25ea0e
- Why: David chose "Sign off" (relayed 2026-11-06T01:19Z)
- Source: https://github.com/pydantic/pydantic-ai/commit/061c25ea0e
- Session: 66eeeb2e-e4cb-4a91-a592-3dd991f93792
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 -
- Decision: Reserved: fresh light-tier (Haiku) reviewer via claude -p from detached policy base 99bd6905af, read-only tools
- Why: Tree 6e2b1be5f9ddbfb99a9d27856418692bbefb7049; first review: full branch 99bd6905afa2aae3bca67d91857173b80dde9bdd..5f89c792b5cecdb01aa45d53139f1993c6152636
- Source: https://github.com/pydantic/pydantic-ai/tree/fix/gh-aw-zai-retry-backoff
- Session: 85331a36-9671-4d0f-b178-8dbb010e0182
2026-11-06 · pre-push review 1 of 3 outcome at 5f89c792b5cecdb01aa45d53139f1993c6152636 · iter -
- Decision: remediated in ebb9e2a5bd: reserve retry floor gated on elapsed time (47s -> 63s, matching main's stop_after_delay(60)); prewarm rerun test comment names the real cause
- Why: Reviewed tree 6e2b1be5f9ddbfb99a9d27856418692bbefb7049; full branch 99bd6905af..5f89c792b5. A first launch died on CLI arg parsing before any model call; not counted
- Source: https://github.com/pydantic/pydantic-ai/tree/fix/gh-aw-zai-retry-backoff
- Session: 85331a36-9671-4d0f-b178-8dbb010e0182
2026-11-06 · pre-push review 2 of 3 at ebb9e2a5bdc81e59dcb1ea1ffc13c9769ac221cf · iter -
- Decision: Reserved: fresh light-tier (Haiku) reviewer via claude -p from detached policy base 99bd6905af, read-only tools
- Why: Tree 05524b2dd585a50b161eb4504e8e6a742b8a220f; follow-up scope 5f89c792b5..ebb9e2a5bd plus review-1 findings to verify; last reviewed tree 6e2b1be5f9dd
- Source: https://github.com/pydantic/pydantic-ai/tree/fix/gh-aw-zai-retry-backoff
- Session: 85331a36-9671-4d0f-b178-8dbb010e0182
2026-11-06 · pre-push review 2 of 3 outcome at ebb9e2a5bdc81e59dcb1ea1ffc13c9769ac221cf · iter -
- Decision: Both review-1 findings verified fixed; one docstring finding remediated in 0302e08750
- Why: Reviewed tree 05524b2dd585a50b161eb4504e8e6a742b8a220f; follow-up scope 5f89c792b5..ebb9e2a5bd
- Source: https://github.com/pydantic/pydantic-ai/tree/fix/gh-aw-zai-retry-backoff
- Session: 85331a36-9671-4d0f-b178-8dbb010e0182
2026-11-06 · push 0302e08750 on exempt delta from ebb9e2a5bd · iter -
- Decision: No review 3: delta is docstring-only (one added line in _stop_rate_limit_retries)
- Why: Exempt row 'Comments or docstrings only'; git diff ebb9e2a5bd..0302e08750 has no non-comment line; chains from reviewed ebb9e2a5bd
- Source: https://github.com/pydantic/pydantic-ai/tree/fix/gh-aw-zai-retry-backoff
- Session: 85331a36-9671-4d0f-b178-8dbb010e0182
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 -
- Decision: Count it as the proof; the PR body notes its 28-minute time_limit as observed, not fixed
- Why: Manager's call following David's earlier decisions: staged runner found, no ImportError, review published on #10643's head
- Source: https://github.com/pydantic/pydantic-ai/actions/runs/42148443402
- Session: 85331a36-9671-4d0f-b178-8dbb010e0182
2026-11-06 · task incidents #12679 and #10695 closed by hand · iter -
- Decision: #12679 (the proof dispatch's time_limit) and #10695 closed by hand; no action in this PR
- Why: Manager's call: run 42148443402 published a review on #10643's exact head fdfbcb25e, #10695's same-target recovery
- Source: https://github.com/pydantic/pydantic-ai/issues/10695
- Session: 85331a36-9671-4d0f-b178-8dbb010e0182
2026-11-06 · upstream gh-aw api-proxy token issue posted · iter -
- Decision: Posted as github/gh-aw#75271; the PR body links it and drops the superseded draft entry
- Why: Manager relayed that the issue is already posted
- Source: https://github.com/github/gh-aw/issues/75271
- Session: 85331a36-9671-4d0f-b178-8dbb010e0182
- Supersedes: draft upstream gh-aw api-proxy token issue
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 -
- Decision: No review 3: delta since reviewed ebb9e2a5bd is a docstring line and a bash comment
- Why: Exempt row 'Comments or docstrings only'; git diff ebb9e2a5bd..73ce780d64 has no non-comment line
- Source: https://github.com/pydantic/pydantic-ai/pull/12674
- Session: 85331a36-9671-4d0f-b178-8dbb010e0182
2026-11-06 · pre-push review 3 of 3 at cefa4ac75eb29478e061fe99bbf0ee18de4f3d61 · iter -
- Decision: Reserved: fresh strong-tier (Opus) reviewer via claude -p from detached policy base c833840a95, read-only tools
- Why: Tree 3c73bc04439faefce722c65b4293c10d916319ed; follow-up scope ebb9e2a5bd..cefa4ac75e (douwebot findings on 73ce780d64: stale-issues pre-warm comment, dispatch-run 404); last reviewed tree 05524b2dd585; strong tier because douwebot commented on two earlier pushes
- Source: https://github.com/pydantic/pydantic-ai/pull/12674
- Session: 1fcd0512-2a49-431a-ba19-cf3d41ce1ef8
2026-11-06 · douwebot review body: stale-issues pre-warm comment · iter -
- Decision: Do: rewrite the stale-issues-finder pre-warm comment to match shared/pre-agent-steps.md in 981dc091f5; lock recompiled with v0.86.2, hash line only
- Why: Valid: the step now fails the job when it cannot stage the shim; the other three inline-prewarm workflows carry no such comment
- Source: https://github.com/pydantic/pydantic-ai/pull/12674#pullrequestreview-5799927502
- Session: 1fcd0512-2a49-431a-ba19-cf3d41ce1ef8
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 -
- Decision: No findings: current at cefa4ac75eb29478e061fe99bbf0ee18de4f3d61; review budget now exhausted
- Why: Reviewed tree 3c73bc04439faefce722c65b4293c10d916319ed; follow-up scope ebb9e2a5bd..cefa4ac75e
- Source: https://github.com/pydantic/pydantic-ai/pull/12674
- Session: 1fcd0512-2a49-431a-ba19-cf3d41ce1ef8
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.