Repository navigation
fix(task-execution): Stop a late worker from replying or saving after it lost the Lease - #2901
Conversation
Co-Authored-By: David Cramer <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
10 screenshot changes — 10 changed · 0 added · 0 removed Review screenshots in Frameshift |
|
theres no such thing as a terminal turn? you're using jargon that doesnt make sense to me |
|
Fair, it was my word, not a repo concept. I meant a Turn that already ended as |
…saves A worker can stall past its Lease, for example when a synchronous webFetch conversion blocks the event loop (JUNIOR-G1). Recovery then gives the Turn to another worker. When the first worker came back, it posted its out-of-date reply and saved over the new owner's work. The agent now checks in right before it delivers a reply and right before it saves a step. When the check-in fails, the run stops with TurnInputCommitLostError. The Slack turn and resume paths rethrow it without writing a failure or posting an error, and the worker returns lost_lease. Two integration tests hold a live worker inside a model request until recovery takes its Turn. Both fail on main. Co-Authored-By: David Cramer <[email protected]>
A lost Lease now stops the run before the timeout and pause paths can save the Turn. The agent also checks in before it returns a completed result, so a child or dispatch run with no reply cannot save completed over another worker's Turn.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 496b65e. Configure here.
A hard timeout after an accepted reply returns a completed result from the error path. Check the Lease there too, so a late worker cannot save completed over a Turn that recovery already finished.
…#2927) When the last attempt of a web or event Turn failed, the mailbox worker marked the Turn failed in the Conversation, but its Turn record stayed `running`. A later wake with no new input then picked up that Turn again as the open mailbox Turn and ran it a second time. This is the root cause behind JUNIOR-9M. #2562 only closed the open Turn when new input arrived. Now the last failed attempt also fails the Turn record, in the same step. `failTurnRecord` already ignores Turns that are finished or have a newer version, so it can't overwrite another worker's result. **Test:** a new case in `conversation-stale-turn.test.ts` runs the agent with a fake model, so a real step is saved before Slack rejects the reply. Then it wakes the Conversation again with no input. On `main`, the Turn record stays `running` and the Turn gets picked up again. With this change, the record is `failed` and no work is resolved. Evals can't inject this failure, so the file gets a test-architecture baseline entry, the same as #2901 did for `durable-queue.test.ts`. Part of #2890 (Turn and execution core). <!-- junior-request-attribution:start --> via @dcramer. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:slack%3AC0B595QDZLL%3A1794073557.784359 --> -- [View Session](https://junior-prod.sentry.dev/conversations/slack%3AC0B595QDZLL%3A1794073557.784359) [[Sentry]](https://sentry.sentry.io/explore/conversations/slack%3AC0B595QDZLL%3A1794073557.784359/?project=4510944073809921) <!-- junior-session-footer:end --> --------- Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>

Item 3 of #2890.
What happens today
A worker can stall past its Lease. In JUNIOR-G1, a synchronous
webFetchconversion blocked one instance's event loop for 201s. Its workers missed every check-in, recovery gave the Turn to another worker, and the first worker then came back with an answer.On
main, the worker that comes back still acts as the owner:running, posts 2 more replies, and saves it ascompleted.Fix
durability.checkIn) right before it delivers a reply and right before it saves a step. A failed check-in means another worker holds the Lease, so the run stops withTurnInputCommitLostErrorand writes nothing.lost_lease.checkInis passed through every path that already passesshouldYield: Slack, resumed Turns, dispatch, child agents, and mailbox Turns.runningorpaused. This stays as a backstop.Proof
Two integration tests in
durable-queue.test.tshold a live worker inside a model request until its Lease expires, let recovery run the Turn on another worker, and then release the held worker. Only Slack and the model are fake. Both tests fail onmainwith the behavior above, and pass with this change.The tests run the agent, so the
durable-queue.test.tstest-architecture baseline goes from 8 to 10. Evals can't inject this fault.via @dcramer.
--
View Session [Sentry]