Files
openclaw/extensions/ollama/src/defaults.ts
Vito Cappello 4fdfb8b1bf fix(ollama): carry real Ollama Cloud context windows and capabilities (#126653)
* fix(ollama): carry real Ollama Cloud context windows and capabilities

The ollama-cloud catalog still described three models (minimax-m2.7, glm-5.1,
glm-5.2) plus a retired kimi-k2.5. Every other cloud model — including kimi-k3,
the current flagship — was absent, so core synthesized it at the generic
DEFAULT_CONTEXT_TOKENS of 200k. A kimi-k3 session therefore ran with 200,000 of
its real 1,048,576 token window: 80% of the context silently discarded, with no
warning anywhere in the product.

Describe the full current cloud lineup with context windows, input modalities
and reasoning support verified against live /api/show and the ollama.com model
pages. Only mistral-large-3 lacks thinking (vision + tools + cloud only).

Suffixed refs shared the same defect from the other side: the default lookup is
keyed bare, so `kimi-k3:cloud` missed it and fell to the 128k plugin default.
A hardcoded glm-5.2 literal in buildOllamaModelDefinition had been papering over
that for exactly one model; replace it with a lookup through the canonical
cloud-id normalizer, which model-reasoning.ts already owned, and drop the
duplicate spelling of that helper.

* fix(ollama): cover exact cloud catalog variants

* fix(ollama): remove invalid cloud aliases

* fix(ollama): default Ollama Cloud onboarding to minimax-m3

Cloud onboarding derives `defaultModel` from the first entry of
OLLAMA_CLOUD_DEFAULT_MODELS, so array order silently owned the out-of-box
model choice. Put minimax-m3 (524,288 ctx, thinking + tools + vision) at
index 0, add it to the bundled rows it was missing from, and document the
ordering contract at the declaration.

Pin the resolved default id in the cloud setup tests so a reorder cannot
move it unnoticed, and align the provider doc's onboarding default and
fallback row list.

Claude-Session: https://claude.ai/code/session_01QXUQuDVataA5o16kxNnmoX

* fix(ollama): preserve default and shared model contracts

* test(ollama): consolidate cloud setup capability expectations

---------

Co-authored-by: VACInc <3279061+VACInc@users.noreply.github.com>
Co-authored-by: Peter Steinberger <steipete@gmail.com>
2026-08-20 08:46:39 -07:00

67 lines
2.2 KiB
TypeScript

// Ollama plugin module implements defaults behavior.
export const OLLAMA_DEFAULT_BASE_URL = "http://127.0.0.1:11434";
export const OLLAMA_DEFAULT_API_KEY = "ollama-local";
const OLLAMA_DOCKER_HOST_BASE_URL = "http://host.docker.internal:11434";
export const OLLAMA_CLOUD_BASE_URL = "https://ollama.com";
export const OLLAMA_CLOUD_PROVIDER_ID = "ollama-cloud";
export const OLLAMA_GLM52_CLOUD_MODEL_ID = "glm-5.2";
/**
* Order is a contract: cloud onboarding merges this list ahead of live discovery and takes
* the first name as `defaultModel` (`setup.runtime.ts`). Reordering this array changes what
* every new setup selects, so keep the intended default at index 0.
*/
export const OLLAMA_CLOUD_DEFAULT_MODELS = [
{
id: "minimax-m2.7",
contextWindow: 196_608,
capabilities: ["completion", "thinking", "tools"],
},
{
id: "minimax-m3",
contextWindow: 524_288,
capabilities: ["completion", "thinking", "tools", "vision"],
},
{
id: "kimi-k3",
contextWindow: 1_048_576,
capabilities: ["completion", "thinking", "tools", "vision"],
},
{
id: "glm-5.1",
contextWindow: 202_752,
capabilities: ["completion", "thinking", "tools"],
},
{
id: OLLAMA_GLM52_CLOUD_MODEL_ID,
contextWindow: 1_000_000,
capabilities: ["completion", "thinking", "tools"],
},
] as const;
/** Cloud models are referenced bare, `:cloud`-suffixed, and `-cloud`-suffixed. */
export function normalizeOllamaCloudModelId(modelId: string): string {
return modelId
.trim()
.toLowerCase()
.replace(/(?::cloud|-cloud)$/, "");
}
export const OLLAMA_DEFAULT_CONTEXT_WINDOW = 128000;
export const OLLAMA_LOCAL_CONTEXT_TOKENS = 32_768;
export const OLLAMA_DEFAULT_MAX_TOKENS = 8192;
export const OLLAMA_DEFAULT_COST = {
input: 0,
output: 0,
cacheRead: 0,
cacheWrite: 0,
};
export const OLLAMA_DEFAULT_MODEL = "gemma4";
export const DEFAULT_OLLAMA_EMBEDDING_MODEL = "nomic-embed-text";
export function resolveOllamaSetupDefaultBaseUrl(env: NodeJS.ProcessEnv = process.env): string {
return ["1", "true", "yes", "on"].includes(env.OPENCLAW_DOCKER_SETUP?.trim().toLowerCase() ?? "")
? OLLAMA_DOCKER_HOST_BASE_URL
: OLLAMA_DEFAULT_BASE_URL;
}