Skip to main content
A session is a local index you read and write in real time, with no cloud round trip on any operation. Sessions are how Moss indexes data during a live interaction - indexing transcript turns mid-call, building a per-user working set, or accumulating context that is handed off between agents. A session is a SessionIndex, created from client.session(). It works with a client built with either a projectKey or a custom authenticator (the session authenticates through the same bridge as loadIndex).

Create or resume

client.session(name) returns a SessionIndex. If a cloud index with that name already exists it auto-loads into the session (no re-embedding); otherwise the session starts empty. The workflow is identical in both cases, and name is also the target when pushIndex() is called.

Short-term vs. long-term context

A session is short-term context - the working set for the current interaction. A persistent cloud index loaded with client.loadIndex() is long-term context - durable knowledge shared across interactions. Most real-time apps query both: load a cloud index for long-term knowledge, open a session for the live turns, and query each.

Loading a cloud index into a session

A session can also pull an existing cloud index into its local store with loadIndex(). With autoRefresh: true the SDK polls the cloud and pulls newer versions in on subsequent reads (paused while the session has un-pushed local edits).

Behavior notes

  • Every session operation (addDocs, deleteDocs, getDocs, query) runs in process memory with no per-operation cloud round trip.
  • The embedding model is set by the optional second argument to session() (default "moss-minilm"; also "moss-mediumlm" or "custom"). When resuming an existing cloud index, omit the model to adopt the stored one - all participants resuming the same index must use the same model.
  • With modelId: 'custom', each added document must carry an embedding and every query must pass an embedding. See Custom embeddings.
  • pushIndex() uploads documents with their locally-computed embeddings; no server-side re-embedding occurs.