Repository navigation
perf(server): bounded snapshots of threads with large messages skip a full encode - #20064
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…and its exact fallback Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ss over both arrays The overflow shortcut walked visibleTurnItems and turnItems with duplicated loops and a duck-typed `"text" in item && typeof item.text === "string"` guard. The contract union already narrows `text` to a string for the three item types that carry it, so `"text" in item` is enough, and a shared predicate over `.some()` on both arrays stops at the same point as before. Behavior is unchanged. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ApprovabilityVerdict: Approved at Macroscope's review found this PR approvable — This is a small, self-contained server performance optimization that avoids redundant JSON serialization for provably oversized snapshots while preserving the existing output and budget flag behavior. Added tests cover the shortcut and exact-size fallback without changing defaults, APIs, or production workflows. No code changes detected at You can add or adjust custom eligibility rules. Learn more. |
Thread transfer impact✅ Thread transfer remains within every enforced ceiling.
Baseline: Scenario and decoded snapshot size10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed. |
|
Taking over this one as maintainer for batch composer-chat-07. I will preserve this bounded-snapshot text-length shortcut and its exact fallback, merge current main, and verify it independently. The long-thread snapshot work in the other batch remains separate. |
Keep main's current history paging and checkpoint budget behavior while retaining the text-length overflow shortcut and exact JSON-size fallback. Preserve both takeover regression tests alongside main's tests.
Preparing a bounded snapshot with oversized message text now skips the final full JSON encode when the retained text alone proves it exceeds the payload budget. Local items count once per encoded array; inherited items count once. When that lower bound fits, the existing exact encoded-size check still decides overflow. Projection contents, paging and the response flag are unchanged.
Merged current main into the original branch and kept its paging and checkpoint-budget changes. This PR remains limited to the final overflow check.
Original work by @bompus, carried forward in this maintainer PR. The earlier takeover already reduced coverage to two focused regressions; both remain in the existing
threadHistoryPaging.test.ts.Verification
Current-head CI passes for all executed validation jobs. Skipped jobs remain skipped; a canceled duplicate native-fingerprint run is superseded by a successful run. No merge is authorized.
Models: GPT-6.1 Sol (integration), Claude Opus 5.5 and GPT-6 Sol (review), through T3 Code delegation and the Codex/Claude harnesses.