Repository navigation
provider, catalog: a prompt cap above a model's window is held to the window (#1286) - #1288
Conversation
|
Input for the review of this PR (from a parallel investigation of #1286; not a verdict). 1.
The GPT-5 rows also satisfy Review test I ran on this PR's head On main it passes. 2. OpenCode's own client uses 3. For 4. One real bug in the current rule: 5. The diff deletes an unrelated existing test. What |
… window (#1286) — a catalog row with limit.input over limit.context (opencode/hy3-free's 192K over 190K, Cloudflare AI Gateway's gpt-5 at 272K over 128K, venice/openai-gpt-52) was served past its window, to the gateway's /v1/models and to every agent compacting at it. The input limit still wins wherever it sits under the window (gpt-5's 272K of its 400K, a real prompt cap; OpenCode's own client compacts at input too), and a row naming only one number keeps it. TestPluginCatalogClampsInputAboveWindow and TestWindowClampsInputAboveContext fail without the change. go vet, go build -tags nogui and go test -tags nogui ./internal/provider ./internal/catalog under a temp HOME pass.
edc0b0f to
3820c8b
Compare
|
Thanks for the detailed pass - I reproduced each point before touching the code.
Force-pushed as 3820c8b. |
yetone
left a comment
There was a problem hiding this comment.
Thanks @charan-rathore, and thanks to the #1286 reporter for the detailed write-up. Reviewed at head edc0b0f33c, merged onto main 4a8338cc in a sandbox HOME. I can't merge this as it is, for two reasons.
1. It deletes an existing test. The PR replaces the whole of internal/provider/plugin_context_test.go. That removes TestPluginModelWindow and its clinePlugin helper: a plugin model with no window takes models.dev's window under the vendor's prefix, and the user's own window set on the provider beats both (ARNO on Discord, v0.1.815). That test isn't about this change and must stay. Please add your test beside it, or in a file of its own. (I ran main's version of that test against this PR's plugins.go and it still passes, so only the guard is lost, not the behavior.)
2. input is the prompt budget, and OpenCode's own client uses it that way.
catalog.Model.Contextis documented as "how many tokens a prompt may hold": models.dev's input limit, else its context window. Plugin models getinputfrom the same models.dev data (fromModelsDevininternal/plugin/host.js).mdModel.window()prefersinputon purpose: gpt-5's 272K of its 400K is OpenAI's real prompt cap.- With this PR, a plugin serving gpt-5 goes from 272000 to 400000 on the plugin path only, while the models.dev path still says 272000. I checked this with a review test:
pluginCatalogwith{Context: 400000, Input: 272000}gives 400000 at this head and 272000 on main. An agent told 400K would send prompts OpenAI refuses past 272K. - OpenCode's
packages/opencode/src/session/overflow.tsusable(), the function the issue quotes, compacts atlimit.input - reservedwheneverinputis set. Withoutinputit compacts atcontext - maxOutput. So for space-bunny-free OpenCode itself compacts near 504K, not 1M. Today magpie matches OpenCode's own client. Withinput = context - outputthe two rules give the same budget, which is why the arithmetic in the issue lines up.
What I ran
TestPluginCatalogPrefersContextWindowfails on main'splugins.go("space-bunny-free: 524288, want 1048576") and passes with the change.TestCursorPluginContextpasses.- The gpt-5 review test above.
- Main's
TestPluginModelWindowagainst this PR's code: passes.
What would move this forward: evidence that a model's upstream accepts prompts above its limit.input, such as a real request to space-bunny-free with more than 524288 prompt tokens that succeeds. If some OpenCode entries really carry a wrong input (hy3-free's input > context looks like one), the fix belongs in that data, or in a narrowly scoped rule such as clamping input to context, with a test that gpt-5's 272K is unchanged. Not one that drops input for every plugin model.
|
Quick note since the formal review landed against the old head: current head 3820c8b implements exactly the narrow shape you described - input kept as the budget, clamped to context only when it sits above the window, gpt-5's 272K covered as a control test, and the deleted test file restored in full (diff is +64 -0 now). Details in my comment above. Ball's in your court, no rush. |
|
Re-reviewed at head Ran
Not verified: a live plugin model through the running gateway. Also, Cloudflare AI Gateway's 128000 is what models.dev says, not a value checked against Cloudflare. The clamp follows the data, and the smaller number is the safe side. space-bunny-free stays at 524288 (its |
|
Shipped in v0.1.1118. Thanks! |
Problem
A catalog row whose
limit.inputsits above itslimit.contextwas served past its window:opencode/hy3-free(190000 window, 192000 input), Cloudflare AI Gateway'sopenai/gpt-5*(128000 / 272000),venice/openai-gpt-52(256000 / 272000). Sincecatalog.Model.Contextis what the gateway's/v1/modelsserves ascontext_window/context_length/max_input_tokensand what agents compact at, those rows advertise more than the model holds.Solution
The input limit still wins wherever it sits under the window — it is the real prompt cap for the models that carry one (gpt-5's 272K of its 400K), and OpenCode's own client compacts at
inputtoo. The change only clamps a cap that exceeds the window, in both places the rule lives:pluginCatalog(plugin path) andmdModel.window()(models.dev path). A row naming only one number keeps it, as before.This reframes the PR after review on #1286's premise: for
space-bunny-freeitself the catalog entry is the wrong part (the API accepts prompts well past 524288), so that model's fix belongs in the models.dev data, not in the rule.Testing
Ran on Go 1.26.6,
-tags nogui, under a temp HOME:TestPluginCatalogClampsInputAboveWindow(hy3-free clamps 192000 -> 190000; gpt-5-codex keeps its 272000 cap; input-only and context-only fallbacks unchanged) andTestWindowClampsInputAboveContextfor the models.dev path: both fail on current main (hy3-free serves 192000; window() returns 272000 over a 128000 context), pass with the change.go test -tags nogui ./internal/provider ./internal/catalogpasses, including the restoredTestPluginModelWindow,TestCursorPluginContext, and plugin parity tests. The diff is purely additive (+64 -0).go vetandgo build -tags nogui ./...are clean.