Repository navigation
Description
Description
SessionStart's "read the handoff, then immediately truncate it" step (session-start-hook.sh) has no way to tell a real interactive session from a short-lived scheduled/headless one sharing the same project directory. When a scheduled task (Claude Code's own cron-style scheduled-task feature) opens a session in a project between two interactive sessions, it silently consumes and clears remember.md — the pending handoff meant for the next real session — and never replaces it, because its task never calls /remember. The file is left at 0 bytes until some later interactive session happens to write a fresh handoff, with no warning anywhere that this happened.
This isn't about a misbehaving scheduled task — the task in question is deliberately read-only and has no reason to know about the memory plugin at all. The defect is that SessionStart fires the same consume-clear for it as for any other session.
Reproduction
Steps to reproduce:
- Set up any Claude Code scheduled task (
create_scheduled_task/ cron) whose prompt operates inside a project directory that also has an interactive Claude Code memory store (legacy mode:{project}/.remember/remember.md). - Have an interactive session in that project end with a
/remembercall, writing a real handoff toremember.md. - Let the scheduled task fire before you start your next interactive session there (cron will do this on its own if the interval is short relative to how often you work in that project).
- Open your next interactive session in that project.
Minimal illustration, from session-start-hook.sh:
if [ -f "$REMEMBER_HANDOFF" ] && [ -s "$REMEMBER_HANDOFF" ]; then
echo "=== LAST HANDOFF ==="
cat "$REMEMBER_HANDOFF"
echo ""
: > "$REMEMBER_HANDOFF" # <-- unconditional, runs for every SessionStart
fiThis is registered for every SessionStart, with no signal available to distinguish who/what is starting the session.
Expected behavior
Either: the consume-clear should not fire for a session that has no intention of ever writing a new handoff back (some non-interactive/scheduled marker), or there should be some mitigation (e.g. don't truncate until a new handoff is actually written, or preserve the previous one until a fresh one lands) so a scheduled task passing through can't destroy a pending handoff meant for a human session.
Actual behavior
Confirmed via this project's own hook logs (.remember/logs/memory-YYYY-MM-DD.log), which record PROJECT_DIR at the moment SessionStart fires — i.e. before any prompt content, including a cd, ever executes:
12:55:17 [hook] session-start: PROJECT_DIR=/path/to/project ...
This timestamp lines up exactly with our scheduled task's cron fire time (and with when the empty remember.md was independently noticed). The task's own prompt is read-only and never mentions /remember or memory at all — it doesn't need to and shouldn't have to. remember.md was 0 bytes from that moment until the next interactive session ran /remember again.
Practical impact is bounded — the durable memory (now.md/today-*.md/recent.md/archive.md) is a separate, automatic pipeline and is untouched by this. Only the single-slot remember.md handoff is at risk, and content that was also discussed in the conversation itself usually survives via that separate pipeline. But any handoff nuance that only existed in the /remember synthesis — not spoken aloud in the session — is genuinely and silently lost.
Environment
- claude-remember version: 0.8.6 (reproduced there; read through 0.8.7/0.8.8/0.9.0 changelogs and found no related fix)
- Claude Code version: 2.1.215
- Shell: zsh
- OS: macOS (Darwin 25.5.0)
- Python version: 3.9.6
Activity
fdaviddpt commentedon Jul 29, 2026
Confirmed and reproduced in the code — thanks for the log-timestamp evidence, that is what makes the cron correlation checkable rather than inferred.
The mechanism is exactly as you describe.
scripts/session-start-hook.sh(currentmain, lines 272-277):No guard, and
SessionStarthas no signal distinguishing a session that will write a handoff back from one that never will. Your framing of the scope is right too: the durable pipeline is untouched, so this is bounded to the single-slot handoff — but that slot holds the synthesis, which is precisely the part that only exists there.One note on the direction, since your Expected Behaviour offers two: we are weighing them as genuinely different, not interchangeable. Detecting the non-interactive session is a guess about who is starting it, and a guess that errs in the unsafe direction destroys data silently — the bug itself. Not truncating until a replacement has actually been written needs no detection at all and cannot lose a handoff regardless of who passes through. The hazard it introduces is the opposite one: a handoff re-delivered forever with no way to tell it from a fresh one, which would be the same class of silent lie pointing the other way. That trade is what is being designed now.
Worth noting for the record: this repo already has
REMEMBER_NESTED_SUMMARIZER(#202/#205) as a positive marker for "a non-interactive session is firing my own hooks" — but it covers only the plugin own nested Haiku call, not an arbitrary scheduled task. So the first direction is not unavailable, just narrower than it looks.Work is in progress; the PR will reference this issue. Your report was actionable as filed and needed no clarification.
fix(session-start): preserve the handoff until a replacement lands (#221
fdaviddpt commentedon Jul 29, 2026
Fixed and merged —
fc97f08, released in the next cut.We went with your second Expected Behaviour (preserve until a replacement lands) rather than the first (detect the non-interactive session), and the reason is worth recording because your report framed it as a choice between two fixes: the first turns out not to be a worse fix but an unbuildable one. This repo does have a marker of that shape —
REMEMBER_NESTED_SUMMARIZER, set on the plugin own nestedclaude -pchild and checked inresolve-paths.sh— but it is a positive marker the plugin sets on something it spawns. An arbitrary scheduled task sets nothing, and there is no negative test for "this session will write a handoff back". Extending it would mean inventing a heuristic, and a heuristic wrong in the unsafe direction destroys data silently, which is the defect you reported. The only lever available atSessionStartis when to discard, never who is asking.So nothing is discarded until a replacement lands.
/rememberoverwrites the same path, and the new content is what retires the old.That introduces the opposite hazard — the same note delivered repeatedly, reading as fresh — so a small record (
remember.delivered: content fingerprint, first-delivery timestamp, count) sits beside the slot, and any re-delivery of already-delivered content is labelled as such:Deliberately unbounded: capping the re-delivery would mean preserving the handoff and then never surfacing it, which converts a visible loss back into an invisible one. The noise is the loud failure, and it is the one worth having.
Your scoping was right and saved time — the durable pipeline is untouched, so this was always bounded to the single-slot handoff. But that slot holds the
/remembersynthesis, which is exactly the content that exists nowhere else, so "bounded" was not the same as "minor".Thank you for the hook-log timestamps in particular.
PROJECT_DIRrecorded atSessionStart— before any prompt content runs — is what made the cron correlation checkable rather than inferred, and it is why this needed no clarifying round trip.Per-session handoff files stop two interactive sessions from clobberi…
Prune stale per-session delivery records; keep session-start-hook.sh'…