Skip to Content

UseChatStorageOptions

Defined in: src/react/useChatStorage.ts:566 

Options for useChatStorage hook (React version)

Extends base options with apiType support.

Extends

  • BaseUseChatStorageOptions

Properties

activeToolSets?

optional activeToolSets: string[]

Defined in: src/react/useChatStorage.ts:677 

Tool set names that should expand unconditionally for this request, bypassing the anchor-similarity check. Use when conversation state implies a set should be present regardless of how the prompt is phrased — e.g., pass ["slides"] when the conversation already contains a slide deck artifact, so short follow-up prompts (“add a thank you slide”, “make it bigger”) still get the full slide toolkit.

Read via a ref so updates are visible to in-flight sendMessage calls without rebuilding the callback.

Names must match a set’s name from BUILT_IN_TOOL_SETS or extraToolSets. Unknown names are ignored.


apiType?

optional apiType: ApiType

Defined in: src/react/useChatStorage.ts:588 

Which API endpoint to use. Default: “responses”

  • “responses”: OpenAI Responses API (supports thinking, reasoning, conversations)
  • “completions”: OpenAI Chat Completions API (wider model compatibility)

autoCreateConversation?

optional autoCreateConversation: boolean

Defined in: src/lib/db/chat/types.ts:544 

Automatically create a new conversation if none is set (default: true)

Inherited from

BaseUseChatStorageOptions.autoCreateConversation


autoEmbedMessages?

optional autoEmbedMessages: boolean

Defined in: src/lib/db/chat/types.ts:609 

Automatically generate embeddings for messages after saving. Enables semantic search over past conversations via searchMessages().

Default

true

Inherited from

BaseUseChatStorageOptions.autoEmbedMessages


autoFlushOnKeyAvailable?

optional autoFlushOnKeyAvailable: boolean

Defined in: src/react/useChatStorage.ts:650 

Automatically flush queued operations when the encryption key becomes available. Requires enableQueue to be true.

Default

true

background?

optional background: boolean

Defined in: src/react/useChatStorage.ts:573 

Keep a resumable generation running when the request fails or the hook unmounts. Portal stores the answer of a turn that finishes with no client attached.


baseUrl?

optional baseUrl: string

Defined in: src/lib/db/chat/types.ts:550 

Base URL for the chat API endpoint

Inherited from

BaseUseChatStorageOptions.baseUrl


chatBackend?

optional chatBackend: ChatBackendFactory

Defined in: src/lib/db/chat/types.ts:540 

Builds the chat storage backend (default: this database); keep it stable across renders, since a new factory rebuilds the backend and every callback.

Inherited from

BaseUseChatStorageOptions.chatBackend


conversationId?

optional conversationId: string

Defined in: src/lib/db/chat/types.ts:542 

ID of an existing conversation to load and continue

Inherited from

BaseUseChatStorageOptions.conversationId


database

database: Database

Defined in: src/lib/db/chat/types.ts:536 

WatermelonDB database instance for storing conversations and messages

Inherited from

BaseUseChatStorageOptions.database


defaultConversationTitle?

optional defaultConversationTitle: string

Defined in: src/lib/db/chat/types.ts:546 

Title for auto-created conversations (default: “New conversation”)

Inherited from

BaseUseChatStorageOptions.defaultConversationTitle


detachedTools?

optional detachedTools: ToolConfig[]

Defined in: src/react/useChatStorage.ts:580 

Device tools that can finish a turn the portal completed while the device was away: their executors run when that answer is stored. Pass the display tools and the memory save tool.


embeddedWalletSigner?

optional embeddedWalletSigner: EmbeddedWalletSignerFn

Defined in: src/react/useChatStorage.ts:628 

Function for silent signing with Privy embedded wallets. When provided, enables automatic encryption key derivation without user confirmation modals.


embeddingModel?

optional embeddingModel: string

Defined in: src/lib/db/chat/types.ts:614 

Embedding model to use when autoEmbedMessages is enabled.

Default

DEFAULT_API_EMBEDDING_MODEL

Inherited from

BaseUseChatStorageOptions.embeddingModel


enableQueue?

optional enableQueue: boolean

Defined in: src/react/useChatStorage.ts:643 

