Skip to content

fix(cursor): bound frame copying and preserve context boundaries - #432

Merged
tt-a1i merged 2 commits into
mainfrom
codex/context-transport-performance
Sep 7, 2026
Merged

fix(cursor): bound frame copying and preserve context boundaries#432
tt-a1i merged 2 commits into
mainfrom
codex/context-transport-performance

Conversation

@tt-a1i

@tt-a1i tt-a1i commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator

Problem

Cursor concatenated the entire incomplete Connect frame for every network fragment: a deterministic 1 MiB/1 KiB-chunk regression copied 538 MB. Separately, transcript rows cached relative paths across cwd changes. The follow-up audit also needed to distinguish duplicate protocol representations from actual duplicated model context. Fixes #431.

Value

Large fragmented responses incur linear copying, and switching child working directories cannot show stale relative paths. Context regression coverage prevents a misleading optimization from deleting required history or substituting generated-token counts for context usage.

Approach

Use a five-byte header plus one bounded payload buffer for fragmented frames, borrowing contiguous payload slices for synchronous decode. Preserve the 16 MiB limit, EOF errors and existing MCP handoff boundaries. Include cwd in the bounded transcript cache key. Verify both Cursor history trees, compacted-context rebuilding and Pi's zero-usage estimation boundary without changing the protocol or usage policy.

Validation

bun run check passed. The default bun run test attempt was interrupted during severe host scheduling delay; its log is retained. The complete repository-discovered suite then passed at Node file concurrency 2: 1455 passed, one platform skip; Vitest 30/30. Final-head CI passed on 84cc307e9af5c8fac0824619ab00814c19d7af5c: Node 22.19.0, Node 24 and Windows, including standard repository checks/tests and package smoke coverage. Two independent code reviews found no actionable issues. Deterministic regressions cover byte-copy growth, all split positions, empty/coalesced frames, retained buffers, frame limits, production truncated EOF, cwd warm/cold equivalence, history pairing and compacted rebuilds. No paid provider calls or user runtime changes.

Impact

No model tools, permissions, settings or persisted schema change. A fragmented frame now reserves its declared payload size (up to the existing 16 MiB cap) once its validated header arrives, instead of repeated incremental allocations. Model history and token accounting remain unchanged: upstream evidence identifies JSON root history as model input and native turns as UI state; local duplication is not proof of doubled model context. The separate viewport rewrite #327 remains outside this batch because its existing 512-item measurement does not establish severe lag and its invalidation contract needs separate review.

Investigation. Fixed base: 69a7e5f19b4db3e32b7ad6abc81884edf767b2e3.

@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Sep 7, 2026
@tt-a1i
tt-a1i merged commit 0bd0041 into main Sep 7, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(cursor): bound fragmented transport cost and audit context accounting

1 participant