Repository navigation
fix(server): Cursor long-context tiers turn on Max Mode - #171
Merged
Merged
Conversation
Cursor's SDK never sets RequestedModel.maxMode, so Grok 4.7 at 500K is rejected with "Invalid parameters for registry model" and 1M tiers silently run at ~300K. Hook the SDK's own protobuf runtime to set Max Mode on requests whose context tier is above 300K, as Cursor's CLI does. Ported from upstream PR pingdotgg#15884 (fixes pingdotgg#15788). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
adampeterhiggins
force-pushed
the
fix/cursor-long-context-max-mode
branch
from
October 6, 2026 09:20
a9f80dd to
fa3f1cc
Compare
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.
Problem
Choosing Grok 4.7 at 500K on Cursor fails every turn with
AI Model Not Found Invalid parameters for registry model: "grok-4.7", and the thread shows only "Provider turn failed."@cursor/sdk(1.0.31) never setsRequestedModel.maxMode(proto field 2), and Cursor serves context tiers above its standard window only in Max Mode. The 1M tiers on other models don't fail, but they silently run at about 300K.This isn't a regression from the ACP → SDK switch. The old ACP CLI only offered Grok 4.7 at 256K and had no context setting, so the old adapter dropped the 500K choice without saying so.
Fix
This ports upstream pingdotgg/t3code#15884 (still open, fixes pingdotgg#15788) unchanged, so a future upstream sync merges cleanly.
cursorSdk.tshooksproto3.util.initPartialin the SDK's own disk-backed@bufbuild/protobufbefore the SDK loads. It setsmaxModeonly onagent.v1.RequestedModelmessages whosecontextparameter is above 300K. Every other message, standard tiers, and requests that already set Max Mode are left alone. Turns, resumes and text generation all go through this loader.I checked it independently rather than relying on the upstream PR:
Cursor.models.list()catalog. Every model with a context option has a standard tier ≤ 300K (200K, 256K, 272K, 300K) and a long tier above it (500K or 1M), so the cutoff fits today's catalog. The SDK drops Cursor's per-variantis_max_modeflag, so this can't be read from the catalog.@bufbuild/protobufas an external module, andscripts/lib/cli-external-packages.tsalready ships it beside the SDK, so packaged builds share the same runtime.Cost: Max Mode is billed per token on usage-based plans, the same as picking the long tier in Cursor's own apps. It only applies when a long tier is actually sent. Options left at their default aren't sent at all today (upstream #16149), so an untouched composer still runs at the standard window. This PR doesn't change that.
docs/fork-differences.mdgets a section to remove once upstream merges pingdotgg#15884.Verification
vp test run apps/server/src/provider/cursorSdk.test.ts: 27 passed. The two new tests run the real SDKsendpath and the generated protobuf request, and both fail with the hook removed.vp test run scripts/lib/cursor-sdk-packaging.test.ts: passed.vp lintandvp fmt --checkon the changed files: clean.tsc --noEmitforapps/server: 0 errors.@cursor/sdk1.0.31, macOS, promptReply with exactly: pong:cursorSdk.tscontext=500kInvalid parameters for registry model: "grok-4.7"pongcontext=256kpongpongNot exercised: a full T3 Code turn through the UI, or Linux/Windows.
Model: Claude Opus 5.5 (1M context). Harness: Claude Code.
🤖 Generated with Claude Code