github yvgude/lean-ctx v2.20.0

latest releases: v3.9.8, v3.9.7, v3.9.6...
3 months ago

Sandbox Execution, Progressive Throttling, Compaction Recovery

Added — Sandbox Code Execution

  • ctx_execute — New MCP tool that runs code in 11 languages (JavaScript, TypeScript, Python, Shell, Ruby, Go, Rust, PHP, Perl, R, Elixir) in an isolated subprocess. Only stdout enters the context window — raw data never leaves the sandbox. Supports action=batch for multiple scripts in one call, and action=file to process files in sandbox with auto-detected language.
  • Smart truncation — Large outputs (>32 KB) are truncated with head (60%) + tail (40%) preservation, keeping both setup context and error messages visible.
  • LEAN_CTX_SANDBOX=1 env — Set in all sandbox processes for detection by user code.
  • Timeout support — Default 30s, configurable per-call.

Added — Progressive Throttling (Loop Detection)

  • Automatic agent loop detection — Tracks tool call fingerprints within a 5-minute sliding window. Calls 1-3: normal. Calls 4-8: reduced results + warning. Calls 9-12: stronger warning. Calls 13+: blocked with suggestion to use ctx_batch_execute or vary approach.
  • Deterministic fingerprinting — JSON args are canonicalized (key-sorted) before hashing, so {path: "a", mode: "b"} and {mode: "b", path: "a"} are treated as the same call.
  • Per-tool tracking — Different tools with different args are tracked independently.

Added — Compaction Recovery

  • ctx_session(action=snapshot) — Builds a priority-tiered XML snapshot (~2 KB max) of the current session state including task, modified files, decisions, findings, progress, test results, and stats. Saved to ~/.lean-ctx/sessions/{id}_snapshot.txt.
  • ctx_session(action=restore) — Rebuilds session state from the most recent compaction snapshot. When the context window fills up and the agent compacts, the snapshot allows seamless continuation.
  • Priority tiers — Task and files (P1) are always included. Decisions and findings (P2) next. Tests, next steps, and stats (P3/P4) are dropped first if the 2 KB budget is tight.

Upgrade

cargo install lean-ctx          # or
npm update -g lean-ctx-bin      # or
brew upgrade lean-ctx

Full Changelog: v2.20.0...v2.20.0

Don't miss a new lean-ctx release

NewReleases is sending notifications on new releases.