Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): agent-driven threads keep their recent rows when checkpoint data is large #21187

Mergedfixfon(GitHub profile, opens in a new tab)merged 1 commit intomain fromrefs/pull/21187/headmerged by juliusmarminge View on GitHub

Problem

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 that payloadBudgetExceeded stays true. On main it fails with expected [ … ] to have a length of 15 but got 1; with this change it passes.
  • vp test run on threadHistoryPaging.test.ts (24 passed), ThreadStream.test.ts, ThreadTransportPerformance.test.ts and ProjectionStore.test.ts all pass.
  • vp fmt --check and vp lint are clean on the changed files, and vp run --filter t3 typecheck passes.

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

    2. Approvability

      Verdict: Approved at d9a151d

      Macroscope'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).
    3. Review in Change Stack →

      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.ts
      • apps/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.ts
      The 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

      Merge 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 Summary

      Architecture risk: 🔵 Low · up to d9a15

      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/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, hasMoreHistory to be false, and the payload budget exception to be reported.
      • observed — Modified behavior in apps/server/src/orchestration-v2/threadHistoryPaging.ts: buildBoundedThreadProjection now documents that unpageable control state may claim at most half the budget and floors windowBudget at policy.maxEncodedBytes / 2; previously, the lower bound was zero.
      Pre-merge checks: Passed 3 · Failed 1
      Failed Failed checks: 1 warning
      Check nameStatusExplanationResolution
      Linked Issues checkWarningIssue #21152 requires 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 Passed checks: 3 passed
      Check nameStatusExplanation
      Title checkPassedThe title is concise, specific, and accurately summarizes the main fix: preserving recent rows in agent-driven threads when checkpoint data is large.
      Description checkPassedThe 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 checkPassedThe 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 and payloadBudgetExceeded. These changes directly support issue #21152 and add no unrelated behavior.

      Full details: Linked Issues check

      Explanation

      Issue #21152 requires 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 verifies payloadBudgetExceeded. 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
      Comment `@coderabbitai help` to get the list of available commands.
    4. juliusmarminge merged thisd9eb2b6

    5. juliusmarminge closed this

Sign in to join this conversation.