Skip to content

fix(hooks): debounce redundant first-message recall (closes #561)#574

Open
Adarsh-031 wants to merge 1 commit into
buildingjoshbetter:mainfrom
Adarsh-031:fix/561-user-prompt-submit-first-message-latency
Open

fix(hooks): debounce redundant first-message recall (closes #561)#574
Adarsh-031 wants to merge 1 commit into
buildingjoshbetter:mainfrom
Adarsh-031:fix/561-user-prompt-submit-first-message-latency

Conversation

@Adarsh-031

Copy link
Copy Markdown

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

File Change
_shared.py Add mark_recall_injected() / consume_recall_injected(), RECALL_MARKER_DIR, and
TRUEMEMORY_RECALL_DEBOUNCE_SECONDS (default 60s)
session_start.py Write the per-session marker after normal-run recall
user_prompt_submit.py _try_auto_recall takes session_id; a fresh marker short-circuits before detection and the Memory
load
tests/ingest/test_recall_debounce.py New: marker semantics + gate short-circuit (9 tests)

The 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

  • All tests pass (pytest tests/ -q -m "not network" — 1062 passed, 14 skipped)
  • Lint clean on changed files (ruff check)

Notes

  • A pre-warmed daemon/Unix socket to remove the ~90ms interpreter cold start is intentionally out of scope here; worth a separate issue.
  • For reviewers: CI's repo-wide ruff check may flag a pre-existing F401 (unused import pytest) in
    tests/test_issue_566_forget_always_load.py. That already exists on main and is unrelated to this PR — happy to fix it in a separate change if preferred.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant