Skip to main content

Conversation history

A Cortex run uses one canonical executable transcript. Agent input/output, registered tool phases and retained artifact/media references belong to that transcript. Local UI messages are a rendering projection.

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

export async function readHistory(client: CortexRuntimeClient, conversationId: string) {
const first = await client.messages(conversationId, { limit: 100 });
if (first.isDone || first.continueCursor === null) return first.page;
const next = await client.messages(conversationId, { cursor: first.continueCursor });
return [...first.page, ...next.page];
}

Continue pagination until isDone; the example illustrates the first two pages. listConversations() returns authorized metadata, including manualWriteLocked, requireApproval, historyRevision, epoch and retention.

Controlled manual changes​

Administrators select the write lock and approval policy through guarded runtimeTranscript:setPolicy. Unlocked append, edit and removeMessage requests carry the expected history revision. Stale revisions conflict rather than overwriting another edit. Edits remain tracked; pending/unapproved or failed history does not become ordinary model context.

Source revisions and hashes bind downstream facts/chunks/vectors and context witnesses. Rebuilding the Agent projection uses canonical current history. A stale background result cannot reintroduce removed messages.

Recovery and access​

Use attach(runId) and retained output cursors to observe an existing run. Reconstruct history from authorized transcript pages after reload. Run/conversation IDs, local snapshots and share selectors confer no authority.

Deletion and retention fence runs and dependent derivations with epochs/tombstones. Read/export/fork/admin operations are checked under current grants. The separate lower-level conversation API is available for explicit domain use; it is not a second transcript for runtime turns.