Interface: OllamaAdapterOptions
Defined in: src/batteries/llm/ollama/types.ts:337
Configuration options for the native Ollama /api/chat adapter.
Properties
| Property | Type | Description | Defined in |
|---|---|---|---|
apiKey? | string | Bearer token for cloud Ollama (https://ollama.com). Omit for local (no auth). | src/batteries/llm/ollama/types.ts:340 |
autoAck? | boolean | Whether the executor acks automatically on a tool-call-free terminal answer. | src/batteries/llm/ollama/types.ts:381 |
baseURL? | string | Endpoint 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? | ChatCompletionsBucketOrder | Determines order of the system-prompt content buckets in history assembly. | src/batteries/llm/ollama/types.ts:365 |
contextWindow? | number | Size 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) => ToolRegistry | OPTIONAL 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? | OllamaFormat | Structured-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 | number | How long the model stays resident after the request (e.g. '5m', 0 to unload). | src/batteries/llm/ollama/types.ts:395 |
localToolCallParser? | | ToolCallParserName | ToolCallParserFn | OPTIONAL 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 |
model | string | Required. The Ollama model name (e.g. llama3.2, gpt-oss:120b for cloud). | src/batteries/llm/ollama/types.ts:387 |
onPromptAssembled? | PromptAssembledObserverFn | Observe 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? | RawGenerationObserverFn | Observe 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? | OllamaRuntimeOptions | Native 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? | number | Request timeout in milliseconds for API calls. | src/batteries/llm/ollama/types.ts:361 |
retry? | ChatCompletionsRetryConfig | Configures request retry behavior. | src/batteries/llm/ollama/types.ts:363 |
selfIdentity? | string | Unique identity label for the assistant instance. | src/batteries/llm/ollama/types.ts:369 |
spoolStore? | SpoolStore | Backing store for string / Uint8Array tool returns; defaults to a per-dispatch in-memory store. | src/batteries/llm/ollama/types.ts:379 |
stream? | boolean | Whether to stream the response chunk by chunk. | src/batteries/llm/ollama/types.ts:357 |
streamIdleTimeoutMs? | number | Idle timeout in milliseconds for the stream before aborting. | src/batteries/llm/ollama/types.ts:359 |
think? | OllamaThink | Native 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 | null | Tokenizer encoding configuration for token counting. | src/batteries/llm/ollama/types.ts:373 |
toolCallIdFilter? | ToolCallIdFilterFn | Optional ingress hook for adapting provider tool-call ids; absent preserves the incoming id. | src/batteries/llm/ollama/types.ts:431 |
unsupportedMediaPolicy? | UnsupportedMediaPolicy | Policy for handling a @nhtio/adk!Media whose modality the Ollama wire cannot represent. | src/batteries/llm/ollama/types.ts:383 |