Repository navigation
fix(queue): Give each queue delivery its own request deadline - #3494
Conversation
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]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
30 screenshot changes — 30 changed · 0 added · 0 removed Review screenshots in Frameshift Show 12 more changed screenshots12 more changed screenshots in Frameshift. |
There was a problem hiding this comment.
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.
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]>
Fixes #3393
Root cause. In local dev,
@vercel/queuecalls a registered dev consumer fromsend()in an async function that it does not await. So the delivery runs inside the sender'sAsyncLocalStoragecontext.queueCallbackwrapped each delivery inrunWithTurnRequestDeadline, 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 withrunWithNewTurnRequestDeadline. 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]