Repository navigation
fix(chat): Yield paused work after request deadline - #1381
Merged
Merged
Conversation
A timeout pause can mark conversation execution paused under the current lease while the host request deadline is already spent. Resuming that turn in the same worker loop reused the dead deadline and failed later slices with no-progress even after the boundary advanced once. Always yield the lease when execution is paused after a run so the next slice starts from a fresh queue wake and request deadline. Keep the same-boundary no-progress fail-safe. Cover both paths in durable-queue integration tests. Refs JUNIOR-7X Co-Authored-By: David Cramer <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Co-Authored-By: David Cramer <[email protected]>
Co-Authored-By: David Cramer <[email protected]>
Co-Authored-By: David Cramer <[email protected]>
dcramer
marked this pull request as ready for review
August 10, 2026 17:47
sentry-junior Bot
added a commit
that referenced
this pull request
Aug 10, 2026
Co-Authored-By: David Cramer <[email protected]>
This was referenced Nov 2, 2026
BYK
added a commit
that referenced
this pull request
Nov 7, 2026
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 is `turnTimeoutMs` from the Turn start, and nothing caps it at the host request deadline. So the run kept going until Vercel killed the function at `maxDuration` (800s). The last span is 799s after the first one. The lease expired, and on the next wake `projectTerminalTurn` found the Turn still `running` and 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.process` span. They happen throughout the day, not at deploy times. **Fix.** - Cap the child Turn deadline at the worker's host request deadline (`getTurnRequestDeadline()`), as Slack Turns do (#1381). The Turn then times out and parks before the host kills the request. - When the worker dies anyway, the main worker path resumes the Turn once from its last save with `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. - Move the lost-worker helpers from `paused-turn.ts` to `checkpoint.ts` so both paths can use them. - `killWorker` in the shared harness can now save the run's input before it kills the worker. That gives the integration tests a real `running` Turn. **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. <!-- junior-request-attribution:start --> via @BYK. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:agent%3Aa59eb1d03b0a1ee74e1524f22301a86e --> -- [View Session in Sentry](https://sentry.sentry.io/explore/conversations/agent%3Aa59eb1d03b0a1ee74e1524f22301a86e/?project=4510944073809921) <!-- junior-session-footer:end --> Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: BYK <[email protected]>
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.
Fix JUNIOR-7X without changing the turn progress rule.
A worker can resume paused work under the same lease while the host request has time left. When the host request deadline is spent, the worker now yields before another resume. The next queue wake gets a fresh request deadline.
The same-boundary no-progress check remains unchanged.
The durable queue integration test now runs the production agent runtime, resume logic, checkpoint, worker, lease, mailbox, and queue routing. It fakes only model generation at the
executeAgentRunstream boundary and Slack I/O at the adapter boundary. The task-execution README records this rule.Requested by David Cramer.
--
View Junior Session [Sentry]