Performance and token optimization release. Reduces per-session overhead by up to 64%.
Added
LEAN_CTX_NO_CHECKPOINTenv var — disable auto-checkpoint injection independently fromminimal_overheadPreparedSavepattern —Session.save()split intoprepare_save()(CPU-only serialization under lock) +write_to_disk()(background I/O viatokio::task::spawn_blocking), removing disk I/O from the tool response hot pathmd5_hex_fast— 8x faster fingerprinting for outputs >16 KB by hashing prefix + suffix + length instead of full content- Benchmark tests — 8 new tests covering token overhead budgets, cache effectiveness, compression density, session save latency, and MD5 performance
Changed
count_tokenscalled once per tool response (was up to 4x) — cached result reused for hints, cost attribution, and loggingCostStorewrites deferred to background thread viaspawn_blockingmcp-live.jsonwrites debounced to every 5th tool call (80% fewer disk writes)compress_outputskipped entirely forNormaldensity (no string copy)- Auto-checkpoint, meta-strings (savings/stale notes, shell hints, archive hints), and session blocks now all suppressed under
minimal_overhead
Fixed
- Integer overflow crash in
shell_efficiency_hintwhen output tokens exceeded input tokens — now usessaturating_sub - Synchronous
save()restores retry counter on disk write failure, preserving auto-save semantics
Upgrade
lean-ctx update # recommended (auto-downloads + refreshes shell hooks)
cargo install lean-ctx # or
npm update -g lean-ctx-bin # or
brew upgrade lean-ctxNote: After upgrading via cargo/npm/brew, run
lean-ctx setupto refresh shell aliases.lean-ctx updatedoes this automatically.
Full Changelog: v3.4.1...v3.4.1