pi-memory icon indicating copy to clipboard operation
pi-memory copied to clipboard

Extensions seems to miscalculate user message count?

Open JohannesKlauss opened this issue 7 months ago • 5 comments

I tried to manually consolidate the memory, because it didn't to it by itself, but it failed saying it needs at lease 2 user messages. But I have 5 from the subtree to the top:

Image

Maybe missed something in the set up?

JohannesKlauss avatar Apr 23 '26 12:04 JohannesKlauss

Root cause: pendingUserMessages was only populated from live agent_end events during the current process. When resuming a session (or forking a branch), historical messages are restored from the session file but agent_end never fires for them — so /memory-consolidate and auto-consolidation on shutdown always saw 0 user messages regardless of conversation length.

Fix (5129d15): On session_start, seed pendingUserMessages and pendingAssistantMessages from the existing session branch via ctx.sessionManager.getBranch(). New messages from agent_end continue to append as before.

samfoy avatar Apr 23 '26 18:04 samfoy

I'm not sure if this is the same issue with pi-knowledge-base, but I'm using it as part of the pi-total-recall package and updating it to 1.0.1 doesn't get rid of the error

JohannesKlauss avatar Apr 24 '26 07:04 JohannesKlauss

@JohannesKlauss Thanks for the ping — you were right that 1.0.1 didn't fix it for you. The problem: pi-total-recall 1.0.1 bundled @samfp/[email protected] via bundledDependencies, so the fix in this repo never actually reached the tarball you installed.

Just published:

Please upgrade pi-total-recall to 1.0.2 and let me know if you still see the message count error. pi-knowledge-search is unaffected — it doesn't track pending messages.

Closing once you confirm.

samfoy avatar Apr 24 '26 13:04 samfoy

Leaving open pending user confirmation

samfoy avatar Apr 24 '26 13:04 samfoy

Now it's working thank you!

JohannesKlauss avatar Apr 24 '26 14:04 JohannesKlauss