fix(chat): resume already-checkpointed running turns - #1237
Draft
sentry-junior[bot] wants to merge 4 commits into
Draft
fix(chat): resume already-checkpointed running turns#1237sentry-junior[bot] wants to merge 4 commits into
sentry-junior[bot] wants to merge 4 commits into
Conversation
Redelivery against a still-running turn reused a Date.now() prompt and failed commitMessages' append-only deep-equal check. That mismatch was swallowed as TurnInputCommitLost and mapped to lost_lease recovery, requeuing forever. Reuse the exact durable checkpointed prompt on running-record replay, throw a typed AgentHistoryBoundaryError for permanent shape mismatches, and fail closed without lost_lease recovery wakes. Evidence: JUNIOR-62 / JUNIOR-7A storm on slack:C0B595QDZLL:1785871561.942119 Co-Authored-By: David Cramer <david@sentry.io>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
A still-running turn with turnStartMessageIndex already owns its prompt. Treat that as resume so redelivery continues instead of rebuilding a Date.now() user message that fails append-only commit and farms lost_lease retries. Also stop swallowing permanent history-boundary mismatches as false. Co-Authored-By: David Cramer <david@sentry.io>
Resume already-checkpointed running turns without fail-closed history throws that broke handoff follow-ups. Add a consecutive empty-wake ceiling so lost_lease/continue recovery cannot farm forever without mailbox progress. Co-Authored-By: David Cramer <david@sentry.io>
Healthy resume+defer slices were treated as empty-wake failures and forced a yield. Count CONVERSATION_WORK_MAX_EMPTY_WAKES only when recovery has no mailbox progress, and clear the streak after successful runs.
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.
Stop poison-turn continue storms by treating an already-checkpointed running session as resume.
Root cause
If a turn checkpoints its prompt, then dies while still
running, redelivery treated it like a fresh prompt: rebuild user message → append-onlycommitMessagesrejects prefix → swallowed as commit-lost →lost_leaserequeue forever.Minimal fix
turnStartMessageIndexmeans the prompt is already owned →shouldPromptAgent = falseand resume/continue that historyrunningrecords with that cursor count as resumed sessionsfalse/ lost-lease recoveryNet diff is ~4 files / ~40 lines. No new error types or worker-wide rewrites.
Verification:
tsc --noEmit. Component tests need Postgres; not run here.Refs https://sentry.sentry.io/issues/7629103059/
Refs https://sentry.sentry.io/issues/7650484395/