Enable the in-memory write queue for operations when encryption key isn’t yet available. When enabled, operations are held in memory and flushed to encrypted storage once the key becomes available.

Default

true

extraToolSets?

optional extraToolSets: ToolSet[]

Defined in: src/react/useChatStorage.ts:661 

Additional tool sets to apply on top of the built-in ones (app-generation, slides, github). When any anchor tool in a custom set is selected by semantic matching, all members of that set are included automatically.

Treated as static config — set once at hook setup. Changing it across renders does not affect in-flight sendMessage calls; use activeToolSets for dynamic, conversation-state-driven overrides.


fileProcessingOptions?

optional fileProcessingOptions: object

Defined in: src/lib/db/chat/types.ts:579 

Options for file preprocessing behavior

keepOriginalFiles?

optional keepOriginalFiles: boolean

Whether to keep original file attachments (default: true)

maxFileSizeBytes?

optional maxFileSizeBytes: number

Max file size to process in bytes (default: 10MB)

onError()?

optional onError: (fileName: string, error: Error) => void

Callback for errors (non-fatal)

Parameters

ParameterType

fileName

string

error

Error

Returns

void

onProgress()?

optional onProgress: (current: number, total: number, fileName: string) => void

Callback for progress updates

Parameters

ParameterType

current

number

total

number

fileName

string

Returns

void

Inherited from

BaseUseChatStorageOptions.fileProcessingOptions


fileProcessors?

optional fileProcessors: FileProcessor[] | null

Defined in: src/lib/db/chat/types.ts:575 

File preprocessors to use for automatic text extraction.

  • undefined (default): Use all built-in processors (PDF, Excel, Word)
  • null or []: Disable preprocessing
  • FileProcessor[]: Use specific processors

Inherited from

BaseUseChatStorageOptions.fileProcessors


foldToolResultsInHistory?

optional foldToolResultsInHistory: boolean

Defined in: src/lib/db/chat/types.ts:660 

Fold persisted [Tool Execution Results] rows onto the assistant turn that produced them when replaying stored history, instead of dropping them.

Defaults to false, and that default is deliberate. Folding is the better behaviour — it is what lets a follow-up about a tool’s output work after a reload — but it moves the payload from a role: "user" row onto an assistant row. Any consumer that scrubs these rows by checking role === "user" plus the content prefix (which is how both apps did it before this option existed) stops catching them the moment folding turns on, and starts replaying whatever the row held. Opting in is therefore a statement that the caller has checked its own filters and set toolResultsHistoryExclude for any payload that must not reach the model.

With it off, rows are dropped from the replayed history rather than sent verbatim. Verbatim would put two consecutive user turns on the wire, and the model answers the previous turn instead of the new prompt.

Inherited from

BaseUseChatStorageOptions.foldToolResultsInHistory


getToken()?

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

Defined in: src/lib/db/chat/types.ts:548 

Function to retrieve the auth token for API requests

Returns

Promise<string | null>

Inherited from

BaseUseChatStorageOptions.getToken


getWalletAddress()?

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

Defined in: src/react/useChatStorage.ts:635 

Async function that returns the wallet address when available. Used for polling during Privy embedded wallet initialization. When the wallet isn’t ready yet, should return null.

Returns

Promise<string | null>


hooks?

optional hooks: RunHooks | RunHooks[]

Defined in: src/lib/db/chat/types.ts:534 

Run lifecycle hooks for telemetry and tracing, for example from createMetricsHooks

Inherited from

BaseUseChatStorageOptions.hooks


inbox?

optional inbox: VaultInbox

Defined in: src/react/useChatStorage.ts:575 

The vault inbox that receives answers finished while no client was attached.


mcpR2Domain?

optional mcpR2Domain: string

Defined in: src/lib/db/chat/types.ts:626 

R2 domain for identifying MCP-generated image URLs. When set, enables OPFS caching of generated images. Defaults to the hardcoded MCP_R2_DOMAIN from clientConfig.

Inherited from

BaseUseChatStorageOptions.mcpR2Domain


memoryStore?

optional memoryStore: MemoryStore | null

Defined in: src/lib/db/chat/types.ts:538 

