Skip to documentation
Docs navigation
Docs/getTopics()
MemoGrafter

getTopics()

Read topics and segments for a session.

What it does

Read topics and segments for a session.

When to use it

Use when an application-managed service needs topic nodes and their segmentation ranges for a particular session.

Signature

TypeScript
getTopics(sessionId: string, options?: TagFilterOptions): Promise<{ nodes: TopicNode[]; segments: TopicSegment[] }>

Parameters

sessionId (string) — The application-owned session whose memory should be read or changed.
options? (TagFilterOptions) — A typed options object. The applicable fields and defaults are documented below.

TagFilterOptions fields

tags? (string[]) — Tags to match. Omit this field to avoid tag filtering.
tagMode? ("all" | "any", default "all") — Require every supplied tag or at least one supplied tag.
scope? ("session" | "session-and-tags" | "tagged", default "session") — Keep reads in the selected session, combine the session with tagged sessions, or search tagged sessions across session boundaries.
sessionIds? (string[]) — Explicitly constrain cross-session operations. It has no effect on APIs that are strictly current-session scoped.
includeSuppressed? (boolean, default false) — Include suppressed topic nodes.
includeForgotten? (boolean, default false) — Include forgotten memories where the operation returns or evaluates memories.

TopicNode fields

id, sessionId, and segmentId identify the topic and its owning session/segment.
label is the short extracted topic name; summary is its generated description.
messageRange is the inclusive source-message index range; topicOrder is its position in the session.
driftScore records the topic-boundary signal. embedding is the stored semantic vector and can be large.
tags and source preserve caller metadata.
suppressed and suppressedAt describe topic lifecycle state.
agentColor, fleetId, and agentId are populated for fleet-owned topics and otherwise are null.
createdAt is a JavaScript Date when read through the package API.

Result

The topic nodes created, selected, or copied by the operation.

Behavior

Applies topic filters to nodes; segments are read for the supplied session and are not tag-filtered.

Side effects and completion

Read-only.

Example

example.ts
const { nodes, segments } = await memo.getTopics("session-1");