kilocode icon indicating copy to clipboard operation
kilocode copied to clipboard

Ollama provider: `temperature` setting is never sent to the API (top_p works correctly)

Open zombimanx2 opened this issue 1 month ago • 2 comments

Component

VS Code extension

Description

Description

When using a local Ollama model as the provider, the temperature value set in agent config (kilo.jsonc / agent settings) is never actually sent to Ollama's API. The model always runs with whatever temperature is baked into the GGUF/Modelfile, regardless of what's configured in Kilo Code.

top_p on the same agent config is applied correctly, so this appears to be a provider-specific bug scoped to the temperature field only.

Additional Testing

To rule out a type/UI issue, I also tried:

  • temperature: 0.4 → launched with temp = 1.000
  • temperature: 2 (integer) → launched with temp = 1.000
  • temperature: 2.0 → launched with temp = 1.000
  • Removed the Modelfile's own temperature override entirely (so the model's only default comes from its GGUF metadata, temp = 1.0) — result unchanged.

In every case, the UI correctly reflected the value I entered in the settings panel, and the saved JSON config correctly persisted it. Only the value actually sent to Ollama ignores it, always falling back to the model's own default of 1.0.

Separately, I also noticed the settings UI's temperature text input does not accept decimal input — pressing . does nothing. This may or may not be related to the same root cause, but is worth noting since it affects the same field.

Environment

  • Kilo Code: 7.8.18
  • Provider: Ollama (local, ollama_local)
  • Model: gemma4-code01:latest (based on Gemma 4 12B)
  • Ollama version: 0.40.13
  • OS: Linux (CachyOS, kernel 7.3.0-4-cachyos)

Hypothesis

The Ollama provider's request-building code appears to map top_p into the outgoing API request options but not temperature — i.e. a missing or broken field mapping specific to temperature on this provider path.

Supporting Log Excerpt

llama_model_loader: - kv   3:                     general.sampling.top_p f32              = 0.950000
llama_model_loader: - kv   4:                      general.sampling.temp f32              = 1.000000
...
slot launch_slot_: id  0 | task -1 | sampler params:
        top_k = 40, top_p = 0.900, min_p = 0.000, ... temp = 1.000

Plugins

None

Kilo version

7.8.18

Steps to reproduce

Steps to Reproduce

  1. Use a local Ollama model whose Modelfile/GGUF has a known default, e.g.:
    general.sampling.top_p = 0.95
    general.sampling.temp  = 1.00
    
  2. Set agent config:
    "agent": {
      "code": {
        "model": "ollama_local/<model>:latest",
        "temperature": 0.4,
        "top_p": 0.9,
        "steps": 20
      }
    }
    
  3. Reload Kilo Code, confirm the settings UI shows temperature: 0.4 and top_p: 0.9.
  4. Send a prompt and inspect the Ollama/llama-server logs for the actual sampler params used.

Expected Behavior

llama-server logs should show:

top_p = 0.900, temp = 0.400

Actual Behavior

llama-server logs show:

top_p = 0.900, temp = 1.000

top_p correctly overrides the model's baked-in default (0.95 → 0.9). temp does not override the model's baked-in default (1.00) — it stays at 1.00 regardless of what is configured.

Screenshot and/or share link

Image

Operating System

CachyOS, kernel 7.3.0-4-cachyos

Terminal

fish / konsole 26.8.2

zombimanx2 avatar Oct 30 '26 18:10 zombimanx2

I traced this on current main (0a9faeff). The temperature isn't lost in the Ollama provider itself; it's dropped by a capability gate:

  • In packages/opencode/src/session/llm/request.ts (~L150), temperature is only sent when model.capabilities.temperature is true; otherwise it's undefined. topP has no such gate, which is why top_p works.
  • For models declared in a custom provider config (like ollama_local), packages/opencode/src/provider/provider.ts (~L1589) sets capabilities.temperature = model.temperature ?? existingModel?.capabilities.temperature ?? false. A local Ollama model isn't in the models.dev catalog, so it falls back to false.

Workaround until this is decided: mark the model as supporting temperature in the provider config, e.g.

"provider": {
  "ollama_local": {
    "models": {
      "gemma4-code01:latest": { "temperature": true }
    }
  }
}

Whether an explicitly configured agent temperature should bypass the gate (or custom/local models should default to true) seems like a maintainer call, so I didn't open a PR.

rome-xi avatar Oct 31 '26 05:10 rome-xi

Hi, I'd like to work on this. Could you please assign it to me?

aj-codespy avatar Oct 31 '26 11:10 aj-codespy