Skip to content

Commit 1918681

Browse files
committed
test(cursor): prove the wire-budget consequence behind the search flag
#1832 flips `supports_search_tool` for Cursor on the reasoning that deferred discovery keeps the MCP catalog out of `exec.description`, and that inlining it can push the advertised catalog past Cursor's 120KB serialized limit. The catalog-projection tests assert the flag; nothing asserted the consequence. These measure it on the real serializer. A deferred catalog stays inside `CURSOR_TOOL_BYTES_LIMIT` and keeps both `exec` and `wait`; the same two tools exceed the cap once the nested catalog is inlined into `exec.description`. The second test pins #1830's actual symptom -- a child whose advertised catalog contains no Responses execution tool at all. Whatever else the budget drops, `exec` and `wait` must be what survives, and the trimmed result must fit. Note on scope: the flag lives in routed catalog metadata consumed by the Codex client, so it is not serialized into a Cursor turn request. Asserting it inside a protobuf test would prove nothing, which is why the two concerns stay in two files.
1 parent 4424138 commit 1918681

1 file changed

Lines changed: 67 additions & 0 deletions

File tree

‎tests/cursor-request-builder.test.ts‎

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,73 @@ describe("Cursor request builder", () => {
455455
expect(budget.tools.length).toBeLessThanOrEqual(CURSOR_TOOL_COUNT_LIMIT);
456456
});
457457

458+
459+
test("a deferred Cursor catalog stays inside the wire budget while a nested one does not (#1830)", () => {
460+
// Why #1832 flips supports_search_tool for Cursor: with deferred discovery OFF, Codex
461+
// inlines the whole MCP catalog into `exec.description` instead of leaving it callable
462+
// through tool_search. This asserts the consequence in bytes, on the real serializer,
463+
// rather than trusting the flag alone.
464+
const nestedCatalogText = Array.from({ length: 120 }, (_, index) =>
465+
`mcp__server_${index}__tool: ${"d".repeat(1_200)}`).join("\n");
466+
467+
const execDeferred = {
468+
name: "exec",
469+
namespace: "opencodex-responses",
470+
description: "Run JavaScript. Discover tools with tool_search.",
471+
parameters: { type: "object", properties: { input: { type: "string" } } },
472+
freeform: true,
473+
};
474+
const execInlined = { ...execDeferred, description: `${execDeferred.description}\n${nestedCatalogText}` };
475+
const wait = {
476+
name: "wait",
477+
namespace: "opencodex-responses",
478+
description: "Resume a running call",
479+
parameters: { type: "object", properties: { id: { type: "string" } } },
480+
};
481+
482+
// Deferred: the advertised catalog serializes well inside the cap and keeps both tools.
483+
expect(cursorMcpToolsEncodedSize([execDeferred, wait], "auto")).toBeLessThanOrEqual(CURSOR_TOOL_BYTES_LIMIT);
484+
const deferred = applyCursorToolBudget([execDeferred, wait], "auto");
485+
expect(deferred.tools).toContain(execDeferred);
486+
expect(deferred.tools).toContain(wait);
487+
expect(deferred.omitted).toHaveLength(0);
488+
489+
// Inlined: the same two tools blow the cap purely because the catalog moved into exec.
490+
expect(cursorMcpToolsEncodedSize([execInlined, wait], "auto")).toBeGreaterThan(CURSOR_TOOL_BYTES_LIMIT);
491+
});
492+
493+
test("the Responses execution bridge survives the budget even when it must be trimmed (#1830)", () => {
494+
// #1830's symptom is a child whose advertised catalog has no Responses execution tool at
495+
// all. Whatever else the budget drops, exec and wait have to be what is left.
496+
const filler = Array.from({ length: 60 }, (_, index) => ({
497+
name: `mcp_tool_${index}`,
498+
namespace: `mcp__server_${index}`,
499+
description: "z".repeat(4_000),
500+
parameters: { type: "object", properties: {} },
501+
}));
502+
const exec = {
503+
name: "exec",
504+
namespace: "opencodex-responses",
505+
description: "Run JavaScript",
506+
parameters: { type: "object", properties: { input: { type: "string" } } },
507+
freeform: true,
508+
};
509+
const wait = {
510+
name: "wait",
511+
namespace: "opencodex-responses",
512+
description: "Resume",
513+
parameters: { type: "object", properties: { id: { type: "string" } } },
514+
};
515+
516+
const catalog = [...filler, exec, wait];
517+
expect(cursorMcpToolsEncodedSize(catalog, "auto")).toBeGreaterThan(CURSOR_TOOL_BYTES_LIMIT);
518+
519+
const budget = applyCursorToolBudget(catalog, "auto");
520+
expect(budget.tools).toContain(exec);
521+
expect(budget.tools).toContain(wait);
522+
expect(cursorMcpToolsEncodedSize(budget.tools, "auto")).toBeLessThanOrEqual(CURSOR_TOOL_BYTES_LIMIT);
523+
expect(budget.omitted.length).toBeGreaterThan(0);
524+
});
458525
test("pins namespaced opencodex-responses exec ahead of filler", () => {
459526
const filler = Array.from({ length: 80 }, (_, index) => ({
460527
name: `filler_${index}`,

0 commit comments

Comments
 (0)