dsh-lag-guard: Limit the long session history window to 120 entries to prevent a multi-megabyte tool schema from bloating the first frame.
dsh-lag-guard is a DSH client plugin written by community maintainer 456erddgr, addressing the issue where long sessions freeze immediately upon opening. Since DSH fixes a maximum of 500 historical items, a session with 176 messages pulls in 484 events / 3290.8KB (accounting for 61.7%) at once, nearly half of which are JSON schemas for tools found in 4 request/header items. The virtual list is sliced by turn and performance measurement is disabled; furthermore, tool schemas are re-JSON.stringifyed during every view reconstruction (13.4ms). The combination of these three factors dominates the synchronous path of the initial frame, causing the freeze. The plugin wraps the `follow` and `readPage` methods of `SessionEventStream`, setting the window to `maxMessages: 120` and `turnWindow: {20, 1}`. For `header.tools` exceeding 200,000 characters, the plugin replaces them with an empty array and tracks `toolsDropped` and `toolsChars`, reducing the session size to 350.5KB, approximately an 78% reduction. The article introduces the three-layer causes, the fix, installation commands, configuration tuning in `cordis.patch.yml`, a metrics collector, and 21 contract tests. It also clarifies what is dropped, what is unaffected, and the limitation of silent failure if the upstream code renames classes.
Read More