feat: configurable auto-save interval with independent precompact control#804
feat: configurable auto-save interval with independent precompact control#804rusel95 wants to merge 3 commits intoMemPalace:developfrom
Conversation
Replace hardcoded SAVE_INTERVAL=15 with user-configurable hooks.save_interval in config.json (0 = disabled, default 15). Env var MEMPALACE_HOOKS_SAVE_INTERVAL overrides config file. Separate precompact control via hooks.precompact (default true). Precompact is the last chance to save before context is lost — it should never be silently disabled alongside the stop hook. Shorten block reason messages to name exact MCP tools (mempalace_diary_write, mempalace_add_drawer) instead of generic "save to your memory system" instructions. Closes MemPalace#494. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Strong +1 on this. Hitting the pain point today on 3.3.0:
The design choice of keeping Would love to see this land. Happy to smoke-test against 3.3.0 if useful. |
|
Pushed cleanup (c2c2f6a):
Re-pinging because this PR addresses several now-filed bugsThe independent
With this PR:
Design note for @igorls @bensig @milla-jovovich: the two controls live in Happy to rebase or adjust naming (e.g. |
These Ukrainian-language files and PR_DEEP_DIVE.md were accidentally pulled into the PR via a local merge conflict resolution. They are personal notes, not part of the configurable hook interval feature. Added to .gitignore so they survive locally but stay out of PRs. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
c2c2f6a to
45b65ae
Compare
Closes #494
Summary
Replaces the hardcoded
SAVE_INTERVAL = 15with a user-configurablehooks.save_intervaland adds independenthooks.precompactcontrol. This is an alternative to #711 that provides granular frequency control instead of a binary on/off toggle.Why this is better than #711
auto_save: true/false— all or nothingsave_interval: 30— any frequency (0 = off)Config
save_interval15MEMPALACE_HOOKS_SAVE_INTERVAL0= disabledprecompacttrueMEMPALACE_HOOKS_PRECOMPACTKey design decision:
precompactdefaults totrueand is controlled separately. Settingsave_interval: 0disables periodic saves but precompact still fires before context is lost. This prevents the data loss scenario where #711'sauto_save: falsesilently disables both hooks.Changes
mempalace/config.pyhooks_save_intervalandhooks_precompactproperties with env var overridesmempalace/hooks_cli.pytests/test_config.pytests/test_hooks_cli.pyTest plan
test_hooks_save_interval_default— default is 15test_hooks_save_interval_from_config— reads from config.jsontest_hooks_save_interval_zero_disables— 0 disables stop hooktest_hooks_save_interval_env_override— env var overrides configtest_hooks_save_interval_env_zero— env var can set to 0test_hooks_save_interval_negative_clamped— negative clamped to 0test_hooks_precompact_default— default is truetest_hooks_precompact_disabled— can be disabled via configtest_hooks_precompact_env_override— env var overridestest_hooks_save_interval_and_precompact_independent— disabling one doesn't affect the othertest_stop_hook_disabled_by_zero_interval— stop hook passes throughtest_stop_hook_custom_interval— save_interval=5 triggers at 5 messagestest_stop_hook_custom_interval_not_reached— save_interval=50 doesn't trigger at 15test_precompact_disabled_by_config— precompact passes through when disabledtest_precompact_enabled_by_default— precompact blocks even when stop is disabledtest_stop_disabled_precompact_still_works— independence verified🤖 Generated with Claude Code