Skip to content

Commit c8a601c

Browse files
SunkenInTimeHuijirocursoragentmaria-rcks
authored
fix(cursor): /compact compacts with the SDK's summarize (pingdotgg#29398)
Co-authored-by: Gabriel Rodrigues <[email protected]> Co-authored-by: Cursor <[email protected]> Co-authored-by: maria-rcks <[email protected]>
1 parent 7cf653b commit c8a601c

9 files changed

Lines changed: 90 additions & 57 deletions

File tree

‎apps/server/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
},
3535
"dependencies": {
3636
"@anthropic-ai/claude-agent-sdk": "^0.3.276",
37-
"@cursor/sdk": "1.0.38",
37+
"@cursor/sdk": "1.2.0",
3838
"@effect/platform-node": "catalog:",
3939
"@effect/platform-node-shared": "catalog:",
4040
"@ff-labs/fff-node": "0.11.0",

‎docs/orchestration-v2/orchestrator-mcp-server.md‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,11 @@ server headers or token.
9999
### Cursor Agent SDK V2
100100

101101
Cursor receives the same authenticated HTTP MCP endpoint through the SDK's
102-
`mcpServers` agent and send options. The adapter passes the authorization header
103-
to the SDK but projects only redacted option metadata into protocol diagnostics.
102+
`mcpServers` on `Agent.create` / `Agent.resume` and each `send`. With
103+
`@cursor/sdk` 1.0.39+, send-level servers replace only the create-time inline
104+
set; ambient servers from `settingSources` (`project`, `user`, `team`, `mdm`,
105+
`plugins`) stay available. The adapter passes the authorization header to the
106+
SDK but projects only redacted option metadata into protocol diagnostics.
104107

105108
### Grok ACP V2
106109

‎docs/user/cursor.md‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,17 @@ The adapter currently uses the SDK's local-agent runtime so runs operate in the
1515
workspace. Cursor cloud agents need repository and cloud-environment configuration that T3 Code does
1616
not expose yet.
1717

18+
Custom Cursor MCP servers and plugins are not configured in T3 Code. They load from the environment
19+
machine's Cursor config when the agent opens: project `.cursor/mcp.json`, user `~/.cursor/mcp.json`,
20+
and installed plugins under `~/.cursor/plugins`. Plugin tools
21+
can appear without a login; OAuth MCP servers still need credentials. Run `agent mcp login <server>`
22+
with the cwd set to the T3 project root (tokens land in
23+
`~/.cursor/projects/<folder-slug>/mcp-auth.json`). Cursor desktop Connections auth does not write
24+
that file, and the local SDK cannot complete interactive MCP OAuth itself—auth attempts fail with
25+
messages such as "MCP authentication is not supported in local SDK runs" or that the auth server
26+
does not support dynamic client registration. After you add or change skills, plugins, or MCP
27+
servers, or after a successful CLI login, use **Restart agent session**.
28+
1829
## Sign in
1930

2031
Choose **Sign in**, then open the sign-in page and complete it in your browser. T3 Code
@@ -36,7 +47,7 @@ The adapter supports:
3647
- creating and resuming local Cursor agent threads;
3748
- changing the model and model parameters between turns;
3849
- assistant text, reasoning, tool activity, plans, and todo streaming;
39-
- thread-scoped T3 Code MCP tools;
50+
- thread-scoped T3 Code MCP tools alongside ambient Cursor MCP/plugins from disk;
4051
- image attachments;
4152
- interruption, queued app messages, and orchestrator-owned interrupt/restart steering;
4253
- provider conversation snapshots through `Agent.messages.list()`;

‎packages/provider-cursor/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
"test": "vp test run --config ../../vite.config.ts --dir ."
5050
},
5151
"dependencies": {
52-
"@cursor/sdk": "1.0.38",
52+
"@cursor/sdk": "1.2.0",
5353
"@napi-rs/keyring": "^1.3.0",
5454
"@t3tools/contracts": "workspace:*",
5555
"@t3tools/provider-core": "workspace:*",

‎packages/provider-cursor/src/server/CursorAgentSdk.ts‎

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ export interface CursorAgentSdkSendInput<Error> {
8989
readonly message: string | SDKUserMessage;
9090
readonly options?: Omit<SendOptions, "onDelta">;
9191
readonly onDelta?: (update: InteractionUpdate) => Effect.Effect<void, Error>;
92+
/** Runs `agent.summarize()` instead, which takes no message or options. */
93+
readonly summarize?: boolean;
9294
}
9395

9496
export interface CursorAgentSdkRun {
@@ -139,6 +141,8 @@ export interface CursorAgentSdkLoggedAgentOptions {
139141
export interface CursorAgentSdkLoggedSendOptions {
140142
readonly model?: SendOptions["model"];
141143
readonly mode?: SendOptions["mode"];
144+
readonly hasMcpServers?: boolean;
145+
readonly mcpServerNames?: ReadonlyArray<string>;
142146
readonly local?: {
143147
readonly force?: boolean;
144148
readonly hasCustomTools?: boolean;
@@ -298,9 +302,12 @@ export function loggedCursorSendOptions(
298302
if (options === undefined) {
299303
return {};
300304
}
305+
const mcpServerNames =
306+
options.mcpServers === undefined ? undefined : Object.keys(options.mcpServers).toSorted();
301307
return {
302308
...(options.model === undefined ? {} : { model: options.model }),
303309
...(options.mode === undefined ? {} : { mode: options.mode }),
310+
...(mcpServerNames === undefined ? {} : { hasMcpServers: true, mcpServerNames }),
304311
...(options.local === undefined
305312
? {}
306313
: {
@@ -466,16 +473,18 @@ export const makeCursorAgentSdkRunner = Effect.fn("makeCursorAgentSdkRunner")(fu
466473
const startRun = () =>
467474
Effect.tryPromise({
468475
try: () =>
469-
agent.send(sendInput.message, {
470-
...sendInput.options,
471-
onDelta: async ({ update }) => {
472-
if (!callbacksReady) {
473-
pendingUpdates.push(update);
474-
return;
475-
}
476-
await dispatchUpdate(update);
477-
},
478-
}),
476+
sendInput.summarize === true
477+
? agent.summarize()
478+
: agent.send(sendInput.message, {
479+
...sendInput.options,
480+
onDelta: async ({ update }) => {
481+
if (!callbacksReady) {
482+
pendingUpdates.push(update);
483+
return;
484+
}
485+
await dispatchUpdate(update);
486+
},
487+
}),
479488
catch: (cause) => runnerError(cause, "run.start"),
480489
});
481490
const run = yield* startRun().pipe(

‎packages/provider-cursor/src/server/adapter.test.ts‎

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ describe("CursorAdapterV2", () => {
219219
Stream.takeUntil((event) => event.type === "turn.terminal"),
220220
Stream.runCollect,
221221
);
222-
assert.isFalse(sentWithMcpOverride);
222+
assert.isTrue(sentWithMcpOverride);
223223
const rows = events.filter((event) => event.type === "subagent.updated");
224224
assert.equal(rows[0]?.subagent.status, "running");
225225
assert.equal(rows[0]?.subagent.model, model ?? null);
@@ -510,11 +510,11 @@ describe("CursorAdapterV2", () => {
510510
),
511511
);
512512

513-
it.effect("fails standalone SDK transport diagnostics and sends compaction as /compress", () =>
513+
it.effect("fails standalone SDK transport diagnostics and compacts with SDK summarize", () =>
514514
Effect.gen(function* () {
515515
const fileSystem = yield* FileSystem.FileSystem;
516516
const workspace = yield* fileSystem.makeTempDirectoryScoped({ prefix: "cursor-v2-errors-" });
517-
const sentMessages: Array<string> = [];
517+
const summarizeRequests: Array<boolean> = [];
518518
let sendCalls = 0;
519519
const instanceId = ProviderInstanceId.make("cursor");
520520
const threadId = ThreadId.make("cursor-transport-error-thread");
@@ -538,9 +538,7 @@ describe("CursorAdapterV2", () => {
538538
send: (input) =>
539539
Effect.sync(() => {
540540
sendCalls += 1;
541-
sentMessages.push(
542-
typeof input.message === "string" ? input.message : input.message.text,
543-
);
541+
summarizeRequests.push(input.summarize === true);
544542
const runId = `native-cursor-run-${sendCalls}`;
545543
return {
546544
agentId: "native-cursor-error",
@@ -551,9 +549,10 @@ describe("CursorAdapterV2", () => {
551549
status: "finished" as const,
552550
model: { id: "composer-2.5" },
553551
durationMs: 1,
554-
...(sendCalls === 1
555-
? { result: "Error: RetriableError: WritableIterable is closed" }
556-
: {}),
552+
result:
553+
sendCalls === 1
554+
? "Error: RetriableError: WritableIterable is closed"
555+
: "Summary of the conversation so far",
557556
}),
558557
cancel: Effect.void,
559558
};
@@ -646,11 +645,12 @@ describe("CursorAdapterV2", () => {
646645
attachments: [],
647646
},
648647
});
649-
yield* runtime.events.pipe(
650-
Stream.filter((event) => event.type === "turn.terminal"),
651-
Stream.runHead,
648+
const compactionEvents = yield* runtime.events.pipe(
649+
Stream.takeUntil((event) => event.type === "turn.terminal"),
650+
Stream.runCollect,
652651
);
653-
assert.equal(sentMessages[1], "/compress");
652+
assert.deepEqual(summarizeRequests, [false, true]);
653+
assert.notInclude(JSON.stringify(compactionEvents), "Summary of the conversation so far");
654654
}).pipe(
655655
Effect.scoped,
656656
Effect.provide(

‎packages/provider-cursor/src/server/adapter.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2385,15 +2385,18 @@ export const makeCursorAdapterV2 = Effect.fn("makeCursorAdapterV2")(function* (
23852385
hasDeviceTools,
23862386
delivered,
23872387
);
2388+
const compacted = message === "/compress";
23882389
const pendingUpdates: Array<InteractionUpdate> = [];
23892390
let context: ActiveCursorTurn | null = null;
2390-
// MCP send overrides replace the ambient servers loaded when the agent opens.
2391+
// Create-time and send-time mcpServers merge with settingSources (SDK >= 1.0.39).
23912392
const sdkRun = yield* agent.session
23922393
.send({
23932394
message,
2395+
summarize: compacted,
23942396
options: {
23952397
model: cursorSdkModelSelection(turnInput.modelSelection),
23962398
mode: turnInput.runtimePolicy.interactionMode === "plan" ? "plan" : "agent",
2399+
...(mcpServers === undefined ? {} : { mcpServers }),
23972400
},
23982401
onDelta: (update) => {
23992402
if (context === null) {
@@ -2405,7 +2408,6 @@ export const makeCursorAdapterV2 = Effect.fn("makeCursorAdapterV2")(function* (
24052408
},
24062409
})
24072410
.pipe(Effect.mapError(classifyCursorModelRejection(turnInput.modelSelection)));
2408-
const compacted = message === "/compress";
24092411
yield* Ref.set(told, {
24102412
agent: agent.nativeThreadId,
24112413
orchestration: !compacted && (delivered.orchestration || mcpServers !== undefined),
@@ -2469,6 +2471,8 @@ export const makeCursorAdapterV2 = Effect.fn("makeCursorAdapterV2")(function* (
24692471
if (
24702472
context !== null &&
24712473
context.assistant.nextSegment === 0 &&
2474+
// A summarize run's result is the summary, not an answer.
2475+
!compacted &&
24722476
// Text from a resume that made no progress is not the turn's answer.
24732477
!isResumeFailureAfterTurnEnded(context, result) &&
24742478
result.result !== undefined &&

‎pnpm-lock.yaml‎

Lines changed: 27 additions & 27 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎pnpm-workspace.yaml‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,12 @@ minimumReleaseAgeExclude:
227227
- "@pierre/[email protected]"
228228
- "@pierre/[email protected]"
229229
230+
- "@cursor/[email protected]"
231+
- "@cursor/[email protected]"
232+
- "@cursor/[email protected]"
233+
- "@cursor/[email protected]"
234+
- "@cursor/[email protected]"
235+
- "@cursor/[email protected]"
230236

231237
overrides:
232238
# Pin every patched package, including transitive dependencies, so lockfile-free

0 commit comments

Comments
 (0)