Repository navigation
fix(agent-invocations): Resume child runs that lose their worker - #2886
Merged
Merged
Conversation
A child agent run that outlived its host request was killed at Vercel maxDuration. The next wake found its Turn still running and failed it with "Agent invocation lost its worker before it could pause". Cap the child Turn deadline at the worker's host request deadline, as Slack Turns do, so the Turn pauses before the host ends the request. When a worker dies anyway, resume the Turn once from its last save, as root Turns do. A second loss before the resumed run saves still fails the invocation. Move the lost-worker resume helpers next to the Turn checkpoint writes so both paths share them. Co-Authored-By: BYK <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
BYK
approved these changes
Nov 7, 2026
BYK
marked this pull request as ready for review
November 7, 2026 16:46
Contributor
|
12 screenshot changes — 12 changed · 0 added · 0 removed Review screenshots in Frameshift Show 6 more changed screenshots |
23 tasks done
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A child agent run can fail with
Agent invocation lost its worker before it could pause, and the parent then has to start the task over.Cause. On 2026-11-07, a worker took a second child invocation 703s into its request (trace
cd517dd5433d4a39be16732422c2f5c0). The soft yield was not due yet. The child Turn deadline isturnTimeoutMsfrom the Turn start, and nothing caps it at the host request deadline. So the run kept going until Vercel killed the function atmaxDuration(800s). The last span is 799s after the first one. The lease expired, and on the next wakeprojectTerminalTurnfound the Turn stillrunningand failed it. Root Slack Turns and automations resume once from their last save in this case (#2298). Child invocations did not.The deploy at about 16:00 UTC was not the trigger. The killed request ran on the old release until 16:08:51. Sentry shows about 26 child traces in 14 days that were cut off at 795–800s with no
queue.processspan. They happen throughout the day, not at deploy times.Fix.
getTurnRequestDeadline()), as Slack Turns do (fix(chat): Yield paused work after request deadline #1381). The Turn then times out and parks before the host kills the request.pauseLostWorkerTurn, the same helper the root path uses. A second loss before the resumed run saves still fails the invocation and reports the failure to the parent. Stop and supersede paths do not change.paused-turn.tstocheckpoint.tsso both paths can use them.killWorkerin the shared harness can now save the run's input before it kills the worker. That gives the integration tests a realrunningTurn.Remaining risk. A resumed run can repeat tool work done after the last save. Root Turns have the same limit. Web, event, and dispatch Turns also run without a deadline cap. This PR does not change them.
via @BYK.
--
View Session in Sentry