Skip to content
5 min read · 1,089 words

Interface: OllamaAdapterOptions ​

Defined in: src/batteries/llm/ollama/types.ts:337

Configuration options for the native Ollama /api/chat adapter.

Properties ​

PropertyTypeDescriptionDefined in
apiKey?stringBearer token for cloud Ollama (https://ollama.com). Omit for local (no auth).src/batteries/llm/ollama/types.ts:340
autoAck?booleanWhether the executor acks automatically on a tool-call-free terminal answer.src/batteries/llm/ollama/types.ts:381
baseURL?stringEndpoint base URL. The adapter targets <baseURL>/api/chat. Defaults to http://localhost:11434 (local); cloud is https://ollama.com. Native Ollama is HTTP-only — for a Unix-socket deployment, point this at an HTTP bridge (nginx proxy_pass / socat) or inject a custom OllamaAdapterOptions.fetch instead.src/batteries/llm/ollama/types.ts:347
bucketOrder?ChatCompletionsBucketOrderDetermines order of the system-prompt content buckets in history assembly.src/batteries/llm/ollama/types.ts:365
contextWindow?numberSize of the model's token context window (the ADK guard, independent of num_ctx).src/batteries/llm/ollama/types.ts:367
fetch?{ (input: URL | RequestInfo, init?: RequestInit): Promise<Response>; (input: string | URL | Request, init?: RequestInit): Promise<Response>; }Custom fetch implementation. Use to reach a Unix-socket Ollama via a custom transport (e.g. undici with a unix: socket path) — native Ollama is HTTP-only, so socket access is a fetch/bridge concern, not an adapter option.src/batteries/llm/ollama/types.ts:355
forgeToolsFilter?(forged: ToolRegistry, ctx: DispatchContext) => ToolRegistryOPTIONAL hook to SHAPE the artifact-query tools forged from prior-turn SpooledArtifact results, before they merge into the visible tool set. Remarks When a prior tool returned a @nhtio/adk!SpooledArtifact, this battery forges that artifact class's reader tools (via ctor.forgeTools(ctx)) so the model can read the handle. A JSON artifact forges ~14 readers (~2.4k tokens of tool schema) — an unsheddable floor on a tight window, because the forge happens INSIDE the battery, downstream of any middleware subtractive pass. This hook lets the ASSEMBLER shape that forged set: it receives the merged forged registry + the dispatch context and returns a (possibly narrowed) registry, applied BEFORE the merge with ctx.tools. e.g. return only the core readers (artifact_head, artifact_json_get) so a tight window fits; the rest stay reachable via tool_catalog/call_a_tool. Default absent = identity (all forged tools) = fully backward-compatible. The battery stays BUDGET-AGNOSTIC (per the CONTRIBUTING size-threshold rule): it does NOT measure or compare against contextWindow — it just applies whatever filter the assembler supplied. Any budget logic lives in the caller's filter (middleware-side), which legitimately knows the turn's budget.src/batteries/llm/ollama/types.ts:450
format?OllamaFormatStructured-output control: 'json' or a JSON schema object.src/batteries/llm/ollama/types.ts:391
headers?Record<string, string>Custom HTTP headers sent with every request (override built defaults, including auth).src/batteries/llm/ollama/types.ts:349
helpers?Partial<OllamaHelpers>Optional overrides for the Ollama translation helpers.src/batteries/llm/ollama/types.ts:377
keep_alive?string | numberHow long the model stays resident after the request (e.g. '5m', 0 to unload).src/batteries/llm/ollama/types.ts:395
localToolCallParser?| ToolCallParserName | ToolCallParserFnOPTIONAL fallback parser for tool calls the provider's chat template did NOT return structurally. Remarks Native /api/chat tool-calling is authoritative: when Ollama returns message.tool_calls, those are used and this option is never consulted. But small models (Gemma, Phi, and others) frequently emit a tool call in a surface form the server template does not recognize — <call:name{…}, a fenced ```json ```` block, <tool_code…>, or bare name\nkey: value— in which case the call arrives as plainmessage.contentandtool_callsis empty, silently dropping the call. This is a cross-model, cross-weight reality, not a single-provider quirk. Set this to a parser family name (e.g.'gemma'), 'auto'(try every bundled parser in priority order), or a custom ToolCallParserFn to recover such calls fromcontentONLY when the provider returned none. Recovered calls execute exactly like native ones. Default absent = disabled = today's native-only behaviour (fully backward-compatible). Mirrors the on-device batteries'toolCallParser, which parse from text unconditionally because those runtimes never return structured calls.src/batteries/llm/ollama/types.ts:429
modelstringRequired. The Ollama model name (e.g. llama3.2, gpt-oss:120b for cloud).src/batteries/llm/ollama/types.ts:387
onPromptAssembled?PromptAssembledObserverFnObserve the fully-assembled request this battery is about to POST TO Ollama — fired once per terminal generation, the instant the body is built and BEFORE the fetch, with the wire messages, tools, and the complete requestBody. The mirror of onRawGeneration. 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/ollama/types.ts:411
onRawGeneration?RawGenerationObserverFnObserve the model's RAW response for each completed generation — fired once per terminal generation, after the provider's reply is parsed but before the result is persisted, with the returned assistant content (rawText), the residual cleanedText, and the extracted reasoning / toolCalls. Purely observational (return value ignored, errors swallowed). Default absent. See RawGenerationObserverFn.src/batteries/llm/ollama/types.ts:403
options?OllamaRuntimeOptionsNative sampling/runtime parameters, sent nested under the request body's options key.src/batteries/llm/ollama/types.ts:393
replayCompatibility?readonly string[]List of replay labels supported by the assistant.src/batteries/llm/ollama/types.ts:375
requestTimeoutMs?numberRequest timeout in milliseconds for API calls.src/batteries/llm/ollama/types.ts:361
retry?ChatCompletionsRetryConfigConfigures request retry behavior.src/batteries/llm/ollama/types.ts:363
selfIdentity?stringUnique identity label for the assistant instance.src/batteries/llm/ollama/types.ts:369
spoolStore?SpoolStoreBacking store for string / Uint8Array tool returns; defaults to a per-dispatch in-memory store.src/batteries/llm/ollama/types.ts:379
stream?booleanWhether to stream the response chunk by chunk.src/batteries/llm/ollama/types.ts:357
streamIdleTimeoutMs?numberIdle timeout in milliseconds for the stream before aborting.src/batteries/llm/ollama/types.ts:359
think?OllamaThinkNative reasoning control for thinking-capable models.src/batteries/llm/ollama/types.ts:389
thoughtSurfacing?"all" | "all-self" | "latest-self"Determines which thoughts are surfaced back to the model.src/batteries/llm/ollama/types.ts:371
tokenEncoding?| TokenEncodingId | nullTokenizer encoding configuration for token counting.src/batteries/llm/ollama/types.ts:373
toolCallIdFilter?ToolCallIdFilterFnOptional ingress hook for adapting provider tool-call ids; absent preserves the incoming id.src/batteries/llm/ollama/types.ts:431
unsupportedMediaPolicy?UnsupportedMediaPolicyPolicy for handling a @nhtio/adk!Media whose modality the Ollama wire cannot represent.src/batteries/llm/ollama/types.ts:383