Skip to main content

Semantic search

The runtime performs a governed backend query embedding against the current managed profile and matching source/chunk/vector provenance. The app supplies a text query and stable request ID.

import type { CortexRuntimeClient } from '@cortexmemory/sdk/runtime';

export async function searchMemory(client: CortexRuntimeClient, requestId: string, query: string) {
const { profile } = await client.getEmbeddingProfile();
const result = await client.recall({
text: query,
requestId,
limit: 10,
});
return { profile, result };
}

Retain the request ID when recovering the same retrieval operation. Query embedding is a billable operation governed by embedding.query, its qualified interface and the shared policy/budget controls.

The result contains items, formatted context and profileId; items identify memory/fact content, score and provenance. Only currently authorized eligible sources participate. Stale revision/hash/profile generations are excluded.

Search reads indexed memory. Agent context can additionally consume eligible pending sources under its configured memory mode. For required freshness, use readiness and barriers.

expectedProfileId checks for mismatch; it does not change the index. See vector embeddings and the explicit memory API for separate low-level use cases.