fix(plugin): expire stale state captures + document plugin-update restart
Memory expiration + recency
Hook-side captures (session_state in on_pre_compact.py and
compact_summary in capture_compact_summary.py) now set
expiration_date = today + 90 days. These types describe a single
moment of project state and become stale clutter after a quarter.
Durable types written by the agent (decision, anti_pattern,
convention, user_preference, task_learning, environmental) stay
unexpired by design -- a decision from a year ago is still a
decision.
Skill updated with two new sections:
- "Expiration: high-churn vs durable" -- table mapping each
metadata.type to whether it should carry an expiration_date.
- "Recency filter on recall" -- agent should layer a
created_at >= <90 days ago> filter on recall when the user
asks about *current* state, and skip it when looking for
durable facts.
Plugin-update / MCP reconnect
When the plugin updates, the MCP server connection in the running
client goes stale -- there's no in-process reconnection path from
inside the plugin. Documenting the workaround is the realistic
fix: README now has an "Updating the plugin" section explaining
/restart (Claude Code), quit-and-relaunch (Cursor), restart
(Codex). The auth header re-reads MEM0_API_KEY from the new
shell, so users don't have to re-enter the key.
This commit is contained in:
@@ -99,6 +99,28 @@ Extract key learnings and store them using the `add_memory` tool:
|
||||
|
||||
> `metadata.type` (which you set explicitly) and `categories` (which the platform auto-tags after the project's custom-category list — see `scripts/setup_coding_categories.py`) are complementary. Always set `metadata.type` for explicit filtering; the platform fills in `categories` on its own. Don't try to set `categories` on `add_memory` calls — per-request overrides aren't supported on the managed API.
|
||||
|
||||
### Expiration: high-churn vs durable
|
||||
|
||||
Some memory types are state snapshots that go stale fast; others are durable facts that should outlive the session that created them. Mark the difference with `expiration_date` on writes.
|
||||
|
||||
| Type | Expiration | Why |
|
||||
|---|---|---|
|
||||
| `session_state`, `compact_summary` | `expiration_date` ≈ today + 90 days | Describe a single moment of project state. Useless after a quarter; clutter the recall surface. |
|
||||
| `decision`, `anti_pattern`, `convention`, `user_preference`, `task_learning`, `environmental` | omit `expiration_date` | Durable facts. A decision made last year is still a decision; same for a convention or a user preference. |
|
||||
|
||||
`add_memory` accepts `expiration_date` as a string (`"YYYY-MM-DD"`). The two server-side hooks (`on_pre_compact.py`, `capture_compact_summary.py`) already set this for the types they write. When you write directly via the MCP tool, follow the same rule.
|
||||
|
||||
### Recency filter on recall
|
||||
|
||||
When the user is asking about *current* state ("where were we", "what's the active task", "the latest decision on X"), filter recall to recent memories so stale snapshots don't surface:
|
||||
|
||||
```python
|
||||
# Last 90 days only
|
||||
{"AND": [{"user_id": "<id>"}, {"metadata": {"type": "session_state"}}, {"created_at": {"gte": "<90 days ago, YYYY-MM-DD>"}}]}
|
||||
```
|
||||
|
||||
Skip the recency filter when the user is asking about durable facts ("what conventions does this project use", "have we hit this bug before") — those are timeless and recency would hide them.
|
||||
|
||||
Memories can be as detailed as needed -- include full context, reasoning, code snippets, file paths, and examples. Longer, searchable memories are more valuable than vague one-liners.
|
||||
|
||||
### Use `infer=False` for already-structured content
|
||||
|
||||
Reference in New Issue
Block a user