fix(server): agent-driven threads keep their recent rows when checkpoint data is large #21187
main fromrefs/pull/21187/head·merged by juliusmarminge View on GitHubProblem#
Threads with no user prompts are windowed by bytes. buildBoundedThreadProjection subtracts the rest of the projection, including every checkpoint's file list, from the 1 MB budget before picking rows. When that data alone fills the budget, the row budget drops to 0 and the window keeps a single row, so the thread opens with only "Load earlier turns".
Change#
In threadHistoryPaging.ts the row budget now never falls below half of the page budget. State that cannot be paged (checkpoint file lists, an active plan) can no longer push the timeline out of the first window. When that state leaves at least half the budget for rows, the window is the same as before, and threads windowed by user turns do not use the byte budget at all. payloadBudgetExceeded still reports true in the oversized case.
Scope and approval#
Fixes #21152. A maintainer accepted the narrow window-starvation part of the issue: https://github.com/pingdotgg/t3code/issues/21152#issuecomment-6248775261
Explaining which limit hid earlier turns next to the history control was triaged as a feature request, so this PR does not touch the UI.
Verification#
- New test in
threadHistoryPaging.test.ts: "keeps agent-only turns visible when checkpoint file lists fill the byte budget". It follows the issue's repro and also checks thatpayloadBudgetExceededstays true. On main it fails withexpected [ … ] to have a length of 15 but got 1; with this change it passes. vp test runonthreadHistoryPaging.test.ts(24 passed),ThreadStream.test.ts,ThreadTransportPerformance.test.tsandProjectionStore.test.tsall pass.vp fmt --checkandvp lintare clean on the changed files, andvp run --filter t3 typecheckpasses.
Model and harness: Claude Sonnet 5.5 (xhigh) running in T3 Code.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XS
Approvability#
Verdict: Approved at
d9a151dMacroscope's review found this PR approvable — This is a small, focused server bug fix that prevents large non-pageable checkpoint metadata from hiding recent agent-thread rows. The production change is isolated to the history-window budget calculation and includes targeted regression coverage, with no schema, default, deployment, or static-analysis changes.
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).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:
10a63973-aa8b-420a-9568-a24ac07c88fd
📥 Commits
-
Reviewing files that changed from the base of the PR and between 9c161462c94f7d9d6d9169da5c841457cbadf213 and d9a151da989470d13ba7fc00e4d3357a22943a78.
📒 Files selected for processing: 2
-
apps/server/src/orchestration-v2/threadHistoryPaging.test.tsapps/server/src/orchestration-v2/threadHistoryPaging.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
-
📝 Walkthrough
-
The bounded thread projection now reserves at least half of the encoded-byte budget for its timeline window. A regression test covers agent-only turns with a large checkpoint file list and verifies timeline visibility, no additional history, and a reported payload-budget exception.
Changes: Thread timeline budget
Layer / File(s) Summary Timeline window budget and regression test
apps/server/src/orchestration-v2/threadHistoryPaging.ts,apps/server/src/orchestration-v2/threadHistoryPaging.test.tsThe timeline window budget now has a minimum of half the encoded-byte limit. A regression test checks that agent-only turns remain visible when a checkpoint contains a large file list, and that the projection reports the payload budget exception. Priority: ⬇️ Low
Estimated code review effort: 2 (Simple) | ~8 minutes
Change: Bug fix · Severity of issue fixed: Low
Suggested reviewers:
juliusmarminge
### Architecture SummaryMerge Risk: ⚪ Minimal · up to
d9a15-
Recent agent-only rows remain visible under large checkpoint data, with oversized projections reported; user-turn pagination is unchanged. No actionable merge-blocking risk was established.
Architecture risk: 🔵 Low · up to
d9a15The change affects 1 system.
Changed systems:
apps/serverArchitecture 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/threadHistoryPaging.test.ts: Adds a bounded-projection test with three agent-created prompt turns, four command rows per turn, and a checkpoint containing 15,000 file paths. The assertions expect every timeline item to remain visible,
hasMoreHistoryto be false, and the payload budget exception to be reported. - observed — Modified behavior in apps/server/src/orchestration-v2/threadHistoryPaging.ts:
buildBoundedThreadProjectionnow documents that unpageable control state may claim at most half the budget and floorswindowBudgetatpolicy.maxEncodedBytes / 2; previously, the lower bound was zero.
Pre-merge checks:
3 · 1-
Failed checks: 1 warningCheck name Status Explanation Resolution Linked Issues check Issue #21152requires recent turns to remain visible and requires the history control to state why earlier turns are hidden and which limit applies. The changed server budget and regression test keep …Implement the issue's remaining UI behavior. Propagate the applicable history-limit information to the client and display the reason and limit next to the history control on web and mobile. Passed checks: 3 passed-
Check name Status Explanation Title check The title is concise, specific, and accurately summarizes the main fix: preserving recent rows in agent-driven threads when checkpoint data is large. Description check The description includes all required sections. It explains the problem, change, scope and approval, verification results, limitations, and the model and harness used. Out of Scope Changes check The production change is limited to buildBoundedThreadProjection. It reserves at least half of the page budget for timeline rows when unpaged control state consumes the byte budget. The added test c…Full details: Out of Scope Changes check
-
Explanation
The production change is limited to
buildBoundedThreadProjection. It reserves at least half of the page budget for timeline rows when unpaged control state consumes the byte budget. The added test covers the reported checkpoint-file-list case andpayloadBudgetExceeded. These changes directly support issue#21152and add no unrelated behavior.
-
Full details: Linked Issues check
-
Explanation
Issue
#21152requires recent turns to remain visible and requires the history control to state why earlier turns are hidden and which limit applies. The changed server budget and regression test keep all 15 agent-only items visible when checkpoint files exceed the byte budget, and the test verifiespayloadBudgetExceeded. No change sends or displays the byte-limit reason in the history control. The active, directly linked issue still contains this coding requirement.Resolution
Implement the issue's remaining UI behavior. Propagate the applicable history-limit information to the client and display the reason and limit next to the history control on web and mobile.
-
- Fix all pre-merge checks with AI
✨ Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
-
juliusmarminge merged thisd9eb2b6
juliusmarminge closed this
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes