Repository navigation
Conversation
Contributor
|
The following comment was made by an LLM, it may be inaccurate: |
1 task done
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
…iders
Custom @ai-sdk/openai-compatible providers are not in the models.dev
catalog, so models without a manual config limit carry no context window.
Auto-compaction then never fires and long sessions grow until the
upstream rejects them with context_length_exceeded.
Most OpenAI-compatible servers already advertise per-model limits on
GET {baseURL}/models. Fill the missing limit fields from that endpoint:
config limit wins per field, models.dev values are never overwritten,
discovery fails open with a short negative cache.
…t discovery Drive the real plugin effect with a fake catalog draft, config layer and fetch: fills empty limits, leaves config-owned and non-empty fields alone, and fails open per endpoint.
woodsonl
force-pushed
the
fix/openai-compatible-model-limits
branch
from
October 6, 2026 21:12
57adba8 to
111cf31
Compare
Member
|
This branch has been upgraded to V2. We're no longer taking PRs for V1. If you think this is still relevant, please port it over and open it for V2. — from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊 |
3 tasks done
3 tasks done
woodsonl
added a commit
to woodsonl/opencode
that referenced
this pull request
Oct 27, 2026
…iders
Custom OpenAI-compatible providers are not in the models.dev catalog, so
their models keep the built-in placeholder limits and auto-compaction
fires against a guess instead of the real window. Request
GET {baseURL}/models once per endpoint and fill context, input, and
output from the advertised context_length, max_input_tokens, and
max_output_tokens when those fields are still placeholders.
Configured limits win per field through the config provider transform
that runs after this plugin, and limits from models.dev or dedicated
discovery plugins are never replaced. Discovery fails open: an
unreachable or malformed endpoint keeps the last known limits and never
blocks the catalog.
Ports anomalyco#53236 to V2.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Issue for this PR
Closes #53235
Type of change
What does this PR do?
Custom
@ai-sdk/openai-compatibleproviders are not in models.dev, so without a hand-writtenlimitblock OpenCode has no context window for their models and auto-compaction cannot know when to fire. Long sessions grow until the upstream rejects them withcontext_length_exceeded.Most OpenAI-compatible servers already advertise per-model limits on
GET {baseURL}/models(vLLM, LM Studio, LiteLLM, Ollama, OpenRouter). This PR fills the missing fields from that endpoint.packages/core/src/plugin/provider/openai-compatible-limits.tsregisters a catalog transform:@ai-sdk/openai-compatibleand that have abaseURLlimitwins per field; existing values (models.dev) are never overwrittenHow did you verify your code works?
packages/core/test/openai-compatible-limits*.test.ts: parsing, auth header precedence, merge rules, and two transform-level tests driving the real plugin effect against a fake catalog, config layer and fetchtsgo --noEmitclean; oxlint 0 errorslimit; the model picks up the advertised windowScreenshots / recordings
N/A (no UI change)
Checklist