fix(server): honor Cursor long-context selections #18700
main fromrefs/pull/18700/head·opened View on GitHubProblem#
Cursor SDK requests omit RequestedModel.maxMode, so Grok 4.7 at 500K fails with AI Model Not Found, while other long-context selections can use the wrong tier. This is the bug reported in #15788 and originally fixed by @MatthewFeroz in #15884.
Change#
This ports #15884 to packages/provider-cursor after the Cursor provider moved out of the server app. Selections above 300K set Max Mode; standard tiers remain unchanged. Credit for the original long-context fix belongs to @MatthewFeroz and the contributors to #15884; its commit remains authored by Matthew Feroz. This replaces #18685 to correct Git identity. Both commits now use emcee6798 as committer, and the test follow-up uses emcee6798 as author. The final code is identical to #18685 at 3958063ebe.
Scope and approval#
This is the same focused obvious-bug fix as #15884, with no unrelated cleanup. Relevant feedback from the original PR is preserved by narrowly patching only agent.v1.RequestedModel, retaining existing values, and testing the real SDK request path. The separate default-option issue in #16149 and generic provider-error presentation are intentionally out of scope.
Verification#
Verified on replacement head f50aad2422 before pushing, from packages/provider-cursor:
vp test run src/server/CursorSdk.test.ts src/server/sdk.test.ts— 8 tests passed, including real SDK request checks for Grok 4.7 at 500K and 256K.- Targeted format and lint checks passed.
vp run typecheckpassed with existing unrelated Effect suggestions.
The replacement commit trees and messages match #18685 exactly; only Git identity and commit metadata changed. No live authenticated Cursor turn was run on this replacement head. #15884 contains the original macOS and Linux live verification.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
Approvability#
Verdict: Approved at
f50aad2Macroscope's review found this PR approvable — The PR narrowly fixes serialization of explicitly selected Cursor long-context tiers while preserving standard requests and unrelated protobuf messages. Production behavior is confined to the affected model request, and dedicated tests cover the real SDK path and edge cases.
Notes:
- All code in this push has already been reviewed. Approvability was decided on eligibility alone.
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
-
⚙️ Run configuration
-
- Configuration used: Path: .coderabbit.config.ts
- Review profile: CHILL
- Plan: Advanced
- Run ID:
0616a43e-5520-42b7-8401-253e5df9fa94
📥 Commits
-
Reviewing files that changed from the base of the PR and between 701fc83169611473139c441bc27d5ded9612dc8d and f50aad2422042a86cee392e5e95fc56f4a325150.
📒 Files selected for processing (2)
-
packages/provider-cursor/src/server/sdk.test.tspackages/provider-cursor/src/server/sdk.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.
-
📝 Walkthrough
-
Walkthrough#
The Cursor provider wraps protobuf initialization to set Max Mode on qualifying
RequestedModelcontext tiers. New child-process tests check real SDK sends and serialized messages, including parameter preservation and unchanged input objects.Changes#
Cursor Max Mode context tiers
Layer / File(s) Summary RequestedModel initialization
packages/provider-cursor/src/server/sdk.tsThe initPartialwrapper setsmaxModetotrueforRequestedModelmessages when the parsed context tier exceeds 300,000 andmaxModeis not already enabled.SDK and serialization tests
packages/provider-cursor/src/server/sdk.test.tsChild-process probes test Max Mode values in live SDK sends and serialized messages. They also check preserved parameters, unchanged input objects, and the default value for an unrelated message type. Priority: ➖ Normal
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Bug fix
Suggested reviewers:
juliusmarminge
Merge Risk | ⚪ Minimal · up to
f50aa-
Merge Risk: ⚪ Minimal · up to
f50aaThe change appears ready to merge after normal checks. No actionable risk remains identified in the reviewed Max Mode behavior.
-
Security Architecture Review
-
Security architecture risk: 🔵 Low · up to
f50aaThe change is limited to long-context request selection and does not show a new permission or access path. Compatibility risk is low, with authenticated operation and unusual failure recovery still unverified.
Retained concerns No architecture-level concerns identified.
-
Security review details
-
Security Blast Radius
- inferred — The behavioral scope is qualifying RequestedModel construction through the patched runtime within a process, not just one test case or selection. The exact message-type guard limits the mutation, but it is not a per-user installation. No expanded credential, data-store, or environment authority was established by the inspected change.
Security Findings and Attack Paths
- inferred — The routed program-execution identifiers belong to a private test harness using an embedded program and two literal probe modes. Their source does not establish a new attacker-controlled command endpoint or a production control bypass.
Trust Boundaries and Controls
- observed — The inspected text-generation caller still requires an enabled provider and an API key before agent creation. Its workspace-isolation checks and agent options are unchanged in the full PR comparison. The new flag derivation occurs inside request construction rather than replacing those controls.
Resilience and Maintainability Implications
- inferred — The wrapper has no asynchronous step or per-request shared accumulator. Its added mutation is target-local and monotonic, so the inspected logic does not introduce a cross-request state-carrying transition. Original-initializer exceptions prevent the added tail from running; rollback of any original partial construction is not established.
-
-
-
-
Pre-merge checks |
4-
✅ Passed checks (4 passed)
-
Check name Status Explanation Title check The title clearly and concisely describes the primary change: honoring Cursor long-context selections. It uses a valid conventional commit format. Description check The description includes all required sections. It explains the problem, implementation, scope, approval basis, verification commands, test results, and known verification limits. Linked Issues check Check skipped because no linked issues were found for this pull request. Out of Scope Changes check Check skipped because no linked issues were found for this pull request.
-
✨ Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Comment `@coderabbitai help` to get the list of available commands.-
coderabbitai[bot](GitHub profile, opens in a new tab) approved these changes
Tested the Max Mode rule from this PR locally. It works for the Grok 4.7 500K failure.
This nightly (
0.0.46-nightly.20261014.3118,@cursor/sdk1.0.35) does not include the loader hook, and the server is a packaged binary, so I could not applysdk.tsitself. The local runtime still buildsRequestedModelwithoutmaxModein@cursor/sdk/dist/cjs/689.js(i.e(689)fromlocal-executor). I setmaxModeon that constructor call when thecontextparam is above 300K, matching the threshold in this PR, and made the same edit in the ESM and bundled copies.After restarting the server onto the patched runtime, Cursor runs of
grok-4.7withcontext=500kfinished. Before the edit those runs died in about a second withAI Model Not Found Invalid parameters for registry model: "grok-4.7". Finished 500K runs after the restart include2026-10-14T20:08:18Zand, on 2026-10-15, runs lasting about 17, 18, and 27 minutes. 256K still completes. I did not re-check a conversation checkpoint for a 1,000,000-token window.The edit is wiped by the next nightly, since it lives in that runtime's
node_modules. Shipping this PR is still the real fix.Hi Team, any update?
+1 Grok 4.7 at 500K always errors
Note
🤖 Claude Opus 5.5 responding on behalf of Theo
Closing: this is covered by #21074, which landed. Reopen if a needed part is still missing.
t3dotgg(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes