[PR #10758] feat(provider): auto-detect Ollama context limits #13554

Open
opened 2026-02-16 18:18:24 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/10758

State: open
Merged: No


Fixes #10759

Summary

  • Auto-detect Ollama servers by checking if GET / returns "Ollama is running"
  • Query model context limits via POST /api/show to get num_ctx from Modelfile parameters
  • Config limit.context takes priority if set by user
  • Falls back to 4096 (Ollama's default) if not specified
  • Fix compaction threshold for models without limit.output: reserve 10% of context instead of hardcoded 32000

This enables context percentage display in the status bar for Ollama models without manual configuration, and fixes compaction triggering immediately on small context models.

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/10758 **State:** open **Merged:** No --- Fixes #10759 ## Summary - Auto-detect Ollama servers by checking if `GET /` returns `"Ollama is running"` - Query model context limits via `POST /api/show` to get `num_ctx` from Modelfile parameters - Config `limit.context` takes priority if set by user - Falls back to 4096 (Ollama's default) if not specified - Fix compaction threshold for models without `limit.output`: reserve 10% of context instead of hardcoded 32000 This enables context percentage display in the status bar for Ollama models without manual configuration, and fixes compaction triggering immediately on small context models.
yindo added the pull-request label 2026-02-16 18:18:24 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#13554