Skip to content

fix(queue): Give each queue delivery its own request deadline - #3494

Merged
MathurAditya724 merged 1 commit into
mainfrom
fix/queue-delivery-deadline
Nov 16, 2026
Merged

MathurAditya724 merged 1 commit into
mainfrom
fix/queue-delivery-deadline

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

Fixes #3393

Root cause. In local dev, @vercel/queue calls a registered dev consumer from send() in an async function that it does not await. So the delivery runs inside the sender's AsyncLocalStorage context. queueCallback wrapped each delivery in runWithTurnRequestDeadline, which keeps any deadline it finds. Each delivery therefore reused the deadline of the request that sent it. After that deadline passed, every resumed slice and every child agent turn started with a 0 ms budget and timed out at once, until the 100-slice limit failed the turn.

Fix. The queue callback handler (the path that every queue provider calls for a delivery: the Vercel HTTP callback, the Vercel dev consumer, and the BullMQ worker) now starts a new request deadline with runWithNewTurnRequestDeadline. In production each delivery already ran in a new invocation with no stored deadline, so production behavior does not change. consume, which in-process queues call directly inside a host request, still shares the outer deadline.

Open decision. The issue also suggests failing a slice that starts with no budget instead of resuming it. This PR does not do that. With this fix a delivery cannot inherit a spent deadline. In production, a slice that starts past its host deadline should resume in a new invocation, so a hard failure there could fail turns that can recover.

via @MathurAditya724.

--

View Session [Sentry]

The Vercel Queue local-dev consumer runs deliveries inside the sender's
async context, so each delivery reused the sender's request deadline.
Once that deadline passed, every resumed slice and child agent turn
started with no budget and timed out until the slice limit.

Fixes #3393

Co-Authored-By: Aditya Mathur <[email protected]>
@vercel

vercel Bot commented Nov 16, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
junior-docs Ready Ready Preview Nov 16, 2026 7:50am UTC

Request Review

@github-actions

Copy link
Copy Markdown
Contributor

30 screenshot changes — 30 changed · 0 added · 0 removed

Review screenshots in Frameshift

Automation Run Details · Desktop
Automation Run Details · Desktop
Changed
Automations Runs Filters · Desktop
Automations Runs Filters · Desktop
Changed
Conversation Attachment · Desktop
Conversation Attachment · Desktop
Changed
Conversation Attachment · Mobile
Conversation Attachment · Mobile
Changed
Conversation Attachment Modal · Desktop
Conversation Attachment Modal · Desktop
Changed
Conversation Attachment Zoom · Desktop
Conversation Attachment Zoom · Desktop
Changed
Show 12 more changed screenshots
Conversation Captured Memories Popover · Desktop
Conversation Captured Memories Popover · Desktop
Changed
Conversation Child Agents · Desktop
Conversation Child Agents · Desktop
Changed
Conversation Details Watched Linked Work · Desktop
Conversation Details Watched Linked Work · Desktop
Changed
Conversation Event Log Virtual · Mobile
Conversation Event Log Virtual · Mobile
Changed
Conversation File Draft · Desktop
Conversation File Draft · Desktop
Changed
Conversation Long Transcript Touch · Mobile
Conversation Long Transcript Touch · Mobile
Changed
Conversation Memory List Jump · Desktop
Conversation Memory List Jump · Desktop
Changed
Conversation Memory List Jump · Mobile
Conversation Memory List Jump · Mobile
Changed
Conversation Share Details · Desktop
Conversation Share Details · Desktop
Changed
Conversation Task Line · Desktop
Conversation Task Line · Desktop
Changed
Conversation Text Attachment · Desktop
Conversation Text Attachment · Desktop
Changed
Conversations Pinned · Desktop
Conversations Pinned · Desktop
Changed

12 more changed screenshots in Frameshift.

@sentry-junior sentry-junior Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. I checked the root cause against the pinned @vercel/queue (0.2.0 in the lockfile; the issue says 0.2.1, same behavior): send() calls invokeDevHandlers, which runs the handler in an un-awaited async IIFE (and dev redelivery and delayed sends use setTimeout). Both keep the sender's AsyncLocalStorage store, so the old runWithTurnRequestDeadline in consume kept the spent deadline.

The fix is in the right place. The Vercel HTTP callback route and the BullMQ worker have no outer deadline, so handler creating a new one behaves the same as before for them. The in-process consume path (evals and conversationWorkQueue overrides) still shares the outer deadline, as the worker's shouldYield comment expects.

The new test fails on main's callback.ts (expected 1794813945258 to be greater than 1794817265333) and passes with this change. The other 7 tests in vercel-queue-dev.test.ts pass both ways.

@MathurAditya724
MathurAditya724 marked this pull request as ready for review November 16, 2026 10:37
@github-actions github-actions Bot added the risk: high PR risk score: high label Nov 16, 2026
@MathurAditya724
MathurAditya724 merged commit bdb3369 into main Nov 16, 2026
48 checks passed
@MathurAditya724
MathurAditya724 deleted the fix/queue-delivery-deadline branch November 16, 2026 10:44
MathurAditya724 added a commit that referenced this pull request Nov 17, 2026
Follow-up to #3496. The `params` preview showed "No
arguments." for tools whose input is a root union, like
`slackListUpdateItem`, and showed params with defaults as required. This
fixes both, rewrites the searchTools description so it matches how
discovery works now, and shares the preview hint with the Code Mode
hint.

It also updates the deferred tool discovery spec to describe the
`params` preview, fixes two stale comments left from
#3494, and makes automation card details use the shared
Slack external ref id schema.

<!-- junior-request-attribution:start -->
via @MathurAditya724.
<!-- junior-request-attribution:end -->

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:agent%3Afb8931822e52792d37f63497ad7ad63d -->

--

[View
Session](https://junior-prod.sentry.dev/conversations/agent%3Afb8931822e52792d37f63497ad7ad63d)
[[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3Afb8931822e52792d37f63497ad7ad63d/?project=4510944073809921)

<!-- junior-session-footer:end -->

---------

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: Aditya Mathur <[email protected]>

This branch was successfully deployed

1 active deployment
Preview – junior-docs — f4c30ba7 Deployed Nov 16, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: high PR risk score: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Long turns and child agents fail in local dev with a zero turn budget

1 participant