Interface: LiteRtLmAdapterOptions
Defined in: src/batteries/llm/litert_lm/types.ts:140
Configuration for the in-browser LiteRT-LM adapter.
Remarks
Splits into three groups: engine controls (model + injection/loading), generation controls (LiteRT-native sampler/limits — NOT OpenAI sampling params), and ADK-control options shared with the other LLM batteries (history shaping, trust, storage, media policy).
Extends
Properties
| Property | Type | Description | Inherited from | Defined in | | ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --- | ----------------------------------------------------------------------------------------------------------------------------------------- | | audioModalityEnabled? | boolean | Enable audio input. Maps to SessionConfig.audioModalityEnabled. When set, a user Message's audio attachments map to LiteRT {type:'audio', path:'data:…'} content items; otherwise they degrade via unsupportedMediaPolicy. Remarks This is the only multimodal knob the installed @litert-lm/core 0.13.1 exposes. The build does NOT surface engine-level vision/audio backends (EngineSettings is {model, backend?, mainExecutorSettings?}; the WASM createDefault takes a single backend) — only this SessionConfig flag + MessageContentItem.path exist (blob is untyped). Whether the WASM runtime actually consumes the content items is not yet runtime-verified in 0.13.1 (the published types over-promise — same shape as the tool_calls finding); the browser model matrix is the gate-on-proof. If the runtime ignores them, configure unsupportedMediaPolicy to degrade. | - | src/batteries/llm/litert_lm/types.ts:203 | | autoAck? | boolean | Automatically ctx.ack() when generation completes with no tool calls (default false). | - | src/batteries/llm/litert_lm/types.ts:240 | | backend? | number | Inference backend (CPU / GPU / …). Maps to EngineSettings.backend. | - | src/batteries/llm/litert_lm/types.ts:188 | | bucketOrder? | ChatCompletionsBucketOrder | Order in which the leading/trailing context buckets are rendered. | - | src/batteries/llm/litert_lm/types.ts:220 | | contextWindow? | number | Hard context-window token budget; enforced only when LiteRtLmAdapterOptions.tokenEncoding is non-null. | - | src/batteries/llm/litert_lm/types.ts:222 | | createEngine? | CreateLiteRtLmEngine | Custom engine factory; overrides the default Engine.create(...) loader. | - | src/batteries/llm/litert_lm/types.ts:150 | | enableConstrainedDecoding? | boolean | Enable constrained decoding (channels). Maps to ConversationConfig.enableConstrainedDecoding. | - | src/batteries/llm/litert_lm/types.ts:212 | | enableThinking? | boolean | Whether to enable the model's "thinking"/reasoning mode, passed EXPLICITLY into the chat template via preface.extra_context.enable_thinking. Defaults to false — the gemma-4 .litertlm template gates < | think | >onenable_thinking, and leaving it unset lets the runtime decide (often ON), silently burning the output budget inside the thought channel. (Independent of reasoningParser, which only parses thinking that IS emitted.) | - | src/batteries/llm/litert_lm/types.ts:278 | | engine? | Engine | A pre-constructed engine to drive; mutually exclusive with LiteRtLmAdapterOptions.createEngine. | - | src/batteries/llm/litert_lm/types.ts:148 | | extractMediaOutputs? | MediaOutputExtractorFn | Extract GENERATED media (audio/image/…) from the raw LiteRT generation result and surface it as attachments on the assistant @nhtio/adk!Message. Default absent → text-only output, unchanged. Receives the raw final LiteRtMessage (whose content may be a structured MessageContentItem[]); each returned descriptor is persisted via ctx.storeMediaBytes and attached as Media.toolGenerated. The current @litert-lm/core runtime emits only {type:'text'} items, so this is a forward-looking seam for a model that emits media content items. | - | src/batteries/llm/litert_lm/types.ts:299 | | filterChannelContentFromKvCache? | boolean | Drop channel ("thinking") content from the KV cache. Maps to ConversationConfig.filterChannelContentFromKvCache. | - | src/batteries/llm/litert_lm/types.ts:214 | | forgeToolsFilter? | (forged: ToolRegistry, ctx: DispatchContext) => ToolRegistry | OPTIONAL hook to SHAPE the artifact-query tools forged from prior-turn SpooledArtifact results, before they merge into the visible tool set. Receives the merged forged registry + dispatch context; returns a (possibly narrowed) registry, applied BEFORE the merge with ctx.tools. Lets the assembler keep only the core readers on a tight window (the rest reachable via tool_catalog/call_a_tool). Default absent = identity (all forged tools) = backward-compatible. The battery stays budget-agnostic (per the CONTRIBUTING size-threshold rule) — it applies the supplied filter without measuring context; budget logic lives in the caller's filter. | - | src/batteries/llm/litert_lm/types.ts:257 | | helpers? | Partial<ChatCompletionsHelpers> | Pluggable per-function overrides for the rendering/translation helpers. | - | src/batteries/llm/litert_lm/types.ts:234 | | inputPromptAsHint? | string | Optional hint prompt passed to Engine.create(settings, inputPromptAsHint) to warm the cache. | - | src/batteries/llm/litert_lm/types.ts:156 | | isWebGPUAvailable? | () => boolean | Override for the WebGPU-availability probe (defaults to a real navigator.gpu check). | - | src/batteries/llm/litert_lm/types.ts:154 | | maxNumTokens? | number | Context length (LiteRT-only). Maps to EngineSettings.mainExecutorSettings.maxNumTokens. Default 4096. | - | src/batteries/llm/litert_lm/types.ts:186 | | maxOutputTokens? | number | Native max tokens per turn. Prefer maxTokens. Maps to SessionConfig.maxOutputTokens. | - | src/batteries/llm/litert_lm/types.ts:184 | | maxTokens? | number | Portable max generation length (canonical spelling of maxOutputTokens). Default 1024. | - | src/batteries/llm/litert_lm/types.ts:162 | | model | string | Blob | ReadableStream<Uint8Array<ArrayBufferLike>> | The .litertlm model to load: a URL string, a ReadableStream<Uint8Array>, or a Blob. Required. The model is fixed at engine-load time, not per request. | - | src/batteries/llm/litert_lm/types.ts:146 | | multimodal? | { audio?: boolean; image?: boolean; } | Enable multimodal input by kind (canonical spelling of visionModalityEnabled + audioModalityEnabled). | - | src/batteries/llm/litert_lm/types.ts:176 | | multimodal.audio? | boolean | - | - | src/batteries/llm/litert_lm/types.ts:176 | | multimodal.image? | boolean | - | - | src/batteries/llm/litert_lm/types.ts:176 | | onCompiling? | BatteryLifecycleCallback | Engine/graph/shader compilation after download, before the first token. A COARSE marker: the on-device runtimes (LiteRT Engine.create, transformers.js from_pretrained) expose the boundary — download done, opaque WebGPU/WASM graph build about to run — but NOT a progress stream, so progress is usually absent. Often the slowest part of a cold start; without this it was invisible. | BatteryLifecycleHooks.onCompiling | src/batteries/llm/chat_common/lifecycle.ts:95 | | onComplete? | BatteryLifecycleCallback | After the turn's output is parsed + persisted, before ack (fires per turn). | BatteryLifecycleHooks.onComplete | src/batteries/llm/chat_common/lifecycle.ts:105 | | onError? | BatteryLifecycleCallback | A load or generation failure (paired with nack). | BatteryLifecycleHooks.onError | src/batteries/llm/chat_common/lifecycle.ts:107 | | onGenerating? | BatteryLifecycleCallback | The generate call is in progress (fires per turn). Fires once immediately before the provider call for most engines; engines that stream per-step generation progress (e.g. a diffusion denoise loop) fire it REPEATEDLY during generation, each carrying a progress in 0..1. | BatteryLifecycleHooks.onGenerating | src/batteries/llm/chat_common/lifecycle.ts:103 | | onInitProgress? | (report: unknown) => void | Callback invoked with model-load progress reports (provider-opaque). | - | src/batteries/llm/litert_lm/types.ts:152 | | onLifecycle? | BatteryLifecycleCallback | Fires on EVERY phase transition (the firehose). | BatteryLifecycleHooks.onLifecycle | src/batteries/llm/chat_common/lifecycle.ts:86 | | onLoading? | BatteryLifecycleCallback | Weights/runtime loading — may fire repeatedly with progress as the provider reports it. | BatteryLifecycleHooks.onLoading | src/batteries/llm/chat_common/lifecycle.ts:88 | | onPromptAssembled? | PromptAssembledObserverFn | Observe the fully-assembled prompt this battery is about to send TO the model — fired once per terminal generation, the instant assembly completes and BEFORE the engine dispatch, with the rendered preface, the per-turn messages, and the rendered tools block. The mirror of onRawGeneration (which taps what comes back). Purely observational (return value ignored, errors swallowed). Default absent. The request is handed back AS-IS — no redaction — so treat it as potentially sensitive if you persist it. See PromptAssembledObserverFn. | - | src/batteries/llm/litert_lm/types.ts:318 | | onRawGeneration? | RawGenerationObserverFn | Observe the model's RAW text output for each completed generation — fired once per terminal generation, after envelope-stripping + reasoning/tool-call parsing but before the result is persisted, with the complete rawText, the residual cleanedText, and the extracted reasoning / toolCalls. Purely observational (return value ignored, errors swallowed). Default absent. This is the supported seam for parser bring-up against a new model, live "why did it abstain?" debugging, and ground-truth fixture capture — the job that previously needed a temporary hook patched into the adapter. See RawGenerationObserverFn. | - | src/batteries/llm/litert_lm/types.ts:309 | | onReady? | BatteryLifecycleCallback | Engine/pipeline resolved and cached, before the first generation. | BatteryLifecycleHooks.onReady | src/batteries/llm/chat_common/lifecycle.ts:97 | | reasoningFieldPrecedence? | ReasoningFieldPrecedence | Precedence order for reasoning/thought fields. | - | src/batteries/llm/litert_lm/types.ts:232 | | reasoningOrphanRecovery? | boolean | Recover UNPAIRED reasoning markers (a lone </think>, a truncated <think>) by inferring the missing half from the pseudo-streaming order, instead of leaking the stray marker into the visible answer. Defaults to true. Set false for strict pair-only parsing. Ignored when reasoningParser is a custom function. | - | src/batteries/llm/litert_lm/types.ts:290 | | reasoningParser? | | ReasoningParserName | ReasoningParserFn | How to parse reasoning/thinking out of the model's text output. A family name, 'auto' (the default), 'none', or a custom ReasoningParserFn. Extracted reasoning becomes ADK Thoughts. | - | src/batteries/llm/litert_lm/types.ts:283 | | replayCompatibility? | readonly string[] | Replay-compatibility tags whose opaque reasoning payloads may be replayed. | - | src/batteries/llm/litert_lm/types.ts:230 | | sampler? | ChatSampler | Portable sampler strategy ('greedy' default). Maps to samplerParams.type (GREEDY/TOP_K/TOP_P); GREEDY is top-1 so k is forced to 1. Canonical spelling of samplerParams.type. | - | src/batteries/llm/litert_lm/types.ts:165 | | samplerParams? | LiteRtSamplerParametersOption | Native sampler config { type, k, p, temperature, seed }. Prefer sampler/temperature/ topK/topP. Maps to SessionConfig.samplerParams. | - | src/batteries/llm/litert_lm/types.ts:182 | | seed? | number | RNG seed for reproducible sampling. | - | src/batteries/llm/litert_lm/types.ts:173 | | selfIdentity? | string | The assistant identity this adapter speaks as (default 'assistant'). | - | src/batteries/llm/litert_lm/types.ts:224 | | spoolStore? | SpoolStore | Byte store for spooling raw tool output (defaults to a per-dispatch in-memory store). | - | src/batteries/llm/litert_lm/types.ts:236 | | stream? | boolean | Stream tokens (default true). When false, a single completed message is returned. | - | src/batteries/llm/litert_lm/types.ts:218 | | temperature? | number | Sampling temperature (used by 'top-k'/'top-p'). Default 0.7. | - | src/batteries/llm/litert_lm/types.ts:167 | | thoughtSurfacing? | "all" | "all-self" | "latest-self" | Which thoughts are surfaced into history. | - | src/batteries/llm/litert_lm/types.ts:226 | | tokenEncoding? | | TokenEncodingId | null | Token encoding used for context-window accounting, or null to disable accounting (default null). | - | src/batteries/llm/litert_lm/types.ts:228 | | toolCallParser? | | ToolCallParserName | ToolCallParserFn | How to parse tool calls out of the model's text output. LiteRT-LM (v0.13.1) is text-in/text-out: the model emits tool calls as family-specific text, not a structured field. A family name, 'auto' (try-all in priority order — the default), 'none' (disable), or a custom ToolCallParserFn. | - | src/batteries/llm/litert_lm/types.ts:247 | | toolDelivery? | "prompt" | "native" | How tool definitions are delivered to the model. Defaults to 'prompt'. - 'prompt' — render the tool definitions as a text block in the system prompt and parse the model's emitted call from its output (via toolCallParser). The portable path: LiteRT-LM applies the model's OWN bundled chat template, and the Gemma-4 .litertlm template's tools branch is broken (passing native tools throws Failed to apply template: undefined value in the wasm runtime — a known Gemma-4 template bug). This mirrors how WebLLM/MLC and Open WebUI's default mode give Gemma tools. - 'native' — pass tool definitions via preface.tools (the chat-template path). Use ONLY for models whose template correctly renders a tools section. | - | src/batteries/llm/litert_lm/types.ts:270 | | topK? | number | Top-K cutoff (used by 'top-k'). Default 40. | - | src/batteries/llm/litert_lm/types.ts:169 | | topP? | number | Top-P (nucleus) cutoff (used by 'top-p'). Default 0.95. | - | src/batteries/llm/litert_lm/types.ts:171 | | unsupportedMediaPolicy? | UnsupportedMediaPolicy | How to handle media the model cannot natively consume (default 'throw'). | - | src/batteries/llm/litert_lm/types.ts:238 | | visionModalityEnabled? | boolean | Enable vision input. Maps to SessionConfig.visionModalityEnabled. When set, a user Message's image attachments map to LiteRT {type:'image', path:'data:…'} content items; otherwise they degrade via unsupportedMediaPolicy. See audioModalityEnabled for the 0.13.1 runtime-vs-types caveat (gated on a real-model proof). | - | src/batteries/llm/litert_lm/types.ts:210 |