Skip to main content

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ámetroTipoRequeridoDescripción
user_idstrOwner of the active session.
summarystrSummary 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) — always None for summaries.

Raises

  • ValueErrorsummary is empty or whitespace-only.

Examples

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

See also