Skip to content

Auto-detect Ollama model context limits #10759

@felipemadero

Description

@felipemadero

Problem

When using Ollama as a provider, the context percentage in the status bar doesn't display because opencode doesn't know the model's context limit. Users have to manually configure limit.context for each model in their config.

Proposed Solution

Query Ollama's native API to automatically detect context limits:

  1. Detect Ollama servers by checking if GET / returns "Ollama is running"
  2. Fetch model info via POST /api/show to get num_ctx from model parameters
  3. Fall back to 4096 (Ollama's default) if not specified in the Modelfile
  4. User config limit.context takes priority if set

This enables the context percentage display without manual configuration.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions