github alexgreensh/token-optimizer v5.0.5
v5.0.5 — hook responsiveness + atomic checkpoint writes

latest releases: openclaw-v2.4.1, v5.6.4, v5.6.2...
21 days ago

v5.0.5 — hook responsiveness + atomic checkpoint writes

Two reliability improvements to the Token Optimizer hook runtime.

Hook responsiveness

SessionStart and UserPromptSubmit hook handlers now run inside an internal wall-clock budget and exit gracefully if they cannot complete within 8 seconds. The ensure-health SessionStart hook also runs asynchronously with a 15-second outer timeout, keeping /compact and new sessions snappy even on busy machines. The guard saves and restores the prior SIGALRM handler so test runners that install their own are not clobbered.

Atomic checkpoint writes

compact_capture now writes checkpoint markdown files atomically via tempfile.mkstemp + os.replace, matching the pattern already used for quality cache and settings writes. A try/finally sentinel ensures the temp file is cleaned up even when the wall-clock guard fires mid-write, so compact_restore can never surface a partial file as authoritative recovery context.

Other improvements

  • --trigger argument to compact-capture is sanitized before it flows into the checkpoint filename
  • list_checkpoints filters in-flight atomic-write dotfiles so they cannot be enumerated
  • cleanupPeriodDays is now the first task in ensure-health, guaranteed to complete before any slower path can exhaust the budget
  • _write_settings_atomic and _write_quality_cache use the same try/finally + sentinel pattern for consistent cleanup under any exception

No signal math, scoring, or storage layout changes. Rollback via git revert returns to v5.0.4 behavior cleanly.

Don't miss a new token-optimizer release

NewReleases is sending notifications on new releases.