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 — [FEATURE]: provider: auto-detect context window from provider · Issue #52346 · anomalyco/opencode

[FEATURE]: provider: auto-detect context window from provider #52346

New issue
Copy link
New issue
Copy link
Closed
Closed
[FEATURE]: provider: auto-detect context window from provider#52346
Copy link
Assignees
rekram1-node

Description

@dlobster7401
dlobster7401
opened on Sep 30, 2026
Issue body actions
  • I have verified this feature I'm about to request hasn't been suggested before.

Related issues: #40908 and #10759 raise the same core concern. This issue adds the concrete Ollama serve-time detection case (num_ctx + ollama ps) and the config-precedence rule as a clarifying proposal.

Summary

The model's limit.context must be set manually in the OpenCode config. For local providers like Ollama this is problematic because the effective context window is determined at serve-time (e.g. via num_ctx or OLLAMA_CONTEXT_LENGTH), can change independently of the OpenCode config, and Ollama reports that value in both its own API and its /v1/models endpoint — but nothing in the OpenCode config is auto-filled from that signal.

Problem

I have a local Ollama instance running qwen3.8:27b with num_ctx 131072 (128K). Ollama reports this correctly:

$ ollama ps
NAME           SIZE PROCESSOR  CONTEXT   UNTIL
qwen3.8:27b    17GB 100% GPU   131072    ...

The OpenAI-compatible endpoint also exposes it in /v1/models. Yet OpenCode's config only accepts a static number:

"limit": { "context": 65536 }

If Ollama's effective context changes (different model, different num_ctx, different hardware), the OpenCode value silently goes stale and the session runs at a lower-than-supported window with no warning.

Suggested behavior

When limit.context is not explicitly set in the config, auto-detect it from the provider at session start:

  • Ollama — read context_length from ollama ps or the Ollama /api/show response
  • OpenAI-compatible endpoints — read max_tokens from the /v1/models response

Use the detected value as the default. An explicit limit.context in config should always take precedence, so users who want to cap the window retain that control.

Environment

  • OpenCode version: 2.0.20
  • OS: Windows 11 (10.0.26200)
  • Provider: Ollama (local)
Reacted by madihaz

Activity

  1. github-actions
    assigned
    rekram1-node
    on Sep 30, 2026
  2. github-actions
    added
    needs:complianceThis means the issue will auto-close after 2 hours.
    on Sep 30, 2026
  3. github-actions commented on Sep 30, 2026

    @github-actions
    github-actionsBot
    on Sep 30, 2026 – with GitHub Actions
    Contributor
    More actions

    This issue doesn’t fully meet our contributing guidelines.

    What needs to be fixed:

    • Feature Request titles should start with [FEATURE]:.
    • Include the required verification checkbox from the Feature Request template.

    Please edit this issue to address the above within 2 hours, or it will be automatically closed.


    This issue might be a duplicate of existing issues. Please check:

    • #40908: Requests dynamic context-length detection from OpenAI-compatible providers’ /models endpoint, including local servers such as Ollama.
    • #10759: Requests automatic detection of Ollama model context limits via its native API.

    If you believe this was flagged incorrectly, please let a maintainer know.

  4. github-actions commented on Sep 30, 2026

    @github-actions
    github-actionsBot
    on Sep 30, 2026 – with GitHub Actions
    Contributor
    More actions

    This is still a feature request, but it does not yet meet the Feature Request template requirements. Please update the title to start with [FEATURE]: and add the template's required verification checkbox. The description already explains the need and includes provider/system context.

  5. dlobster7401
    changed the title [-]provider: auto-detect context window from provider[/-] [+][FEATURE]: provider: auto-detect context window from provider[/+] on Sep 30, 2026
  6. github-actions commented on Sep 30, 2026

    @github-actions
    github-actionsBot
    on Sep 30, 2026 – with GitHub Actions
    Contributor
    More actions

    Thanks for updating the issue—it now meets the Feature Request requirements.

  7. github-actions
    removed
    needs:complianceThis means the issue will auto-close after 2 hours.
    on Sep 30, 2026
  8. dlobster7401 commented on Sep 30, 2026

    @dlobster7401
    dlobster7401
    on Sep 30, 2026
    Author
    More actions

    Closing — confirmed via the docs that OpenCode already auto-detects context, vision, and tool-use capabilities from Ollama when limit.context is not set in the config. The original issue was a user-side misconfiguration (hardcoded limit.context lower than the provider's actual window). The only genuinely missing piece would be a warning when an explicit limit is lower than the provider-reported window — leaving that as a separate ask if needed.

  9. dlobster7401
    closed this as completedon Sep 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @rekram1-node
    rekram1-node

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

    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.