fix(hooks): debounce redundant first-message recall (closes #561)#574
Open
Adarsh-031 wants to merge 1 commit into
Open
Conversation
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.
Summary
The UserPromptSubmit hook ran a full auto-recall (Memory load + embedding search) on the first message of every session, duplicating the recall SessionStart had just injected. This adds a one-shot, time-windowed debounce so the first prompt skips that redundant work.
Changes
_shared.pymark_recall_injected()/consume_recall_injected(),RECALL_MARKER_DIR, andTRUEMEMORY_RECALL_DEBOUNCE_SECONDS(default 60s)session_start.pyuser_prompt_submit.py_try_auto_recalltakessession_id; a fresh marker short-circuits before detection and the Memorytests/ingest/test_recall_debounce.pyThe debounce is one-shot (marker consumed on read) and self-cleaning, so only the first prompt after SessionStart is skipped; later prompts recall normally.
Test plan
pytest tests/ -q -m "not network"— 1062 passed, 14 skipped)ruff check)Notes
ruff checkmay flag a pre-existingF401(unusedimport pytest) intests/test_issue_566_forget_always_load.py. That already exists onmainand is unrelated to this PR — happy to fix it in a separate change if preferred.