Skip to Content

ExtractFactsOptions

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

Auth + endpoint for the extraction LLM call. Auth is the dual pattern — one of apiKey / getToken is required at runtime; see PortalLlmAuth.

Extends

Properties

apiKey?

optional apiKey: string

Defined in: src/lib/memory/portalLlm.ts:72 

Direct API key — sent as x-api-key (server-side / CLI usage). Wins when both are provided.

Inherited from

PortalLlmAuth.apiKey


backoffMs()?

optional backoffMs: (attempt: number) => number

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

Override the retry backoff (ms) for a given 1-based attempt index. The extraction call retries transient failures internally (default exponential backoff); pass () => 0 to retry without delay (useful for tests).

Parameters

ParameterType

attempt

number

Returns

number


baseUrl?

optional baseUrl: string

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


endpointOverride?

optional endpointOverride: string

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

Optional per-call request path override, forwarded to callPortalJsonCompletion. When set, the extraction call POSTs to baseUrl + endpointOverride instead of the default /api/v1/chat/completions. The body follows the transport, not the path: a model that needs the Responses API is moved from a .../chat/completions override to its sibling .../responses with a Responses-shaped body. Lets callers route this internal-utility pass to a dedicated endpoint. Invalid values throw at call time (see validateEndpointOverride).