Route memory operations through this store; null disables memory access while undefined uses the local vault. Folders are unsupported. With piiRedaction on, build the store with embeddingOptions.maskInput or its memory calls throw.

Inherited from

BaseUseChatStorageOptions.memoryStore


minContentLength?

optional minContentLength: number

Defined in: src/lib/db/chat/types.ts:620 

Minimum content length required to generate embeddings. Messages shorter than this are skipped as they provide limited semantic value.

Default

10

Inherited from

BaseUseChatStorageOptions.minContentLength


nerDetector?

optional nerDetector: NerDetector

Defined in: src/lib/db/chat/types.ts:698 

Optional on-device NER detector for unstructured PII (names, locations, organizations) that regex can’t catch. When supplied AND piiRedaction is active, the conversation redactor merges its spans into the outbound message redaction (chat-send path only). Supply e.g. createTransformersNerDetector() from @anuma/sdk/pii/transformers on web. Ignored when piiRedaction is off. See NerDetector.

Inherited from

BaseUseChatStorageOptions.nerDetector


onData()?

optional onData: (chunk: string) => void

Defined in: src/lib/db/chat/types.ts:552 

Callback invoked with each streamed response chunk

Parameters

ParameterType

chunk

string

Returns

void

Inherited from

BaseUseChatStorageOptions.onData


onError()?

optional onError: (error: Error) => void

Defined in: src/lib/db/chat/types.ts:558 

Callback invoked when an error occurs during the request

Parameters

ParameterType

error

Error

Returns

void

Inherited from

BaseUseChatStorageOptions.onError


onFinish()?

optional onFinish: (response: LlmapiResponseResponse) => void

Defined in: src/lib/db/chat/types.ts:556 

Callback invoked when the response completes successfully

Parameters

ParameterType

response

LlmapiResponseResponse

Returns

void

Inherited from

BaseUseChatStorageOptions.onFinish


onPiiRedacted()?

optional onPiiRedacted: (matches: PiiMatch[]) => void

Defined in: src/lib/db/chat/types.ts:689 

Called with the PII matches found whenever outbound messages are redacted. Only fired when piiRedaction is active and at least one match was found.

Parameters

ParameterType

matches

PiiMatch[]

Returns

void

Inherited from

BaseUseChatStorageOptions.onPiiRedacted


onServerToolCall()?

optional onServerToolCall: (toolCall: ServerToolCallEvent) => void

Defined in: src/lib/db/chat/types.ts:563 

Callback invoked when a server-side tool (MCP) is called during streaming. Use this to show activity indicators like “Searching…” in the UI.

Parameters

ParameterType

toolCall

ServerToolCallEvent

Returns

void

Inherited from

BaseUseChatStorageOptions.onServerToolCall


onStreamMeta()?

optional onStreamMeta: (meta: StreamResumeHandle & object) => void

Defined in: src/react/useChatStorage.ts:582 

Stream handle for each HTTP round, including client-tool continuations.

Parameters

ParameterType

meta

StreamResumeHandle & object

Returns

void


onThinking()?

optional onThinking: (chunk: string) => void

Defined in: src/lib/db/chat/types.ts:554 

Callback invoked when thinking/reasoning content is received (from <think> tags or API reasoning)

Parameters

ParameterType

chunk

string

Returns

void

Inherited from

BaseUseChatStorageOptions.onThinking


onToolCallArgumentsDelta()?

optional onToolCallArgumentsDelta: (event: ToolCallArgumentsDeltaEvent) => void

Defined in: src/lib/db/chat/types.ts:568 

Called with partial tool call arguments as they stream in. Use for live preview of artifacts (HTML, slides) being generated.

Parameters

ParameterType

event

ToolCallArgumentsDeltaEvent

Returns

void

Inherited from

BaseUseChatStorageOptions.onToolCallArgumentsDelta


onToolSelection()?

optional onToolSelection: (info: object) => void

Defined in: src/react/useChatStorage.ts:597 

Called once per sendMessage with the user prompt and the FINAL tool selection — after semantic filtering, tool-set expansion, and exclusions; exactly the tools the request carries. Intended for debug logging and selection QA (e.g. a prefixed plain-text console line you can filter on). Errors thrown by the callback are swallowed.

