Repository navigation
fix(cursor): Cursor threads follow the rules above the workspace, like Cursor does #35608
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
8807c8c
7a6e700
82e74b7
3666a9f
a255836
447fb74
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -56,6 +56,11 @@ import { | |
| hasCursorSkillMention, | ||
| rewriteCursorSkillMentions, | ||
| } from "./skills.ts"; | ||
| import { | ||
| CURSOR_RULES_REMOVED_NOTICE, | ||
| CursorRulesWalkStop, | ||
| readCursorRulesAboveWorkspace, | ||
| } from "./ancestorRules.ts"; | ||
| import { cursorWorkspaceMcpServers } from "./workspaceMcpServers.ts"; | ||
| import { t3OrchestrationPrompt } from "@t3tools/provider-core/server/orchestrationInstructions"; | ||
| import { buildRuntimeInstructions } from "@t3tools/provider-core/server/runtimeInstructions"; | ||
|
|
@@ -988,6 +993,7 @@ export const makeCursorAdapterV2 = Effect.fn("makeCursorAdapterV2")(function* ( | |
| const platform = yield* HostProcess.Platform; | ||
| const host = yield* ProviderHost.ProviderHost; | ||
| const mcpSessions = yield* McpProviderSessions.McpProviderSessions; | ||
| const rulesWalkStop = yield* CursorRulesWalkStop; | ||
| const adapterOptions = options; | ||
| const apiKey = adapterOptions.environment.CURSOR_API_KEY?.trim() || undefined; | ||
|
|
||
|
|
@@ -1018,6 +1024,8 @@ export const makeCursorAdapterV2 = Effect.fn("makeCursorAdapterV2")(function* ( | |
| readonly agent: string; | ||
| readonly orchestration: boolean; | ||
| readonly device: boolean; | ||
| /** The rules text the conversation was last sent, if T3 knows it. */ | ||
| readonly rules: string | undefined; | ||
| } | null>(null); | ||
| // Cursor drops a cancelled run from the conversation, so the next message carries its prompt. | ||
| const interruptedPrompt = yield* Ref.make<{ | ||
|
|
@@ -2367,23 +2375,36 @@ export const makeCursorAdapterV2 = Effect.fn("makeCursorAdapterV2")(function* ( | |
| turnInput: ProviderAdapter.ProviderAdapterV2TurnInput, | ||
| mcpServers: Record<string, McpServerConfig> | undefined, | ||
| hasDeviceTools: boolean, | ||
| delivered: { readonly orchestration: boolean; readonly device: boolean }, | ||
| delivered: { | ||
| readonly orchestration: boolean; | ||
| readonly device: boolean; | ||
| readonly rules: string | undefined; | ||
| }, | ||
| interrupted: string | undefined, | ||
| ) { | ||
| const rawText = turnInput.message.text; | ||
| if (rawText.trim() === "/compress" && turnInput.message.attachments.length === 0) { | ||
| return { message: "/compress", prompt: undefined }; | ||
| return { message: "/compress", prompt: undefined, rules: undefined }; | ||
| } | ||
| const currentRules = yield* readCursorRulesAboveWorkspace( | ||
| turnInput.runtimePolicy.cwd ?? process.cwd(), | ||
| rulesWalkStop, | ||
| ).pipe( | ||
| Effect.provideService(FileSystem.FileSystem, fileSystem), | ||
| Effect.provideService(Path.Path, path), | ||
| ); | ||
| const rules = | ||
| currentRules === delivered.rules | ||
| ? undefined | ||
| : (currentRules ?? CURSOR_RULES_REMOVED_NOTICE); | ||
|
Comment on lines
+2397
to
+2399
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Send the removal notice after a restart when earlier rules may have been delivered. After a process restart, a resumed conversation starts with Track unknown delivery state separately from known absence. Use a sentinel for the unknown state. Apply it only when Extend the restart test near adapter.test.ts:869 with this sequence. Deliver rules, restart the process, delete the rules, then expect
|
||
| const resolved = yield* providerMessageTextWithAttachmentPaths({ | ||
| text: yield* resolveCursorSkillText(rawText, turnInput.runtimePolicy.cwd ?? undefined), | ||
| attachments: turnInput.message.attachments, | ||
| resolveAttachmentPath: host.resolveAttachmentPath, | ||
| resolveExtractedTextPath: host.resolveExtractedTextPath, | ||
| }); | ||
| const newText = t3OrchestrationPrompt({ | ||
| prompt: yield* providerMessageTextWithAttachmentPaths({ | ||
| text: yield* resolveCursorSkillText( | ||
| rawText, | ||
| turnInput.runtimePolicy.cwd ?? undefined, | ||
| ), | ||
| attachments: turnInput.message.attachments, | ||
| resolveAttachmentPath: host.resolveAttachmentPath, | ||
| resolveExtractedTextPath: host.resolveExtractedTextPath, | ||
| }), | ||
| prompt: rules === undefined ? resolved : `${rules}\n\n${resolved}`, | ||
| hasT3Mcp: mcpServers !== undefined, | ||
| hasDeviceTools, | ||
| orchestrationDelivered: delivered.orchestration, | ||
|
|
@@ -2432,6 +2453,7 @@ export const makeCursorAdapterV2 = Effect.fn("makeCursorAdapterV2")(function* ( | |
| return { | ||
| message: images.length === 0 ? text : ({ text, images } satisfies SDKUserMessage), | ||
| prompt: userText, | ||
| rules: currentRules, | ||
| }; | ||
| }); | ||
|
|
||
|
|
@@ -2459,13 +2481,14 @@ export const makeCursorAdapterV2 = Effect.fn("makeCursorAdapterV2")(function* ( | |
| const hasDeviceTools = | ||
| mcpServers !== undefined && mcpSession?.capabilities?.has("device") === true; | ||
| const known = yield* Ref.get(told); | ||
| // A conversation this process has not sent to was told on its first run. | ||
| // A conversation this process has not sent to was told the orchestration text on its | ||
| // first run; its rules may have changed since, so they are sent again. | ||
| const delivered = | ||
| known?.agent === agent.nativeThreadId | ||
| ? known | ||
| : { orchestration: turnInput.runOrdinal > 1, device: false }; | ||
| : { orchestration: turnInput.runOrdinal > 1, device: false, rules: undefined }; | ||
| const interrupted = yield* Ref.get(interruptedPrompt); | ||
| const { message, prompt } = yield* resolveUserMessage( | ||
| const { message, prompt, rules } = yield* resolveUserMessage( | ||
| turnInput, | ||
| mcpServers, | ||
| hasDeviceTools, | ||
|
|
@@ -2506,6 +2529,7 @@ export const makeCursorAdapterV2 = Effect.fn("makeCursorAdapterV2")(function* ( | |
| agent: agent.nativeThreadId, | ||
| orchestration: !compacted && (delivered.orchestration || mcpServers !== undefined), | ||
| device: !compacted && hasDeviceTools, | ||
| rules: compacted ? undefined : rules, | ||
| }); | ||
| if (!compacted) { | ||
| yield* Ref.set(interruptedPrompt, null); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟠 High
server/adapter.ts:2378When ancestor rules are removed while T3 is stopped, resumed turns never send
CURSOR_RULES_REMOVED_NOTICE, so the old<user_rules>block remains in conversation history. On restart,delivered.rulesandcurrentRulesare bothundefined, causing this equality check to suppress the notice; distinguish unknown delivery state from known absence so the resumed conversation sends the retraction.🤖 Copy this AI Prompt to have your agent fix this:
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Valid gap, but I'm leaving it as is. I tried a fix (since dropped from the branch): after a restart, treat a resumed conversation's delivered rules as unknown, so it gets the current rules or the removal notice. The catch is that T3 can't tell whether a resumed conversation ever had rules. So every resumed Cursor conversation would get a "rules removed" notice once after every T3 restart, even ones that never had any. It also broke the recorded Cursor resume replay in
OrchestratorReplayRecovery.integration.test.ts. Closing the gap exactly would mean reading the conversation history on the first turn after each restart: an extra Cursor API call and more code, for a rare case (rules deleted while T3 is stopped, then an old conversation resumed). If they're removed, the old rules only stay in that one conversation's history.— Claude (Opus 5.5, Claude Code), replying on Max's behalf
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I'm unable to act on this request because you do not have permissions within this repository.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I'm unable to act on this request because you do not have permissions within this repository.