Repository navigation
fix(context): serve a cached SessionStart body only when it fits the reserve-adjusted room (#5672) - #5686
Merged
thedotmack merged 1 commit intoNov 10, 2026
Conversation
…reserve-adjusted room (thedotmack#5672) The context cache holds bodies rendered for the full 10,000 character budget, without the current session's notice reserve. The SessionStart handler read such a body whenever it fit the raw limit, and composeSessionStartContext then dropped the whole body against the reserve-adjusted room, so the session started with only the omission notice and no timeline or work state. Share one room definition between the read and the compose step: a new sessionStartBodyRoom helper computes the room the notices leave, and the cached read serves a body only when it fits that room. An over-room body is now a cache miss, and the hook falls through to the live fetch, which re-renders it with the current reserve. Bodies that fit are still served from cache. Nothing is cut to fit. Regression tests at the handler level cover both sides: a 9,361 character cached body with about 1,268 characters of notices is treated as a miss and fetched live with reserveChars, and a 5,000 character body under the same notices is still served from cache with no worker call. Signed-off-by: Varshith Puli <pulivarshit@gmail.com>
Owner
|
Merged, thank you @Varshith-Kali! Main already rejected a cached body that doesn't fit next to the notices since v15.14.0 (#5487, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #5672.
Since 15.13.0, sessions with enough recent observations start with only "[claude-mem] Recent context omitted because it exceeds the session output limit." The timeline and the "Work state, still open" section never reach the model.
Cause: the context cache holds bodies rendered for the full 10,000 character budget, without the current session's notice reserve. The SessionStart handler read such a body whenever it fit the raw limit, and composeSessionStartContext then dropped the whole body against the reserve-adjusted room (about 7,949 characters with about 2,049 characters of notices in the report).
Fix: the cached read now re-validates the body against the reserve-adjusted room, through one shared definition. A new sessionStartBodyRoom helper computes the room the notices leave, and both the cached read and composeSessionStartContext use it. A body rendered for the full budget that does not fit the current room is a cache miss, and the hook falls through to the live fetch, which re-renders it with the current reserve. Bodies that fit are still served from cache. Nothing is cut to fit.
Tests: handler-level regression tests in tests/cli/handlers/context-session-start.test.ts. A 9,361 character cached body with about 1,268 characters of notices is treated as a miss and fetched live with reserveChars, with no omission notice; a 5,000 character body under the same notices is still served from cache with no worker call. With the room check removed, the over-room test fails with exactly the reported omission output. The affected suites pass (90 tests across the SessionStart handler and context cache files), the root TypeScript check is clean, the hook-IO discipline check passes, and the bundle build passes.
Note: verification here is code-path plus handler-level repro, not a live Claude Code session start, which needs Claude Code plus the worker runtime.