Parameters

ParameterType

info

object

info.clientToolNames

string[]

info.prompt

string

info.serverToolNames

string[]

Returns

void


piiRedaction?

optional piiRedaction: boolean | PiiRedactor

Defined in: src/lib/db/chat/types.ts:684 

Enable best-effort, client-side PII obfuscation (NOT a compliance guarantee). Outbound message text is scanned for personally identifiable information and replaced with tagged placeholders before reaching the LLM provider; responses are de-anonymized automatically. Embedding inputs and the summarization prompt are redacted too. Regex-based detection does not cover names, non-text content, or tool-call arguments.

  • true: one redactor is shared per conversation
  • PiiRedactor instance: bring your own (tune via constructor options)

Inherited from

BaseUseChatStorageOptions.piiRedaction


preProcessors?

optional preProcessors: PromptPreProcessor[]

Defined in: src/lib/db/chat/types.ts:670 

Pre-processors run after the last user message is received but before the first LLM request. Each receives the prompt text and a shared embedding (computed once per request) and may return messages to enrich the conversation. Forwarded to the underlying useChat hook. See createWebSearchPreProcessor, createCryptoPricePreProcessor, createStockPricePreProcessor, createWeatherPreProcessor, or write a custom one matching PromptPreProcessor.

Inherited from

BaseUseChatStorageOptions.preProcessors


resumable?

optional resumable: boolean

Defined in: src/react/useChatStorage.ts:568 

Opt into the portal stream buffer for every generated round.


serverTools?

optional serverTools: object

Defined in: src/lib/db/chat/types.ts:590 

Configuration for the server tools cache and tool selection.

cache?

optional cache: ToolsCacheBackend

Cache backend; defaults to localStorage with a memory fallback on platforms without localStorage.

cacheExpirationMs?

optional cacheExpirationMs: number

Cache expiration time in milliseconds (default: 86400000 = 1 day)

deferLoading?

optional deferLoading: DeferLoadingConfig

Opt-in defer-loading (Phase 3). OFF by default → tools are sent exactly as today. When enabled, the full server catalog is emitted every turn in a deterministic, byte-stable order ([tool-search] → [hot] → [deferred, name-sorted]) with defer_loading:true on non-hot tools and an Anthropic tool-search tool prepended, so the leading tools prefix stays cacheable. See DeferLoadingConfig.

Inherited from

BaseUseChatStorageOptions.serverTools


signMessage?

optional signMessage: SignMessageFn

Defined in: src/react/useChatStorage.ts:621 

Function to sign a message for encryption key derivation. Typically from Privy’s useSignMessage hook. Required together with walletAddress for field-level encryption.


smoothing?

optional smoothing: boolean | StreamSmoothingConfig

Defined in: src/lib/db/chat/types.ts:672 

Output pacing forwarded to useChat. Set false when the UI batches streamed updates.

Inherited from

BaseUseChatStorageOptions.smoothing


toolResultsHistoryExclude?

optional toolResultsHistoryExclude: string[]

Defined in: src/lib/db/chat/types.ts:642 

Tool names whose persisted results must never be replayed to the model.

A turn’s auto-executed tool results are stored as a synthetic [Tool Execution Results] row and, on a replayed send, folded back onto the assistant turn they belong to — that is what lets a follow-up question about a tool’s output work after a reload. Name a tool here when its payload exists for the RENDERER rather than the model: a display card can carry data the model was deliberately never given (People Nearby’s card holds third parties’ snapped coordinates, which the search result strips), and replaying it would hand that data straight back.

Hook-level rather than per-send on purpose: an exclusion that has to be remembered at every call site is one bad send away from leaking.

Inherited from

BaseUseChatStorageOptions.toolResultsHistoryExclude


walletAddress?

optional walletAddress: string

Defined in: src/react/useChatStorage.ts:614 

Wallet address for encrypted file storage and field-level encryption. When provided with signMessage, all sensitive message content, conversation titles, and media metadata are encrypted at rest using AES-GCM with wallet-derived keys.

Requires:

  • OPFS browser support (for file storage)
  • signMessage function (for encryption key derivation)

When not provided, data is stored in plaintext (backwards compatible).

Last updated on