Skip to content

Commit d590f26

Browse files
authored
Merge pull request #5612 from modelcontextprotocol/v2/chore/5543-sequentialthinking-item-size-tests
test(sequentialthinking): characterize the absence of a per-item size cap
2 parents 31fda3e + 5b5531f commit d590f26

1 file changed

Lines changed: 69 additions & 0 deletions

File tree

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
// Characterization tests for the size of one item (#5543). The server's
2+
// documented caps are on other dimensions: MAX_THOUGHT_HISTORY bounds how many
3+
// thoughts are retained, and MAX_BOX_TEXT_WIDTH / MAX_BOX_ROWS bound what one
4+
// thought draws on stderr. Nothing bounds how large a single thought or
5+
// branchId may be: the input schema is a bare `z.string()` for both, and the
6+
// history keeps each one whole.
7+
//
8+
// These cases pin that absence, and take no position on whether a per-item cap
9+
// should exist. If one is ever added, they fail, so the change is a visible,
10+
// deliberate one rather than a silent side effect.
11+
//
12+
// Each case runs with thought logging off and on. Logging is on by default for
13+
// a real client, and drawing the box is the one step between validation and
14+
// retention that reads the whole item, so "accepted" has to hold there too.
15+
// The stderr caps themselves are covered in thought-logging.test.ts.
16+
17+
import { describe, it, expect, beforeEach, afterEach, vi } from "vitest";
18+
import { connect, parseOk, thought, type Connected } from "./helpers.js";
19+
20+
describe.each([
21+
{ logging: "off", disableThoughtLogging: "true" },
22+
{ logging: "on", disableThoughtLogging: undefined },
23+
])(
24+
"sequentialthinking item size (characterization), thought logging $logging",
25+
({ disableThoughtLogging }) => {
26+
let conn: Connected;
27+
28+
beforeEach(async () => {
29+
// With logging on, every accepted thought draws a box on stderr.
30+
vi.spyOn(console, "error").mockImplementation(() => {});
31+
conn = await connect({ disableThoughtLogging });
32+
});
33+
34+
afterEach(async () => {
35+
await conn.close();
36+
vi.restoreAllMocks();
37+
});
38+
39+
it("accepts a thought of a million characters, counted once", async () => {
40+
const result = parseOk(
41+
await conn.think(thought({ thought: "a".repeat(1_000_000) })),
42+
);
43+
expect(result.thoughtHistoryLength).toBe(1);
44+
});
45+
46+
it("accepts a thought of five thousand lines, counted once", async () => {
47+
const result = parseOk(
48+
await conn.think(thought({ thought: "line\n".repeat(5000) })),
49+
);
50+
expect(result.thoughtHistoryLength).toBe(1);
51+
});
52+
53+
it("accepts a ten-thousand-character branchId and lists it verbatim", async () => {
54+
const branchId = "b".repeat(10_000);
55+
const first = parseOk(
56+
await conn.think(thought({ branchFromThought: 1, branchId })),
57+
);
58+
expect(first.branches).toEqual([branchId]);
59+
60+
// A later, unbranched thought still reports the id untruncated: it is
61+
// read back from what the server retained, not echoed from the request.
62+
const later = parseOk(
63+
await conn.think(thought({ thoughtNumber: 2, totalThoughts: 3 })),
64+
);
65+
expect(later.branches).toEqual([branchId]);
66+
expect(later.thoughtHistoryLength).toBe(2);
67+
});
68+
},
69+
);

0 commit comments

Comments
 (0)