Skip to Content

extractFacts

extractFacts(messages: AutoExtractMessage[], options: ExtractFactsOptions): Promise<ExtractedCandidate[]>

Defined in: src/lib/memory/autoExtract.ts:390 

Stage 1 — call the LLM to extract candidate facts from the recent conversation. Returns post-validated candidates only (confidence threshold, source-id check, length cap, schema validation). Returns an empty array if the LLM emits malformed JSON or no candidates.

A null from callPortalJsonCompletion means a failure (empty completion, malformed JSON, network/HTTP error) — distinct from a successful {candidates: []}, which parses to a non-null object. A failed extraction silently drops the whole turn’s memories, so transient failures matter: callPortalJsonCompletion retries them internally with backoff (default 3 attempts), so a one-off empty/malformed completion from a reasoning-class model doesn’t lose the turn. Only an exhausted-retry null reaches here.

Parameters

ParameterType

messages

AutoExtractMessage[]

options

ExtractFactsOptions

Returns

Promise<ExtractedCandidate[]>

Last updated on