fix(server): honor Cursor long-context selections #15884
main fromrefs/pull/15884/head·opened View on GitHubProblem#
Cursor's SDK omits RequestedModel.maxMode, so selecting Grok 4.7 at 500K fails with an invalid-parameters error, while Opus 5.5 at 1M silently gets a 300K window. These are already exposed context selections in T3 Code.
Fixes #15788.
Change#
Install a compatibility hook at the shared Cursor SDK loading boundary. It sets Max Mode only on agent.v1.RequestedModel messages with a selected context tier above 300K, matching the current Cursor catalog's long-context variants. It preserves standard tiers, existing Max Mode, model IDs, and other parameters.
The hook resolves the SDK's own disk-backed protobuf dependency through createRequire, so packaged servers use the same runtime as the SDK. It covers Cursor turns, resumes, and text generation for every client using that server. No contracts or client code change. Remove the workaround when the SDK exposes Max Mode in ModelSelection.
Scope and approval#
This is a focused fix for an obvious request-construction omission, restoring the context window the user already selected. It changes only the shared SDK loader and its regression tests, with no new feature or default selection. The failure and proposed workaround are documented in the issue's investigation. No explicit maintainer approval is linked; this PR is submitted under the focused obvious-bug exception.
Verification#
Live tests used macOS, @cursor/sdk 1.0.31, authenticated Cursor SDK requests, and a separate temporary workspace and JSONL store for each run. The prompt was Reply with exactly: pong. Baselines loaded the unmodified SDK; patched runs loaded T3's shared SDK wrapper. Effective limits came from the persisted checkpoint's tokenDetails.maxTokens. The baseline SDK version is also pinned at base a1d9d72. A last known working revision and introducing commit have not been established.
| Selection | Unmodified SDK | With the fix |
|---|---|---|
Grok 4.7, context=500k | AI Model Not Found Invalid parameters for registry model: "grok-4.7" | pong, 500,000-token limit |
Opus 5.5, context=1m | pong, 300,000-token limit | pong, 1,000,000-token limit |
The patched Opus 5.5 context=300k control also returned pong with a 300,000-token limit and Max Mode off.
The automated regression exercises the real SDK's send path and generated protobuf request, stopping before transport. Additional wire-format cases cover standard tiers, decimal and uppercase tiers, missing or unknown contexts, existing Max Mode, unrelated message types, and preservation of the input selection. The new wire regression failed before the fix.
Focused checks passed:
vp test run apps/server/src/provider/cursorSdk.test.ts apps/server/src/orchestration-v2/Adapters/CursorAdapterV2.test.ts apps/server/src/orchestration-v2/Adapters/CursorAgentSdk.test.ts apps/server/src/textGeneration/CursorTextGeneration.test.ts scripts/lib/cursor-sdk-packaging.test.ts
# 37 tests passed, including the packaged-runtime probe
vp lint apps/server/src/provider/cursorSdk.ts apps/server/src/provider/cursorSdk.test.ts --report-unused-disable-directives
vp fmt --check apps/server/src/provider/cursorSdk.ts apps/server/src/provider/cursorSdk.test.ts
vp run --filter t3 typecheck
Live checks verify request acceptance and persisted effective context limits. They do not fill the entire window to stress-test compaction. Web, desktop, and mobile clients use the same server loader for Cursor turns, resumes, and text generation. Only macOS SDK execution was exercised live; browser UI, native clients, and Linux/Windows runtime behavior were not exercised. No UI code changes.
Model: gpt-6.1-sol. Harness: Codex in T3 Code.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
The fix honors the context tier already selected in T3. The live unmodified SDK test showed Opus
context=1mgetting a 300K limit and Grokcontext=500kfailing; the patched runs got the requested 1M and 500K limits. Standard tiers still leave Max Mode off. The PR does not change the catalog or default selections.The submission basis is the focused obvious-bug exception in CONTRIBUTING.md, as explained in the PR body. The process-wide hook and its effect on default long-context variants still need human eligibility review. That decision remains with maintainers; the neutral approvability result is not being treated as approval.
Navigate logical layers of code changes, visualize relationships, and explore their blast radius.
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
- Configuration used: Repository: pingdotgg/t3code/.coderabbit.yaml
- Review profile: CHILL
- Plan: Advanced
- Run ID:
7082b490-2ad4-4a16-923d-981de98ace12
📥 Commits
Reviewing files that changed from the base of the PR and between a1d9d72aefc2a388ea3915956e9d84d279c87da7 and b980c4de882a5be971c6f3c927f816eb17975e79.
📒 Files selected for processing (2)
apps/server/src/provider/cursorSdk.test.tsapps/server/src/provider/cursorSdk.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
📝 Walkthrough
Walkthrough#
The Cursor provider now enables Max Mode for
RequestedModelrequests with recognized context values greater than 300,000. Tests cover synthetic protobuf requests and real SDK requests at multiple context sizes.Changes#
Cursor long-context requests
Layer / File(s) Summary Max Mode initialization
apps/server/src/provider/cursorSdk.tsThe protobuf initializer sets maxModefor qualifyingRequestedModelcontext values when Max Mode is not already enabled. Other message types and unrecognized context values remain unchanged.Synthetic and real SDK validation
apps/server/src/provider/cursorSdk.test.tsTests check context thresholds, parameter and source-input preservation, unrelated message types, and real SDK requests. The real SDK probe blocks network access and captures requests before transport. Priority: ⬆️ High
Estimated code review effort: 3 (Moderate) | ~25 minutes
Change: Bug fix · Severity of issue fixed: High
Suggested reviewers:
juliusmarmingeMerge Risk: ⚪ Minimal · up to
b980cThe long-context request change appears mergeable after normal checks; no specific remaining risk requires a pre-merge fix.
Security Architecture Review#
Security architecture risk: 🔵 Low · up to
b980cNo expanded access or weakened security control was identified. The remaining risk is compatibility with third-party behavior, particularly for resumed or retried requests that were not directly verified.
Retained concerns No architecture-level concerns identified.
Security review details
Security Blast Radius
- inferred — The hook applies across requests using the resolved protobuf singleton within a server process. Its behavioral scope is limited by exact message-type and context predicates; any consumer constructing that same RequestedModel type through the singleton inherits the compatibility behavior. No new credential, filesystem, tool, or network authority is assigned by the hook.
Trust Boundaries and Controls
- observed — Repository-level authentication and authority assembly remain outside the compatibility hook and unchanged from the base. Catalog calls still receive an API key; orchestration still supplies explicit sandbox, settings, and tool configuration. Text generation retains its temporary workspace, custom-policy rejection, and existing sandbox fallback. External SDK enforcement ordering was not available for independent verification.
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)#
Check name Status Explanation Resolution Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold. ✅ Passed checks (4 passed)
Check name Status Explanation Linked Issues check ✅ Passed Issue #15788requires Cursor selections above 300K to use Max Mode, including Grok 4.7 at 500K and Opus 5.5 at 1M.cursorSdk.tspatches onlyagent.v1.RequestedModelwhen its context tier exceeds 3…Out of Scope Changes check ✅ Passed The diff changes only the shared Cursor SDK loader and its regression tests. The hook implements issue #15788, and the tests verify that behavior. No unrelated changes appear in the reviewed diff.Title check ✅ Passed The title clearly and concisely describes the main change: honoring Cursor long-context selections. Description check ✅ Passed The description covers the required Problem, Change, Scope and approval, and Verification sections. It explains the focused-bug exception, summarizes the implementation, and reports specific test resu… - Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
- Create a new PR
- Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Comment `@coderabbitai help` to get the list of available commands.The docstring-coverage warning does not identify missing behavior documentation. This PR adds no public API. The existing compatibility comment explains the SDK omission, affected request type, context threshold, load ordering, and removal condition. That follows AGENTS.md's guidance to keep local implementation explanations in nearby code comments. The repository's CodeRabbit configuration does not set a docstring requirement. I am retaining that explanation; no code change is warranted for this coverage warning.
I verified this live on Linux: T3 server from source,
@cursor/sdk1.0.31, no SDK preload. I compared basea1d9d72awith this PR's headb980c4de.Each side was one Cursor thread on
claude-opus-5-5(effort=high,contextWindow=1m,fastMode=false). The task read six ~296 KB files in full (about 470K tokens) and reported a key line from each. The window comes from the SDK's checkpoint token details insdk-agent-store:base a1d9d72athis PR b980c4decheckpoint max300,000 1,000,000 peak used365,000, then 90,257 after compaction 468,915, no compaction keys reported 6/6, but the model said its context was compacted partway through part4.txt6/6 Controls on this PR:
contextWindow=300kgives 300,000, so the standard tier is unchanged.contextWindow=1mwithfastMode=truegives 1,000,000.
It merges cleanly into
main@e22c8804.Not tested: Grok 4.7 at 500K, GPT-5.6 and Sonnet long context, macOS, Windows, and the desktop build.
Model: Claude Opus 5.5 (1M). Harness: Claude Code in T3 Code.
Related: #16149. Options left at their default aren't sent at all, so a
delegate_taskwithoutcontextWindow, or a thread whose composer was never touched, still runs at 300K with this PR, while the picker shows 1M.juliusmarminge added labelsmacroscope-review
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
Great work thanks!
Note
Written by
claude-opus-5-5on behalf of MariaThanks for this. I'm closing it as part of PR triage. Another PR already covers the same fix.
From the review: Long-context max mode is still missing, but this patches removed server files; #18700 carries the same fix in the current cursor provider package.
It has also had no activity for 10 days. If this is still important to you, message me on Twitter at @maria_rcks and I'll take another look.
maria-rcks closed this
Sign in to join this conversation.
Approvability#
Verdict: Approved at
b980c4dMacroscope's review found this PR approvable — This is a narrowly scoped Cursor SDK compatibility fix that restores already-exposed long-context selections by setting Max Mode only for requests above 300K. Existing standard requests remain unchanged, and the production path is covered by focused protobuf and real SDK send-path tests.
Notes:
- Diff unchanged. Approvability was decided on eligibility alone.
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).