ShortTermMemory API reference
Conversation and message operations exposed through client.short_term. Signatures in the bolt sections describe ShortTermMemory; the NAMS table identifies hosted differences.
Signatures below show types, keyword-only arguments (*), and defaults. They are reference declarations; the examples show calls to execute.
See Backend capabilities for availability and data scope. This page is a short overview and index; each subsystem has its own page.
Overview
message = await client.short_term.add_message(
session_id="example", role="user", content="Hello, world!"
)
conversation = await client.short_term.get_conversation("example")
for stored in conversation.messages:
print(stored.role.value, stored.content)
The example uses bolt, where a session name can create a conversation implicitly. On NAMS, call create_conversation first and use its returned ID.
On this subsystem
-
Conversation and message operations —
add_message,add_messages_batch,get_conversation,delete_message, the NAMS conversation operations (create_conversation,list_conversations,bulk_add_messages,get_observations,get_reflections,get_extraction_status), and theMessage/Conversation/ExtractionStatusmodels. -
Message search and context —
search_messagesandget_context. -
Sessions, summaries, and maintenance —
list_sessions,clear_session,get_conversation_summary,migrate_message_links,generate_embeddings_batch,extract_entities_from_session, and theSessionInfo/ConversationSummarymodels.
Constructor
Bolt only. MemoryClient builds this store for you and passes its resolved ontology, validation mode, resolver, and settings.resolution; the signature matters when you construct the store directly.
def ShortTermMemory(
client: Neo4jClient,
embedder: Embedder | None=None,
extractor: EntityExtractor | None=None,
*,
multi_tenant: bool=False,
default_llm_provider: LLMProvider | None=None,
ontology: OntologyDocument | None=None,
validation_mode: Literal['permissive', 'strict']='permissive',
resolver: EntityResolver | None=None,
resolution_config: ResolutionConfig | None=None,
): ...
| Parameter | Description |
|---|---|
|
Connected Neo4j client. |
|
Optional embedder for message embeddings and extracted entity names. |
|
Optional entity extractor. |
|
When True, writes require |
|
Optional LLM provider used by |
|
The effective ontology. Extracted relations the ontology does not permit are dropped before storage, in either validation mode. |
|
|
|
Resolver for the ingestion path. Only an |
|
Resolution settings. |
Entity extraction on ingest
When an extractor is configured, add_message, add_messages_batch, and extract_entities_from_session persist entities through one path. Since 0.7 it:
-
filters invalid entity names (stopwords, bare numbers, single characters),
-
enforces the ontology: it always drops forbidden relations, and in
strictmode also drops undeclared entities, -
embeds the mention names in one batch when an embedder is configured, so new entities are searchable and resolution reuses the vectors,
-
resolves the message’s mentions as one episode, when
resolution.resolve_on_ingestis True and the resolver is anOntologyResolver, and -
writes each mention by its band:
mergedreuses the matched node and appends the surface form to itsaliases;reviewcreates the node plus a pendingSAME_ASedge to the match, whichlong_term.find_potential_duplicatesreturns;createdcreates the node.
Each MENTIONS edge points at the entity id the database holds, including when the entity MERGE matched a pre-existing node. A resolution failure is logged and the mentions are stored unresolved; resolution never blocks the write. See Tune entity resolution and Resolution configuration.