Threads
Working with threads from code.
Threads open by themselves, so most code never touches
them. They matter when you want to bias retrieval toward current work, or show
someone what they were doing.
Listing
const { threads } = await hm.sessions({ limit: 5 });
for (const s of threads) {
console.log(s.title, s.memoryCount, s.status);
}
| | |
| --- | --- |
| status | active or closed |
| limit | Default 50 |
Resuming
const { payload } = await hm.resumeSession(threads[0].id);
Returns what was established during that thread, in the order it happened,
which is a different question from "what is relevant to this query", and one
ordinary search cannot answer.
Biasing retrieval
await hm.recall({ q: "what did we decide about retries?", threadId: current });
Memories from that thread are boosted, not filtered to. Current work wins
ties; older context still surfaces when it is genuinely the better answer.
Grouping your own conversations
If your app has its own conversation ids, pass one as externalRef and it maps
to a thread:
await hm.remember({ content: "…", externalRef: `chat:${conversationId}` });
await hm.recall({ q: "…", externalRef: `chat:${conversationId}` });
Returning to that conversation weeks later rejoins the same thread rather than
opening a new one.