GeezerVison is showing github.com — fix(cursor): refresh cached workspace model list after a Cursor model rejection by Mr-Neutr0n · Pull Request #39248 · pingdotgg/t3code
Conversation
Problem
When Cursor adds a model (such as gemini-4-neon) while a T3 Code server is already running, projects that previously ran a Cursor thread reject the new model on Agent.create, Agent.resume, and agent.send until the server restarts. Fresh scratch folders succeed immediately.
@cursor/sdk caches one CursorAgentPlatform per workspace folder in a module-level map, and each platform caches GET /v1/models in localModelListCache with no expiry or invalidation on model rejection (still present in @cursor/[email protected]). Once that cached list is stale, resolveLocalModelSelection throws ConfigurationError: Cannot use this model: ... for any newly added model.
Fixes #39240.
Change
In packages/provider-cursor/src/server/CursorAgentSdk.ts:
- Detect SDK model rejections (
ConfigurationError whose message starts with "Cannot use this model:") in both CursorAgentSdkRunner.open and CursorAgentSdkSession.send.
- Clear
localModelListCache on the workspace's CursorAgentPlatform (including the storePlatform path for moved-workspace resumes and agent.platform on send) and retry the call once.
- If the model is still rejected after that single refresh, propagate the original
ConfigurationError without looping. Skip the open retry when a custom local.store was passed, since @cursor/sdk creates an uncached platform for that call.
Scope
Fixes #39240. Changes are confined to CursorAgentSdk.ts and CursorAgentSdk.test.ts for this single bug.
Verification
- Reproduced the failure live on T3 Code Desktop 0.1.10 (
@cursor/sdk 1.3.1): launching gemini-4-neon (reasoning_effort: high) in an existing project failed with Cannot use this model: gemini-4-neon (listing gemini-4-carbon, gemini-4-hydrogen, gemini-4-argon), while launching the same model and options in a new scratch folder succeeded at the same minute.
- Added two focused tests in
packages/provider-cursor/src/server/CursorAgentSdk.test.ts before applying the fix:
- Real
@cursor/sdk test backed by a loopback /v1/models server covering create, resume, moved-workspace resume (storeCwd), and a genuinely unavailable model (confirming one refresh and no retry loop).
- Unit test for
session.send clearing agent.platform.localModelListCache once when switching to a newly added model mid-thread, and stopping after one retry for a missing model.
- Both tests failed on
main with ConfigurationError: Cannot use this model: gemini-4-neon.
- After the fix, ran:
vp test run packages/provider-cursor/src/server/CursorAgentSdk.test.ts packages/provider-cursor/src/server/adapter.test.ts: 2 files, 38 passed.
vp run check:changed: passed (unused patches, format, lint, knip, typecheck across 42 packages, 10 passed in changed test files).
- Did not run repo-wide test suites or desktop packaging builds; leaving those to CI.
Gemini 4 Neon in T3 Code (Cursor harness).
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Thanks for this. #39246 makes the same change and is the one being kept.
#39246 fixes the same stale workspace model list inside the SDK’s shared model validation. That keeps the refresh at the cache lookup and avoids retrying whole agent operations, so it is the smaller fix to carry forward.
Your coverage of resumed threads, moved workspaces, and switching models mid-thread is useful regression coverage to retain when reviewing the kept fix.
Closing as a duplicate.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Labels
size:M
30-99 changed lines (additions + deletions).
vouch:unvouched
Author is not yet trusted in the VOUCHED list.
Milestone
No milestone
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.
|