mem_session_summary
Signature
mem.mem_session_summary(user_id: str, summary: str) -> SaveResult
Creates a type="summary" observation linked to the active session and persists it. Does NOT close the session — the session keeps running and last_activity_at is touched.
This is the right call when you want to checkpoint the conversation context (e.g., before a likely compaction) but the user is not done.
note
type="summary" is reserved — it cannot be passed to mem_save. This method is the only producer of summary observations.
Parameters
| Parámetro | Tipo | Requerido | Descripción |
|---|---|---|---|
user_id | str | sí | Owner of the active session. |
summary | str | sí | Summary text persisted as a type="summary" observation. Must be non-empty. The observation title is auto-derived: summary[:80] if short enough, else summary[:77] + "...". |
Returns
SaveResult (frozen Pydantic model):
id(int) — observation id.outcome(Literal["created", "updated", "deduped"]).session_id(str) — the active session this summary belongs to.topic_key(str | None) — alwaysNonefor summaries.
Raises
ValueError—summaryis empty or whitespace-only.
Examples
- Mid-session checkpoint
- Structured checkpoint before compaction
result = mem.mem_session_summary(
user_id="alice",
summary="Halfway through the auth refactor — login works, logout pending.",
)
print(result.id, result.outcome) # e.g. 42, "created"
# session is still active — keep working
checkpoint = """
## Goal
Refactor auth flow.
## Accomplished
- Login endpoint migrated to async.
## Next Steps
- Migrate logout + add CSRF tests.
## Relevant Files
- src/auth/routes.py
""".strip()
mem.mem_session_summary(user_id="alice", summary=checkpoint)