Skip to Content

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?

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


baseUrl?

optional baseUrl: string

Defined in: src/lib/memory/reflect.ts:102 

Endpoint for the answer LLM.


bm25AdmissionDivisor?

optional bm25AdmissionDivisor: number

Defined in: src/lib/memory/types.ts:221 

Divisor mapping BM25 scores to the admission floor. Default: 50.

Inherited from

RecallOptions.bm25AdmissionDivisor


budget?

optional budget: Budget

Defined in: src/lib/memory/types.ts:115 

Search depth. Default: ‘low’.

Inherited from

RecallOptions.budget


ceWeight?

optional ceWeight: number

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

Multiplicative cross-encoder blend weight. Default: 0.1.

Inherited from

RecallOptions.ceWeight


conversationId?

optional conversationId: string

Defined in: src/lib/memory/types.ts:140 

Restrict chunk search to one conversation. Chunk-only.

Inherited from

RecallOptions.conversationId


decomposeOptions?

optional decomposeOptions: 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?

optional baseUrl: string

model?

optional model: string

Inherited from

RecallOptions.decomposeOptions


decryptLast?

optional decryptLast: 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

RecallOptions.decryptLast


embeddingCache?

optional embeddingCache: 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

RecallOptions.embeddingCache


entityFanout?

optional entityFanout: number

Defined in: src/lib/memory/types.ts:234 

Max neighbor entities expanded per hop. Default: 8.

Inherited from

RecallOptions.entityFanout


excludeConversationId?

optional excludeConversationId: string

Defined in: src/lib/memory/types.ts:142 

Exclude one conversation from chunk search. Chunk-only.

Inherited from

RecallOptions.excludeConversationId


factTypes?

optional factTypes: ("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

RecallOptions.factTypes


factTypeWeights?

optional factTypeWeights: 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

RecallOptions.factTypeWeights


fetchFn()?

optional fetchFn: {(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>

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>


folderId?

optional folderId: string | null

Defined in: src/lib/memory/types.ts:121 

Vault folder filter. Vault-only.

Inherited from

RecallOptions.folderId


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


graphRefine?

optional graphRefine: 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

RecallOptions.graphRefine


includeChunks?

optional includeChunks: boolean

Defined in: src/lib/memory/types.ts:117 

Include source chunks for fact memories that have provenance. Default: false.

Inherited from

RecallOptions.includeChunks


limit?

optional limit: number

Defined in: src/lib/memory/types.ts:111 

Max items returned. Default: 8.

Inherited from

RecallOptions.limit


llmModel?

optional llmModel: string

Defined in: src/lib/memory/reflect.ts:51 

Override the answer model. Default: anthropic/claude-sonnet-4-6.


maxHops?

optional maxHops: number

Defined in: src/lib/memory/types.ts:232 

Total graph hops incl. the seed lookup (hop 1). Default: 1 (seed only).

Inherited from

RecallOptions.maxHops


maxTokens?

optional maxTokens: number

Defined in: src/lib/memory/reflect.ts:53 

Cap response length. Default: 4096.

Overrides

RecallOptions.maxTokens


memories?

optional memories: 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?

optional memoryIds: 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

RecallOptions.memoryIds


minScore?

optional minScore: 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

RecallOptions.minScore


mmr?

optional mmr: boolean

Defined in: src/lib/memory/types.ts:213 

Apply MMR diversification after ranking (rerank pipeline only). Default: false.

Inherited from

RecallOptions.mmr


nodeBudget?

optional nodeBudget: 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

RecallOptions.nodeBudget


now?

optional now: 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

RecallOptions.now


onDiagnostics()?

optional onDiagnostics: (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

ParameterType

diagnostics

RecallDiagnostics

Returns

void

Inherited from

RecallOptions.onDiagnostics


profile?

optional profile: 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

RecallOptions.profile


proofCountAlpha?

optional proofCountAlpha: number

Defined in: src/lib/memory/types.ts:219 

Proof-count log-boost scale. Default: 0.1.

Inherited from

RecallOptions.proofCountAlpha


queryEmbedTotalTimeoutMs?

optional queryEmbedTotalTimeoutMs: 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?

optional recency: RecencyOptions

Defined in: src/lib/memory/types.ts:211 

Recency decay curve overrides (per-year decay slope, floor, no-date multiplier).

Inherited from

RecallOptions.recency


recencyAlpha?

optional recencyAlpha: number

Defined in: src/lib/memory/types.ts:209 

Recency boost slope in the fused ranker. Default: 1.0.

Inherited from

RecallOptions.recencyAlpha


rerankLoadTimeoutMs?

optional rerankLoadTimeoutMs: 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?

optional rerankTopN: 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

RecallOptions.rerankTopN


responseSchema?

optional responseSchema: Record<string, unknown>

Defined in: src/lib/memory/reflect.ts:106 

Optional JSON Schema to coerce structured outputs.


rrfK?

optional rrfK: number

Defined in: src/lib/memory/types.ts:223 

RRF smoothing constant for lane fusion (facts × chunks and side lanes). Default: 60.

Inherited from

RecallOptions.rrfK


scopes?

optional scopes: string[]

Defined in: src/lib/memory/types.ts:119 

Vault scope filter. Vault-only.

Inherited from

RecallOptions.scopes


subQueries?

optional subQueries: 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

RecallOptions.subQueries


supersessionBoost?

optional supersessionBoost: number

Defined in: src/lib/memory/types.ts:215 

Supersession score-gap transfer factor. Default: 0.8.

Inherited from

RecallOptions.supersessionBoost


supersessionWindow?

optional supersessionWindow: number

Defined in: src/lib/memory/types.ts:217 

Hard cap on the supersession candidate window. Default: 50.

Inherited from

RecallOptions.supersessionWindow


systemPrompt?

optional systemPrompt: 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?

optional taskType: 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?

optional types: MemoryKind[]

Defined in: src/lib/memory/types.ts:109 

Which kinds to search. Default: [‘fact’].

Inherited from

RecallOptions.types


userInstructions?

optional userInstructions: 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?

optional vaultPreparation: VaultPreparation

Defined in: src/lib/memory/types.ts:103 

Internal

Inherited from

RecallOptions.vaultPreparation

Last updated on