Two changes to the compaction flow:
PreCompact: agent stores its summary with infer=False
on_pre_compact.sh now instructs the agent to call add_memory with
infer=False. The agent has full conversation context and writes a
structured summary; without infer=False the platform runs a second
LLM extraction pass over that summary, losing structure and
producing fragmented facts. With it, the structured text is
preserved verbatim. Same guidance added to mem0-mcp/SKILL.md so
the agent applies it to other already-extracted writes (decisions,
anti-patterns, conventions).
SessionStart-compact: capture the platform-generated summary
PreCompact fires BEFORE Claude Code generates its compact summary,
so the summary is unreachable from that hook. SessionStart-compact
fires AFTER, so a new background helper (capture_compact_summary.py)
reads the transcript at that point, finds the isCompactSummary=true
entry, and stores its content as a separate memory tagged
metadata.type=compact_summary. The post-compaction bootstrap text
now tells the agent to layer its recall queries across
session_state (its own pre-compact summary), compact_summary (the
platform's condensed view), and topical types like decision /
anti_pattern.
Net effect: three complementary memory types from one session
boundary, none of which used to be filterable or even captured
correctly.