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?
optionalapiKey: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
backoffMs()?
optionalbackoffMs: (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
| Parameter | Type |
|---|---|
|
|
|
Returns
number
baseUrl?
optionalbaseUrl:string
Defined in: src/lib/memory/autoExtract.ts:194
endpointOverride?
optionalendpointOverride: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()?
optionalfetchFn: {(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>
Parameters
| Parameter | Type |
|---|---|
|
|
|
|
|
|
Returns
Promise<Response>
Call Signature
(
input:string|Request|URL,init?:RequestInit):Promise<Response>
Parameters
| Parameter | Type |
|---|---|
|
|
|
|
|
|
Returns
Promise<Response>
getToken()?
optionalgetToken: () =>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
maxAttempts?
optionalmaxAttempts: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?
optionalmodel:string
Defined in: src/lib/memory/autoExtract.ts:195
now?
optionalnow: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()?
optionalonAttempt: (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
| Parameter | Type |
|---|---|
|
|
|
Returns
void
onCandidatesDropped()?
optionalonCandidatesDropped: () =>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()?
optionalonCandidatesParsed: (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
| Parameter | Type |
|---|---|
|
|
|
|
|
|
|
|
|
Returns
void
onExhaustedEmpty()?
optionalonExhaustedEmpty: (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
| Parameter | Type |
|---|---|
|
|
Returns
void
onTranscript()?
optionalonTranscript: (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
| Parameter | Type |
|---|---|
|
|
|
|
|
|
|
|
|
Returns
void
piiRedaction?
optionalpiiRedaction: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?
optionalprofile: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?
optionaltimeoutMs: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?
optionaltotalTimeoutMs: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?
optionaluserIdentity: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.