Why this exists (anuma-ai/ai-memoryless-client#5536): auto-extraction is the highest-volume first-party background call in the product — one per extracting turn, on every platform — and it carries no flow fingerprint, so the portal’s freeloader detector classifies it as scripted abuse. In reject mode that 403s every basic-tier extraction, which surfaces here as onExhaustedEmpty → empty-after-retry and leaves free-tier vaults empty. TopicExtractOptions.endpointOverride already exists for the same reason on the topic pass; this is the fact pass catching up.

IMPORTANT — the utility endpoint clamps to a PRICE CEILING and never rejects, so pointing this at /api/v1/utility/chat/completions while the portal’s ceiling prices below DEFAULT_EXTRACTION_MODEL silently rewrites the model instead of 403-ing. That trades a visible failure for an invisible quality regression: raise PORTAL_UTILITY_CEILING_MODEL to at least the extraction model’s rate BEFORE setting this in a client.


fetchFn()?

optional fetchFn: {(input: RequestInfo | URL, init?: RequestInit): Promise<Response>; (input: string | Request | URL, init?: RequestInit): Promise<Response>; }

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

Override the global fetch implementation (useful for tests).

Call Signature

(input: RequestInfo | URL, init?: RequestInit): Promise<Response>

MDN Reference 

Parameters

ParameterType

input

RequestInfo | URL

init?

RequestInit

Returns

Promise<Response>

Call Signature

(input: string | Request | URL, init?: RequestInit): Promise<Response>

MDN Reference 

Parameters

ParameterType

input

string | Request | URL

init?

RequestInit

Returns

Promise<Response>


getToken()?

optional getToken: () => Promise<string | null>

Defined in: src/lib/memory/portalLlm.ts:74 

Function to get an auth token (e.g., Privy’s getIdentityToken). Token is sent as Authorization: Bearer.

Returns

Promise<string | null>

Inherited from

PortalLlmAuth.getToken


maxAttempts?

optional maxAttempts: number

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

Max attempts for the extraction call on a transient failure (default 3). Lower it to bound how long extraction can hold a turn open — e.g. a worker that runs extraction behind an in-flight-turn guard can pass 2 to keep repeated failures from delaying later turns.


model?

optional model: string

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


now?

optional now: number

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

Reference “now” (Unix ms) for resolving relative temporal phrases in the transcript (“yesterday”, “next week”, “in two days”) into the absolute YYYY-MM-DD anchors the W6 temporal lane indexes on. The transcript itself carries no timestamps, so without an anchor the model resolves relatives against its own training-cutoff guess and emits wrong eventTime dates. Defaults to Date.now(). Override for back-dated eval corpora and deterministic tests (mirrors RecallOptions.now).

Server-side timezone note: the ms value is formatted to a calendar date in the process’s local timezone (same basis as parseLocalCalendarDay). On a UTC server, a user near midnight in a non-UTC offset can get the wrong calendar day. Pass the user’s local-midnight timestamp as now when the process timezone doesn’t match the user’s.


onAttempt()?

optional onAttempt: (attempt: PortalLlmAttempt) => void

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

Per-attempt wire diagnostic, forwarded to callPortalJsonCompletion. The extraction eval gates on it (first-attempt clean rate); production callers may leave it unset.

Parameters

ParameterType

attempt

PortalLlmAttempt

Returns

void


onCandidatesDropped()?

optional onCandidatesDropped: () => void

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

Called when the extractor DID produce candidates but PII de-anonymization dropped every one of them — the model mangled its placeholders (so they can’t be restored to real values) or restoring the values blew the length cap. These drops happen before retain(), so failedCount can’t see them, and the turn would otherwise masquerade as a quiet no-facts result. Lets H3’s outcome surface dropped-after-redaction so a rising PII-drop rate (i.e. redaction silently eating facts) is alarmable.

Returns

void


onCandidatesParsed()?

optional onCandidatesParsed: (stats: object) => void

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

Fired once per successful completion with how many candidates the model emitted (rawCount) and how many survived validateCandidates (validCount) — the non-string / empty / over-cap / low-signal / bad- confidence drops that until now were a bare continue nobody counted.

Without it a no-facts turn cannot be split into “the model found nothing” and “the model found things we threw away”, which is the difference between a prompt problem and a validator problem. Counts only; never content.

Parameters

ParameterType

stats

object

stats.rawCount

number

stats.validCount

number

Returns

void


onExhaustedEmpty()?

optional onExhaustedEmpty: (failure: PortalLlmFailure) => void

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

Called when the extraction LLM returned no usable result after exhausting its retries (empty/malformed completion, network/HTTP error) — i.e. a failure that drops the turn’s facts, as opposed to a legitimate {candidates: []} “nothing durable here”. Lets callers distinguish a silently-degrading extractor from quiet turns (the two are otherwise indistinguishable). See extractAndRetain’s outcome.

Receives the classified PortalLlmFailure. Knowing THAT extraction failed was not enough: the 2026-08-11 audit found ~60% of production turns ending here and had to cross-check Prometheus to learn that the cause was HTTP-200-with-empty-body rather than the 403 everyone assumed. Forward failure.reason into analytics so the next such question is a query.

Parameters

ParameterType

failure

PortalLlmFailure

Returns

void


onTranscript()?

optional onTranscript: (stats: object) => void

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

Fired once per call with the size of the transcript sent to the model; counts only, never content.

Parameters

ParameterType

stats

object

stats.charCount

number

stats.messageCount

number

Returns

void


piiRedaction?

optional piiRedaction: boolean | PiiRedactor

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

When set, PII (emails, phones, SSNs, cards, IPs, API keys, …) in the conversation transcript is replaced with tagged placeholders before the extraction call, and the returned facts + entities are de-anonymized so the vault keeps the real values while raw PII never reaches the extraction model (and, via extractAndRetain, the consolidation model). Pass true for a fresh per-call redactor, or a shared PiiRedactor to keep placeholder numbering consistent with other calls.

NOTE: this does NOT cover the embeddings provider. Facts are stored and embedded with their real values, so to keep PII out of embedding requests set RetainContext.embeddingOptions.maskInput (e.g. redactor.maskText) as well — the two are independent switches.


profile?

optional profile: MemoryAppProfile

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

App profile adding extraction guidance to the system prompt and setting the content-length cap.


timeoutMs?

optional timeoutMs: number

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

Per-attempt timeout (ms) for the extraction call. Defaults to the portal helper’s 60s. Combine with maxAttempts to cap the total time budget.


totalTimeoutMs?

optional totalTimeoutMs: number

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

Absolute wall-clock budget (ms) across ALL extraction attempts incl. backoff. When set, the loop stops before an attempt that would exceed it, so worst-case latency is bounded rather than maxAttempts × timeoutMs.


userIdentity?

optional userIdentity: string[]

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

The user’s own name(s) / handle(s) (e.g. profile nickname, wallet display name). Candidates whose entire content is just one of these are dropped — a personal memory system already knows who the user is, so “Peter Lee” is circular noise. Optional; when omitted only the bare-fragment gate applies.

Last updated on