[Bug]: Resume snapshot ignores byte budget — advertises <2KB, injects ~196KB
Description
buildResumeSnapshot in src/session/snapshot.ts accepts a maxBytes parameter but never reads it — the function body has a comment // maxBytes ... IGNORED at line 30. The errors, git, and subagents sections iterate ALL events with no truncation. The precompact hook (hooks/precompact.mjs:7) advertises <2KB XML but calls buildResumeSnapshot without passing maxBytes, then stores the result verbatim via upsertResume.
To Reproduce
git clone https://github.com/mksglu/context-mode
cd context-mode && npm install
git checkout 589d8214 # verified version
# Minimal repro: 5 error events × 40KB each
node -e "
const { buildResumeSnapshot } = require('./src/session/snapshot.ts');
const events = Array.from({length: 5}, (_, i) => ({
type: 'error',
data: { message: 'E'.repeat(40000), timestamp: Date.now() + i }
}));
const snapshot = buildResumeSnapshot({ events });
console.log('snapshot size:', snapshot.length, 'bytes');
console.log('advertised budget: <2KB');
console.log('ratio:', (snapshot.length / 2048).toFixed(1) + 'x');
// Assert: snapshot > 100KB despite maxBytes being a parameter
"
# Expected: ~200,862 bytes (196 KB), ~98x the advertised <2KB
Expected Behavior
The maxBytes parameter should cap the snapshot size, or the <2KB claim in precompact.mjs should be removed.
Actual Behavior
maxBytes is accepted but explicitly ignored (// IGNORED in source). All error/git/subagent events are included verbatim with no truncation.
Additional Context
- The fix pattern already exists in-repo:
files (MAX_ACTIVE_FILES=10) and recent_user_messages (400 chars × 3) DO enforce caps in the same file.
- This was verified against commit
589d8214 (v1.0.169) on 2026-07-28.
- Happy to submit a PR if the maintainers are open to it.
[Bug]: Resume snapshot ignores byte budget — advertises <2KB, injects ~196KB
Description
buildResumeSnapshotinsrc/session/snapshot.tsaccepts amaxBytesparameter but never reads it — the function body has a comment// maxBytes ... IGNOREDat line 30. The errors, git, and subagents sections iterate ALL events with no truncation. Theprecompacthook (hooks/precompact.mjs:7) advertises<2KB XMLbut callsbuildResumeSnapshotwithout passingmaxBytes, then stores the result verbatim viaupsertResume.To Reproduce
Expected Behavior
The
maxBytesparameter should cap the snapshot size, or the<2KBclaim inprecompact.mjsshould be removed.Actual Behavior
maxBytesis accepted but explicitly ignored (// IGNOREDin source). All error/git/subagent events are included verbatim with no truncation.Additional Context
files(MAX_ACTIVE_FILES=10) andrecent_user_messages(400 chars × 3) DO enforce caps in the same file.589d8214(v1.0.169) on 2026-07-28.