GeezerVison is showing github.com — fix(server): resume fallback keeps the latest turn when an older handoff is pending by Marve10s · Pull Request #21754 · pingdotgg/t3code
Conversation
Problem
When a native resume fails while an older handoff is still pending (from an earlier run that failed or was interrupted), the new conversation can lose the latest completed turn. The new fallback handoff is placed in front of the older pending handoffs. Delivery flattens handoffs in array order, and selectHistory treats the end of that array as the newest history, so the older handoff's items win the budget and the latest result is dropped. Fixes #21704.
Change
The resume fallback in ProviderTurnStartService now places its full-thread handoff after pending handoffs from earlier runs and before handoffs made for the current run. Those inputs already arrive oldest first (the projection reads handoffs by rowid), and the retry delta handoff is already appended last, so after this change delivery sees history in the order it happened.
Handoffs for the current run stay after the fallback on purpose. A provider-switch delta or a merge-back can carry items the fallback summary doesn't contain, and those are newer. A plain append would put the fallback's older unique items at the end and recreate the same bug under budget pressure.
Scope and approval
Fixes the triaged bug #21704 (accepted). The maintainer comment confirms the ordering cause in ProviderTurnStartService.ts, ContextHandoffDelivery.ts and handoffBudget.ts. This PR changes only that ordering. It leaves the separate submission-ordinal question from the issue untouched.
Verification
Added an integration test to ProviderSwitch.integration.test.ts. It runs four turns with native resume failing every time: run 2 fails, which leaves a pending fallback handoff, and the fallback for run 4 is delivered together with that older handoff under the default 16,000-byte budget. The test checks that run 2's handoff was delivered into run 4's native thread, and that run 4's injected history keeps the original brief and run 3's result.
- On
main the test fails: run 3's result is missing from the injected history, because run 1's older result from the stale handoff took its place.
- With this change it passes. The rest of
ProviderSwitch.integration.test.ts, ThreadMergeBack.integration.test.ts, ProviderTurnStartService.test.ts and ContextHandoffBudget.test.ts pass as well.
I could not check a live provider session, only the orchestration path with the test adapter.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
chatgpt-codex-connector[bot] reacted with thumbs up emoji
Codex Review Summary
This comment shows the latest Codex review activity on this pull request.
| Review |
Status |
Commit |
Review trigger |
| 📝 Code Review |
✅ Completed 2026-10-19T14:57:40.916898Z |
aad7de3 |
PR opened |
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review" or "@codex security review".
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Approvability
Verdict: Approved at aad7de3
Macroscope's review found this PR approvable — This is a focused resume-fallback ordering fix that preserves newer handoff history and adds targeted integration coverage. Its production impact is limited to the affected recovery path, with no schema, default, infrastructure, security, or static-analysis changes.
You can add or adjust custom eligibility rules. Learn more.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|

No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
-
⚙️ Run configuration
-
- Configuration used: Path: .coderabbit.config.ts
- Review profile: CHILL
- Plan: Advanced
- Run ID:
1a9b95eb-4b10-4b61-a9ee-21825b22d36f
📥 Commits
-
Reviewing files that changed from the base of the PR and between 5307c23 and aad7de3.
📒 Files selected for processing: 2
-
apps/server/src/orchestration-v2/ProviderTurnStartService.ts
apps/server/src/orchestration-v2/testkit/ProviderSwitch.integration.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
📝 Walkthrough
-
Resume-fallback handoffs now follow handoffs for earlier runs and precede handoffs targeting the current run. An integration test checks that the replacement thread receives the original brief and the latest completed result.
Changes: Resume-Fallback Handoff Ordering
| Layer / File(s) |
Summary |
Order resume-fallback handoffs apps/server/src/orchestration-v2/ProviderTurnStartService.ts, apps/server/src/orchestration-v2/testkit/ProviderSwitch.integration.test.ts |
The service places the generated handoff after handoffs for earlier runs and before handoffs targeting the current run. The integration test checks delivery to a replacement thread and verifies that its injected history includes the original brief and latest completed result. |
Priority: ➖ Normal
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix · Severity of issue fixed: Medium
Suggested reviewers: juliusmarminge
Merge Risk: ⚪ Minimal · up to aad7d
-
The fallback ordering preserves the latest completed turn in the covered continuation scenario. No actionable merge-blocking risk remains after normal checks.
### Architecture Summary
Architecture risk: 🔵 Low · up to aad7d
The change affects 1 system.
Changed systems: apps/server
Architecture concerns
No architecture-level concerns identified.
Review details
-
Systems and components
- observed — apps/server (service) was modified; 2 changed files map to changed impact.
Before / after behavior
- observed — Modified behavior in apps/server/src/orchestration-v2/ProviderTurnStartService.ts: When a provider resume falls back to a fresh native session, the generated summary handoff is now placed after handoffs for earlier runs but before handoffs targeting the current run; previously it was prepended before every existing handoff.
- observed — Modified behavior in apps/server/src/orchestration-v2/testkit/ProviderSwitch.integration.test.ts: Adds an integration test covering a resume-fallback replacement thread that also receives an older handoff. Across four Claude runs, run 2 fails and runs 1 and 3 complete; the test verifies the older handoff’s delivery references run 4’s native thread and that history newly injected for run 4 contains both the original brief and run 3’s latest result.
Pre-merge checks: 4
-
| Check name |
Status |
Explanation |
| Title check |
 |
The title clearly and concisely describes the main fix: preserving the latest turn when an older resume-fallback handoff is pending. It uses an appropriate conventional commit format. |
| Description check |
 |
The description includes complete Problem, Change, Scope and approval, and Verification sections. It identifies the issue, explains the ordering change, cites maintainer approval, reports focused test… |
| Linked Issues check |
 |
Issue #21704 requires recency-aware handoff selection and protection of newer completed-turn content under the budget. ProviderTurnStartService.ts now places the resume-fallback handoff after handof… |
| Out of Scope Changes check |
 |
The diff contains one ordering change in ProviderTurnStartService.ts and one integration test for issue #21704. The test directly validates the reported ordering and budget behavior. No unrelated pr… |
Full details: Description check
-
Explanation
The description includes complete Problem, Change, Scope and approval, and Verification sections. It identifies the issue, explains the ordering change, cites maintainer approval, reports focused test results, and states the live-provider limitation.
Full details: Linked Issues check
-
Explanation
Issue #21704 requires recency-aware handoff selection and protection of newer completed-turn content under the budget. ProviderTurnStartService.ts now places the resume-fallback handoff after handoffs from earlier runs and before current-run handoffs. The added ProviderSwitch.integration.test.ts test verifies delivery of the older pending handoff and retention of the original brief and latest completed result in run 4 history.
Full details: Out of Scope Changes check
-
Explanation
The diff contains one ordering change in ProviderTurnStartService.ts and one integration test for issue #21704. The test directly validates the reported ordering and budget behavior. No unrelated production behavior or separate submission-ordinal work is changed.
✨ Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Comment @coderabbitai help to get the list of available commands.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Note 🤖 Claude Opus 5.5 responding on behalf of Theo
Thanks for this fix. We took it over in #22902 so it can land now: your commit is kept with your authorship, rebased on current main, with a small follow-up commit on top. Closing this one in favor of #22902.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Labels
size:XS
0-9 changed lines (additions + deletions).
vouch:unvouched
Author is not yet trusted in the VOUCHED list.
Milestone
No milestone
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.
|