Skip to content

[BUG] Ollama ModelConfig options (e.g. num_ctx) are defined but not propagated to runtime #1218

@egallis31

Description

@egallis31

📋 Prerequisites

  • I have searched the existing issues to avoid creating a duplicate
  • By submitting this issue, you agree to follow our Code of Conduct
  • I am using the latest version of the software
  • I have tried to clear cache/cookies or used incognito mode (if ui-related)
  • I can consistently reproduce this issue

🎯 Affected Service(s)

Controller Service

🚦 Impact/Severity

Minor inconvenience

🐛 Bug Description

The OllamaConfig.Options field in the ModelConfig CRD allows users to specify Ollama-specific parameters such as num_ctx, temperature, etc. However, these options are currently not forwarded to the runtime or Ollama API calls.

Only the host (via OLLAMA_API_BASE) and defaultHeaders are passed through the ADK translator. As a result, any values defined under ollama.options are silently ignored at runtime, despite being part of the public API schema.

This creates a mismatch between the CRD definition and actual behavior.

🔄 Steps To Reproduce

Define an Ollama ModelConfig Resource with the options spec:

# ModelConfig for granite4:3b (for general tasks, not agents)
apiVersion: kagent.dev/v1alpha2
kind: ModelConfig
metadata:
  name: granite4-3b-ollama
  namespace: kagent
spec:
  model: "granite4:3b"
  provider: Ollama
  apiKeySecret: kagent-secrets
  apiKeySecretKey: litellm-api-key
  ollama:
    host: "http://ollama:11434"
    options:
      num_ctx: "128000" # bug with passing the options to runtime agent runner

🤔 Expected Behavior

When a user defines ollama.options in a ModelConfig, those values should be passed to the Ollama provider client (LiteLLM / HTTP request) so they affect model execution. This should result in the Ollama request being executed with the specified context size and sampling parameters.

📱 Actual Behavior

Actual Behavior

  • The options map is accepted by the CRD and appears in test data
  • The ADK translator does not forward options
  • The Python runtime (LiteLLM) never receives num_ctx or other Ollama parameters
  • Only keys passed through:
    • OLLAMA_API_BASE
    • defaultHeaders

This makes ollama.options effectively a no-op.

💻 Environment

  • OS: TalosOS
  • Kuberenets: 1.34.1
  • kagent Helm Version: 0.7.8

🔧 CLI Bug Report

No response

🔍 Additional Context

DeepWiki

Relevant code paths:

  • CRD defines OllamaConfig.Options
    go/api/v1alpha2/modelconfig_types.go
  • Test YAML includes num_ctx
    go/internal/controller/translator/agent/testdata/inputs/ollama_agent.yaml
  • Translator only sets OLLAMA_API_BASE and headers
    go/internal/controller/translator/agent/adk_api_translator.go
  • Python runtime initializes LiteLLM with headers only
    python/packages/kagent-adk/src/kagent/adk/types.py

📋 Logs

Ollama:

time=2026-01-19T17:20:45.615Z level=DEBUG source=sched.go:290 msg="runner with non-zero duration has gone idle, adding timer" runner.name=registry.ollama.ai/library/granite4:3b runner.inference="[{ID:GPU-aafce598-4e49-4405-5ed6-7d8c9af80b95 Library:CUDA}]" runner.size="7.5 GiB" runner.vram="7.5 GiB" runner.parallel=1 runner.pid=1199 runner.model=/root/.ollama/models/blobs/sha256-6c02683809a8dc4eb05c78d44bc63bcd707703b078998fa58829c858ab337bb0 runner.num_ctx=40000 duration=5m0s


Manually set context via Ollama env variable to reach 40000

📷 Screenshots

No response

🙋 Are you willing to contribute?

  • I am willing to submit a PR to fix this issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions