feat: configurable auto-save interval with independent precompact control#804
Open
rusel95 wants to merge 1 commit intoMemPalace:developfrom
Open
feat: configurable auto-save interval with independent precompact control#804rusel95 wants to merge 1 commit intoMemPalace:developfrom
rusel95 wants to merge 1 commit 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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