GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(provider): auto-detect Ollama context limits by felipemadero · Pull Request #10758 · anomalyco/opencode

Conversation

@felipemadero

@felipemadero felipemadero commented Jan 27, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

tonyarnold and kevincox reacted with thumbs up emoji
All reactions
  • 👍 2 reactions
@felipemadero
feat(provider): auto-detect Ollama context limits
bb7056b
Query Ollama API to get model context limits (num_ctx) for proper
context percentage display in status bar. Detects Ollama servers
by checking if root endpoint returns "Ollama is running", then
fetches model info via /api/show. Falls back to 4096 default.
@github-actions github-actions Bot added the needs:issue label Jan 27, 2026
@github-actions

github-actions Bot commented Jan 27, 2026

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions

github-actions Bot commented Jan 27, 2026

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Based on my search, I found the following potentially related PRs:

  1. PR Adding the auto-detection of ollama local with a variable for baseURL #3726 - "Adding the auto-detection of ollama local with a variable for baseURL"

    • Adding the auto-detection of ollama local with a variable for baseURL #3726
    • Potentially related as it addresses Ollama auto-detection, though focused on baseURL variable rather than context limits
  2. PR feat(opencode): add auto model detection for OpenAI-compatible providers #8359 - "feat(opencode): add auto model detection for OpenAI-compatible providers"

    • feat(opencode): add auto model detection for OpenAI-compatible providers #8359
    • Related to auto-detection of providers, may overlap with Ollama detection logic
  3. PR fix(session): warn when context window may be too small for tool calling #7422 - "fix(session): warn when context window may be too small for tool calling"

    • fix(session): warn when context window may be too small for tool calling #7422
    • Related to context window handling, though focused on warnings rather than auto-detection

These are the closest matches, but none appear to be exact duplicates of PR #10758. You should review PR #3726 and #8359 for any overlap in Ollama auto-detection implementation logic.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot removed the needs:issue label Jan 27, 2026
@felipemadero
fix(compaction): handle models without output limit
10aa64b
When limit.output is 0, fall back to reserving 20% of context
(capped at OUTPUT_TOKEN_MAX) instead of hardcoded 32000.
This fixes compaction triggering immediately on small context
models like 16k Ollama models.
@felipemadero
felipemadero force-pushed the feat/ollama-context-limit branch from f083bcc to 10aa64b Compare January 27, 2026 03:19
@github-actions github-actions Bot mentioned this pull request Jan 27, 2026
docs: add instruction for ollama auto config cli #10769
Closed
@felipemadero
felipemadero force-pushed the feat/ollama-context-limit branch from b8ed4d9 to 10aa64b Compare January 28, 2026 02:18
@thdxr
thdxr force-pushed the dev branch from cbab81f to 2d3c7a0 Compare January 30, 2026 04:49
@opencode-agent
opencode-agent Bot force-pushed the dev branch from 00637c0 to 71e0ba2 Compare January 30, 2026 14:32
@thdxr
thdxr force-pushed the dev branch 4 times, most recently from f1ae801 to 08fa7f7 Compare January 30, 2026 14:37
@rooftop-Owl rooftop-Owl mentioned this pull request Feb 5, 2026
Local Ollama models not included in model listing, breaking plugin model discovery #12243
Closed
This was referenced Mar 9, 2026
feat: auto-detect local Ollama models #16653
Closed
feat: Ollama implementation #16681
Closed
@github-actions

github-actions Bot commented Mar 28, 2026

Copy link
Copy Markdown
Contributor

Closing this pull request because it has had no updates for more than 60 days. If you plan to continue working on it, feel free to reopen or open a new PR.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot closed this Mar 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Auto-detect Ollama model context limits

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@felipemadero
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.