ReflectOptions
Defined in: src/lib/memory/reflect.ts:49
Options for reflect. Auth for the answer LLM is the dual pattern
inherited from PortalLlmAuth — one of apiKey / getToken is
required at runtime; apiKey wins when both are set.
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
baseUrl?
optionalbaseUrl:string
Defined in: src/lib/memory/reflect.ts:102
Endpoint for the answer LLM.
bm25AdmissionDivisor?
optionalbm25AdmissionDivisor:number
Defined in: src/lib/memory/types.ts:221
Divisor mapping BM25 scores to the admission floor. Default: 50.
Inherited from
RecallOptions.bm25AdmissionDivisor
budget?
optionalbudget:Budget
Defined in: src/lib/memory/types.ts:115
Search depth. Default: ‘low’.
Inherited from
ceWeight?
optionalceWeight:number
Defined in: src/lib/memory/types.ts:193
Multiplicative cross-encoder blend weight. Default: 0.1.
Inherited from
conversationId?
optionalconversationId:string
Defined in: src/lib/memory/types.ts:140
Restrict chunk search to one conversation. Chunk-only.
Inherited from
decomposeOptions?
optionaldecomposeOptions:PortalLlmAuth&object
Defined in: src/lib/memory/types.ts:169
Auth + endpoint for optional LLM helpers that reuse portal auth —
currently RecallOptions.graphRefine neighbor selection.
Query decomposition is not driven by this field inside recall()
(719/B4); createRecallTool reads the same shape from
RecallToolOptions.decomposeOptions for tool-layer rewrite.
Callers that still pass { budget: 'high', decomposeOptions } without
RecallOptions.subQueries keep compiling but no longer rewrite —
recall() emits decompose-moved on RecallDiagnostics.degraded
so upgrades without a changelog read still leave a telemetry breadcrumb.
Auth is the dual pattern — one of apiKey / getToken is required;
see PortalLlmAuth.
Type Declaration
baseUrl?
optionalbaseUrl:string
model?
optionalmodel:string
Inherited from
RecallOptions.decomposeOptions
decryptLast?
optionaldecryptLast:boolean
Defined in: src/lib/memory/types.ts:230
Decrypt vault memory content only for the top-N ranked candidates
instead of the whole vault. Forwarded verbatim to the vault search
pipeline’s MemoryVaultSearchOptions. Default: off (legacy
whole-vault decrypt path).
Inherited from
embeddingCache?
optionalembeddingCache:Map<string,Float32Array<ArrayBufferLike>>
Defined in: src/lib/memory/types.ts:107
Embedding cache shared with the rest of the turn, so the query is embedded once across lanes and the send.
Inherited from
entityFanout?
optionalentityFanout:number
Defined in: src/lib/memory/types.ts:234
Max neighbor entities expanded per hop. Default: 8.
Inherited from
excludeConversationId?
optionalexcludeConversationId:string
Defined in: src/lib/memory/types.ts:142
Exclude one conversation from chunk search. Chunk-only.
Inherited from
RecallOptions.excludeConversationId
factTypes?
optionalfactTypes: ("other"|"identity"|"preference"|"relationship"|"plan"|"ongoing_context"|"constraint"|"instruction")[]
Defined in: src/lib/memory/types.ts:126
Typed memory (PR1) — restrict fact recall to these FactTypes. Optional and no-op when unset (all types are eligible). Vault-only.
Inherited from
factTypeWeights?
optionalfactTypeWeights:Partial<Record<"other"|"identity"|"preference"|"relationship"|"plan"|"ongoing_context"|"constraint"|"instruction",number>>
Defined in: src/lib/memory/types.ts:138
PR5 — optional per-FactType score multiplier applied in the fusion boost
stage (e.g. boost identity/constraint, down-weight ongoing_context).
A type absent from the map (and untyped rows) uses 1.0, so an empty/omitted
map is a no-op (uniform weighting). Vault-only.
Inherited from
fetchFn()?
optionalfetchFn: {(input:RequestInfo|URL,init?:RequestInit):Promise<Response>; (input:string|Request|URL,init?:RequestInit):Promise<Response>; }
Defined in: src/lib/memory/reflect.ts:104
Override fetch (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>
folderId?
optionalfolderId:string|null
Defined in: src/lib/memory/types.ts:121
Vault folder filter. Vault-only.
Inherited from
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
graphRefine?
optionalgraphRefine:boolean
Defined in: src/lib/memory/types.ts:246
PR5 — enable LLM graph path-refinement: at each traversal hop a model picks
which neighbor entities to expand instead of pure co-occurrence ranking.
Opt-in (default false); only active on the high budget (needs the
traverse flag) AND when decomposeOptions is set (reuses that auth).
Falls back to deterministic co-occurrence order on any error. Adds ≤1 LLM
call per expansion hop.
Inherited from
includeChunks?
optionalincludeChunks:boolean
Defined in: src/lib/memory/types.ts:117
Include source chunks for fact memories that have provenance. Default: false.
Inherited from
limit?
optionallimit:number
Defined in: src/lib/memory/types.ts:111
Max items returned. Default: 8.
Inherited from
llmModel?
optionalllmModel:string
Defined in: src/lib/memory/reflect.ts:51
Override the answer model. Default: anthropic/claude-sonnet-4-6.
maxHops?
optionalmaxHops:number
Defined in: src/lib/memory/types.ts:232
Total graph hops incl. the seed lookup (hop 1). Default: 1 (seed only).
Inherited from
maxTokens?
optionalmaxTokens:number
Defined in: src/lib/memory/reflect.ts:53
Cap response length. Default: 4096.
Overrides
memories?
optionalmemories:RankedMemory[]
Defined in: src/lib/memory/reflect.ts:112
Skip Stage-1 recall and synthesize from these memories instead.
Used by synthesizeProfile after intersecting recall with a
reviewedMemoryIds gate so the LLM never sees unreviewed evidence.
memoryIds?
optionalmemoryIds:string[]
Defined in: src/lib/memory/types.ts:131
Restrict fact candidates BEFORE ranking. Empty means no facts. When set,
unrestricted chunk search is disabled; it must not escape a topic scope.
Asking for "chunk" alongside this yields no excerpts and reports
"chunks-scope-restricted" on RecallDiagnostics.degraded.
Inherited from
minScore?
optionalminScore:number
Defined in: src/lib/memory/types.ts:144
Drop results below this score. Default: 0.1 for facts, 0.5 for chunks (mirrors today’s defaults).
Inherited from
mmr?
optionalmmr:boolean
Defined in: src/lib/memory/types.ts:213
Apply MMR diversification after ranking (rerank pipeline only). Default: false.
Inherited from
nodeBudget?
optionalnodeBudget:number
Defined in: src/lib/memory/types.ts:237
Hard cap on graph-lane memory IDs — across all hops, and on the single-hop
lane low/mid run. Default: 64.
Inherited from
now?
optionalnow:number
Defined in: src/lib/memory/types.ts:180
Reference “now” for resolving relative temporal phrases in the
query (“last week”, “yesterday”, “N days ago”). Default: Date.now().
Override for back-dated evaluation harnesses (bench corpora dated
2021–2023) and for deterministic tests — otherwise the W6 lane
resolves windows in 2026 and never overlaps stored event_time.
Inherited from
onDiagnostics()?
optionalonDiagnostics: (diagnostics:RecallDiagnostics) =>void
Defined in: src/lib/memory/types.ts:188
Best-effort observability hook. Called once per recall() with per-lane
timings, lane counts, and soft-degradation signals — the raw material for
tuning latency/quality and for wiring recall telemetry to PostHog. Invoked
synchronously just before recall() returns; a throwing callback is
swallowed (diagnostics must never break retrieval). Off unless provided.
Parameters
| Parameter | Type |
|---|---|
|
|
Returns
void
Inherited from
profile?
optionalprofile:MemoryAppProfile
Defined in: src/lib/memory/types.ts:105
App profile supplying the fact-lane score floor and fact-type weights when minScore / factTypeWeights are not set.
Inherited from
proofCountAlpha?
optionalproofCountAlpha:number
Defined in: src/lib/memory/types.ts:219
Proof-count log-boost scale. Default: 0.1.
Inherited from
queryEmbedTotalTimeoutMs?
optionalqueryEmbedTotalTimeoutMs:number
Defined in: src/lib/memory/types.ts:207
Overall deadline, in ms, for embedding the query — token read, every retry
attempt and the backoff between them. Default: 8000. On expiry the fact lane
degrades to BM25 and the (cosine-only) chunk lane is skipped, reported as
embeddings-unavailable, so an embeddings outage costs a turn at most this
long rather than ~4 x the per-attempt timeout. 0 disables it.
Inherited from
RecallOptions.queryEmbedTotalTimeoutMs
recency?
optionalrecency:RecencyOptions
Defined in: src/lib/memory/types.ts:211
Recency decay curve overrides (per-year decay slope, floor, no-date multiplier).
Inherited from
recencyAlpha?
optionalrecencyAlpha:number
Defined in: src/lib/memory/types.ts:209
Recency boost slope in the fused ranker. Default: 1.0.
Inherited from
rerankLoadTimeoutMs?
optionalrerankLoadTimeoutMs:number
Defined in: src/lib/memory/types.ts:199
Max ms a mid/high recall waits for the cross-encoder’s FIRST model load
before degrading to the fused ranking (reported as rerank-unavailable).
Default: 10000. The load keeps going in the background for later calls.
Inherited from
RecallOptions.rerankLoadTimeoutMs
rerankTopN?
optionalrerankTopN:number
Defined in: src/lib/memory/types.ts:191
Number of candidates fed to the cross-encoder rerank stage. Default: 5; was 30 until 2026-08-13 — see anuma-ai/sdk#845.
Inherited from
responseSchema?
optionalresponseSchema:Record<string,unknown>
Defined in: src/lib/memory/reflect.ts:106
Optional JSON Schema to coerce structured outputs.
rrfK?
optionalrrfK:number
Defined in: src/lib/memory/types.ts:223
RRF smoothing constant for lane fusion (facts × chunks and side lanes). Default: 60.
Inherited from
scopes?
optionalscopes:string[]
Defined in: src/lib/memory/types.ts:119
Vault scope filter. Vault-only.
Inherited from
subQueries?
optionalsubQueries:string[]
Defined in: src/lib/memory/types.ts:153
Pre-decomposed facet queries for the composite ranker. When ≥2 are
supplied, the vault lane runs rankComposite over them (no LLM call
inside recall() — 719/B4). Callers that still want LLM rewrite
(e.g. createRecallTool at budget: 'high') call
decomposeQuery themselves and pass the result here. A single entry
(or omitting this) keeps the single-query path.
Inherited from
supersessionBoost?
optionalsupersessionBoost:number
Defined in: src/lib/memory/types.ts:215
Supersession score-gap transfer factor. Default: 0.8.
Inherited from
RecallOptions.supersessionBoost
supersessionWindow?
optionalsupersessionWindow:number
Defined in: src/lib/memory/types.ts:217
Hard cap on the supersession candidate window. Default: 50.
Inherited from
RecallOptions.supersessionWindow
systemPrompt?
optionalsystemPrompt:string
Defined in: src/lib/memory/reflect.ts:78
Override the grounding system prompt.
⚠ DOING THIS MAKES THE REQUEST’S PROVENANCE YOURS. The default prompt’s first sentence is this flow’s fingerprint in the portal’s freeloader (anti-bot) detector (see DEFAULT_SYSTEM_PROMPT); replacing it wholesale removes that, and a free-tier request carrying no recognised provenance is rejected outright once the portal’s markerless reject is enabled — a 403, not a degraded answer.
Which replacement is correct depends on what the call IS, and there is no safe default:
- A background/internal call (a fixed-purpose helper, not a user’s own question): prepend withInternalFlowMarker, which is exported for exactly this. That is what profile-facet synthesis does.
- A user-facing call (the person is asking their own question and expects an answer):
do NOT use the internal marker — it asserts “not user chat” and would be false. Keep the
default prompt, or append your instructions to it rather than replacing it, so the
fingerprint survives. A genuinely distinct user-facing flow needs its own fingerprint
registered in ai-portal
internal/detection/markers.go.
Appending is the cheap way to stay safe: ${DEFAULT_SYSTEM_PROMPT}\n\n${yourInstructions}
keeps the fingerprint as a prefix. reflect.test.ts pins both the marked and the bare
override paths so this stays true.
taskType?
optionaltaskType:TaskType
Defined in: src/lib/memory/reflect.ts:100
Class-B task name for the X-Anuma-Task-Type header, or nothing.
Deliberately OPTIONAL and unset by default. reflect() also answers the user’s
OWN question, and that traffic is chat, not an internal flow — declaring a
task type unconditionally here would put an internal-flow name on real
conversation, which is the same boundary INTERNAL_FLOW_MARKER draws
(reflect is deliberately unmarked; its background caller marks its own
prompt — see ../internalFlowMarker.ts). So the name is per call: only a
caller with ONE fixed purpose passes
one, and today that is profile-facet synthesis (memory_profile_synth).
types?
optionaltypes:MemoryKind[]
Defined in: src/lib/memory/types.ts:109
Which kinds to search. Default: [‘fact’].
Inherited from
userInstructions?
optionaluserInstructions:string
Defined in: src/lib/memory/reflect.ts:87
Extra caller instruction to carry on the USER turn, between the question and
the evidence block (see the userMessage assembly below). This is the slot a
background caller uses to keep its per-request data OUT of the system message
without colliding with the numbered evidence list — profile-facet synthesis
puts its section label, guidance and response-field hint here so its system
half can stay fixed and server-ownable.
vaultPreparation?
optionalvaultPreparation:VaultPreparation
Defined in: src/lib/memory/types.ts:103
Internal
Inherited from