RetainOptions
Defined in: src/lib/memory/types.ts:620
Properties
autoMergeThreshold?
optionalautoMergeThreshold:number
Defined in: src/lib/memory/types.ts:637
Cosine similarity threshold for auto-merge. Default: 0.8
(DEFAULT_AUTO_MERGE_THRESHOLD in retain.ts — the source of truth).
consolidateOptions?
optionalconsolidateOptions:PortalLlmAuth&object
Defined in: src/lib/memory/types.ts:645
When provided, runs an LLM-based consolidation pass against the top-K
existing memories above consolidateThreshold (looser than auto-merge).
The LLM emits create/update/noop per Hindsight’s facet-dedup rules.
Auth/endpoint required — one of apiKey / getToken (see
PortalLlmAuth); without this option we keep the cosine-only path.
Type Declaration
baseUrl?
optionalbaseUrl:string
endpointOverride?
optionalendpointOverride:string
model?
optionalmodel:string
onFallback()?
optionalonFallback: (reason:ConsolidationFallbackReason) =>void
Invoked when the consolidator degrades to its “create” fallback
instead of returning a real decision — llm_error for network /
timeout / unparseable output, invalid_response for well-formed
JSON that violates the schema (unknown action, bad targetId).
A flaky consolidator silently accumulates duplicate memories;
wire this to logging/metrics so the fallback rate is observable.
subject_mismatch is the odd one out and worth reading separately: the
model answered fine and we REFUSED its supersede because its own stated
subjects disagreed (#822). A non-zero rate is the guard doing its job, not
a problem — the rate to watch is how often it fires, which is also the
only signal for how reliably the model fills the subject fields in at all.
Parameters
| Parameter | Type |
|---|---|
|
|
Returns
void
piiRedaction?
optionalpiiRedaction:boolean|PiiRedactor
When set, the new fact and existing candidates are PII-redacted before
the consolidation model sees them and the result is de-anonymized before
persistence. Auto-extraction inherits this from its extract options.
consolidateThreshold?
optionalconsolidateThreshold:number
Defined in: src/lib/memory/types.ts:673
Cosine similarity floor for the consolidator candidate set. Default: 0.55
(DEFAULT_CONSOLIDATE_THRESHOLD in retain.ts — the source of truth).
consolidateTopK?
optionalconsolidateTopK:number
Defined in: src/lib/memory/types.ts:678
Top-K consolidation candidates to feed the LLM. Default: 20
(DEFAULT_CONSOLIDATE_TOP_K in retain.ts — the source of truth). Widened
from 5 so a value change can find and retire ALL stale duplicates of the
old value in one pass, not just the nearest few.
enableAutoMerge?
optionalenableAutoMerge:boolean
Defined in: src/lib/memory/types.ts:626
When provided, applies merge-on-write logic instead of plain insert.
eventTime?
optionaleventTime: {end:number|null;kind:"point"|"range"|"ongoing";start:number; } |null
Defined in: src/lib/memory/types.ts:685
W6 temporal lane — when the event in this fact occurred. Persisted to memory_vault.event_time_* columns; recall’s temporal lane filters and boosts memories whose event-time overlaps the query window. Auto-extraction emits this; manual writes can omit it.
factType?
optionalfactType:"other"|"identity"|"preference"|"relationship"|"plan"|"ongoing_context"|"constraint"|"instruction"
Defined in: src/lib/memory/types.ts:696
Typed memory (PR1) — the extractor’s classification for this fact. Persisted on create; on merge/consolidate it lazily backfills the target only when the target has no type yet (never overwrites a non-null type). Auto-extraction emits this; manual writes omit it (persisted as null).
folderId?
optionalfolderId:string|null
Defined in: src/lib/memory/types.ts:624
respectTombstones?
optionalrespectTombstones:boolean
Defined in: src/lib/memory/types.ts:634
When true, a would-be create is suppressed if it matches a soft-deleted
(“tombstoned”) memory above the auto-merge threshold — so auto-extraction
can’t silently resurrect a fact the user deleted. Off by default so manual
and other retain() callers are unaffected; auto-extraction opts in.
Returns action: 'suppressed' with the matched tombstoneId.
scope?
optionalscope:string
Defined in: src/lib/memory/types.ts:623
source?
optionalsource:RetainSource
Defined in: src/lib/memory/types.ts:621
sourceChunkIds?
optionalsourceChunkIds:string[]
Defined in: src/lib/memory/types.ts:622
trustTier?
optionaltrustTier:string
Defined in: src/lib/memory/types.ts:705
Tier-0 security (PR3) — trust tier for this fact. The write-time
injection screen threads "quarantined" here for flagged candidates;
omit for the default (null/trusted). Persisted only on create (a
quarantined candidate is force-created, never merged, so it can’t bump
or contaminate a clean memory). The DB op re-validates the value
against the known set before writing.