Resume timed-out CI Review delegates and enforce the parent's time reserve
This pull request was posted by Claude Code using claude-opus-5-5 on behalf of David.
Why we make these changes
In the two CI Review runs on current source since #10501 (39358200683, 39360027162), delegates that hit the 15-minute Task timeout had gathered most of their evidence, but task discarded their history and the parent re-reviewed their files: 11 and 6.4 minutes on the critical path. In the first run the parent kept investigating through the time-budget notice, and nothing was posted. In the second, the parent approved after reading the full source of only 2 of the 9 modified files it took over.
What changes
- Resume a timed-out delegate (
cli.pytask).capture_run_messageskeeps the delegate's history. On timeout the partial response is dropped,repair_messagescloses out tool calls the cut left unanswered, and one streamed request without tools asks for the report and for anything unfinished. The parent receives it prefixednote: the sub-agent timed out …. The resume runs only within the delegate's unspent request grant and before the parent's time reserve. Otherwise, or if the request fails,taskreturns the same timeout error as before. Its usage is charged to the parent. - Enforce the parent's time reserve (
cli.pyrun). Once thetime_budget_noticecondition holds, aPrepareToolscapability offers only themcp__safeoutputs__*tools. The request in flight is not cancelled, and the notice stays. - Review prompt (
shared/prompts/pydantic-ai-pr-review.md). A resumed report counts like any other delegate report. A file the parent reviews itself counts as reviewed only after its diff and full source (a new file's diff is enough); otherwise it is unreviewed, which rules outAPPROVE. Once only safe-output tools remain, unverified findings go into the review body, marked unverified.
Design decisions
- Unanswered tool calls get pydantic-ai's synthesized
interruptedreturns instead of being deleted: deleting a call can leave a thinking-only response whose signature covered it (pydantic_ai_slim/pydantic_ai/messages.py_repair_dangling_tool_calls). - The resume spends from the delegate's own grant, which stays in
_subagent_requests_in_flightuntiltaskreturns, so shared request accounting is unchanged. - The resume is streamed like the delegate. A non-streamed request sends nothing until it finishes, so the client's 120 s read timeout would cut a long report.
- The resume runs under the shim's
_wall_clock_capwith_MarkTimedOutSpans, like the delegate (#10687), as thedelegate-resumeagent. Theexecute_tool Taskspan keeps its timeout mark after a resume, because the delegate's cap did fire. error:results keep "Do not dispatch it again"; re-dispatching never fits the time left.- No model, limit, timeout, retry or concurrency changes.
- The shared prompt is fetched at run time (run 39360027162 logged
using the committed default prompt), so no lock recompile. - #10347 also edits
task's timeout path; whichever lands second rebases.
Verification
.github/scripts/test_pydantic_ai_runner.py, in-process with scripted models and an injected cut, no real waits: resume from history with the partial response dropped; unanswered calls closed out; no resume without time, request headroom, or a completed response; resume failure returns the timeout error; tool filter across the reserve boundary, with the in-flight call still run.test_subagent_is_resumed_after_its_cap_cuts_it_offexpires the real cap on a clock-skipping loop and pins theTaskresult and every span's outcome.- GLM via Z.ai (
glm-5.3-flash) and Anthropic (claude-sonnet-5-5) both accept the streamed, tool-less resume request on a history withtool_useblocks; the GLM run went end to end throughcli.task(result). test_run_timeout_marks_the_spans_it_cuts_off(from #10687) now uses a 6-minute run budget: its 1-minute budget sat wholly inside the 5-minute reserve, where itshangtool is no longer offered.- Comparing matched runs after deployment needs the shim telemetry fixes first.
Related: #10259, #10309, #10570. This PR closes none of them.
New public surface
None.
User-visible behavior
Only the gh-aw workflows that run on this shim change. Each is offered only its safe-output tools during its final five minutes, and those that use Task resume timed-out delegates.
What changes for existing users
Nothing. Only .github/ changes.
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 (not applicable).
- PR title is fit for the release changelog.