Sessions, summaries, and maintenance
Session listing, conversation summaries, message linking, and deferred-processing operations from ShortTermMemory API reference. Signatures show types, keyword-only arguments (*), and defaults; they are reference declarations, not calls to execute directly.
Session operations (bolt)
list_sessions
List SessionInfo models with prefix, pagination, and ordering controls. There is no user_id parameter.
async def list_sessions(
*,
prefix: str | None=None,
limit: int=100,
offset: int=0,
order_by: Literal['created_at', 'updated_at', 'message_count']='updated_at',
order_dir: Literal['asc', 'desc']='desc',
) -> list[SessionInfo]: ...
| Parameter | Description |
|---|---|
|
Filter sessions by ID prefix (e.g., "lenny-podcast-" to match all podcast sessions) |
|
Maximum sessions to return |
|
Number of sessions to skip (for pagination) |
|
Field to order by ('created_at', 'updated_at', or 'message_count') |
|
Sort direction ('asc' or 'desc') |
clear_session
Delete the matching conversation and its messages, with all their relationships (including :MENTIONS); the mentioned entities stay. This is the supported session-clearing name; delete_session does not exist.
async def clear_session(session_id: str) -> None: ...
clear_session does not delete the session’s reasoning data. start_trace stores session_id on the trace but does not link the trace to the conversation, so the traces, steps, and tool calls recorded for the session remain. To remove them as well, delete the traces by session_id:
await client.short_term.clear_session(session_id)
await client.graph.execute_write(
"""
MATCH (rt:ReasoningTrace {session_id: $session_id})
OPTIONAL MATCH (rt)-[:HAS_STEP]->(rs:ReasoningStep)
OPTIONAL MATCH (rs)-[:USES_TOOL]->(tc:ToolCall)
DETACH DELETE rt, rs, tc
""",
{"session_id": session_id},
)
Conversation summaries (bolt)
get_conversation_summary
Return a ConversationSummary. An explicit sync/async summarizer(transcript) takes precedence. Otherwise the store uses the configured LLMProvider when available, or builds a basic summary from messages. Legacy LLMConfig is not supplied as the store’s default summarization provider by MemoryClient.
async def get_conversation_summary(
session_id: str,
*,
max_tokens: int=500,
include_entities: bool=True,
summarizer: Callable[[str], str | Awaitable[str]] | None=None,
) -> ConversationSummary: ...
| Parameter | Description |
|---|---|
|
Session to summarize |
|
Approximate max length of summary (used as hint for summarizer) |
|
Whether to include key entities in the result |
|
Custom synchronous function or async function accepting a transcript and returning a summary string. If omitted, use the store’s default LLMProvider when configured, otherwise a basic summary. |
There are no separate generate_summary or cached get_summary methods. Calling this operation generates a summary from the current conversation.
Message linking and deferred processing (bolt)
Messages are linked sequentially:
(Conversation)-[:FIRST_MESSAGE]->(Message1)
(Message1)-[:NEXT_MESSAGE]->(Message2)
migrate_message_links
Migrate existing messages to use :NEXT_MESSAGE and :FIRST_MESSAGE relationships.
async def migrate_message_links() -> dict[str, int]: ...
generate_embeddings_batch
Generate embeddings for messages that don’t have them.
async def generate_embeddings_batch(
session_id: str,
*,
batch_size: int=100,
on_progress: Callable[[int, int], None] | None=None,
) -> int: ...
| Parameter | Description |
|---|---|
|
Session to process |
|
Messages to process per batch |
|
Progress callback (processed_count, total_count) |
extract_entities_from_session
Extract entities and relations from all messages in a session.
async def extract_entities_from_session(
session_id: str,
*,
batch_size: int=50,
skip_existing: bool=True,
extract_relations: bool=True,
on_progress: Callable[[int, int], None] | None=None,
user_identifier: str | None=None,
) -> dict[str, int]: ...
| Parameter | Description |
|---|---|
|
Session to process |
|
Messages to process per batch |
|
Skip messages that already have entity links ( |
|
Whether to also extract and store relations between entities |
|
Progress callback (processed_count, total_count) |
|
Tenant the messages belong to; scopes resolution candidates when |
Returns a dict with messages_processed, entities_extracted, entities_created, entities_merged and relations_extracted. entities_extracted counts mentions; with ingest-time resolution on, several mentions can resolve onto one node, so entities_created and entities_merged report what was written.
Models
SessionInfo
Fields and defaults:
| Field | Type | Default | Description |
|---|---|---|---|
|
|
|
Session identifier |
|
|
|
Session title |
|
|
|
When the session was created |
|
|
|
When the session was last updated |
|
|
|
Number of messages in the session |
|
|
|
Preview of the first message (truncated) |
|
|
|
Preview of the last message (truncated) |
ConversationSummary
Fields and defaults:
| Field | Type | Default | Description |
|---|---|---|---|
|
|
|
Session identifier |
|
|
|
Generated summary text |
|
|
|
Number of messages summarized |
|
|
|
Time range of messages (first, last) |
|
|
|
Key entities mentioned in the conversation |
|
|
|
Key topics discussed |
|
|
|
When summary was generated |