Skip to content

Commit 8eea6d9

Browse files
cliffhallclaude
andcommitted
fix(everything): refuse a minted resource over the byte budget; simulate-research-query is not read-only
Copilot round 6 on #5131: - A single blob larger than MAX_MINTED_BYTES is refused rather than stored after evicting everything else; gzip-file-as-resource reports it as a tool error. - simulate-research-query creates a task (and a full store drops its oldest), so it no longer claims readOnlyHint. Part of #4852 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: cliffhall <cliff@futurescale.com>
1 parent ddbd190 commit 8eea6d9

3 files changed

Lines changed: 32 additions & 1 deletion

File tree

‎src/everything/__tests__/modern.test.ts‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,20 @@ describe("the 2026-07-28 surface", () => {
102102
expect(session.client.getServerCapabilities()?.extensions).toBeUndefined();
103103
});
104104

105+
it("marks the task-creating tools as not read-only", async () => {
106+
session = await connectModern();
107+
const { tools } = await session.client.listTools();
108+
for (const name of [
109+
"simulate-research-query",
110+
"trigger-sampling-request-async",
111+
"trigger-elicitation-request-async",
112+
]) {
113+
expect(
114+
tools.find((t) => t.name === name)?.annotations?.readOnlyHint,
115+
).toBe(false);
116+
}
117+
});
118+
105119
it("lists the capability-gated and task tools up front, and not the 2025-only toggles", async () => {
106120
session = await connectModern();
107121
expect(session.client.getProtocolEra()).toBe("modern");
@@ -650,6 +664,14 @@ describe("minted resources", () => {
650664
).rejects.toMatchObject({ code: -32602 });
651665
});
652666

667+
it("refuses one resource larger than the whole byte budget", () => {
668+
expect(() =>
669+
mintBlobResource("huge", "text/plain", "A".repeat(MAX_MINTED_BYTES + 1)),
670+
).toThrow(
671+
`Cannot keep huge for later reading: its ${MAX_MINTED_BYTES + 1} bytes of content exceed the ${MAX_MINTED_BYTES}-byte limit for minted resources`,
672+
);
673+
});
674+
653675
it("keeps at most MAX_MINTED_BYTES of content, dropping the oldest", async () => {
654676
const half = "A".repeat(MAX_MINTED_BYTES / 2);
655677
const first = mintBlobResource("first", "text/plain", half).uri;

‎src/everything/resources/minted.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ function makeRoom(bytes: number): void {
6969

7070
/**
7171
* Store a blob resource under a freshly minted URI, and return a link to it.
72+
* Throws for a blob larger than `MAX_MINTED_BYTES`.
7273
*
7374
* @param name - The resource's name, the last segment of its URI.
7475
* @param mimeType - Its MIME type.
@@ -79,6 +80,13 @@ export function mintBlobResource(
7980
mimeType: string,
8081
blob: string,
8182
): ResourceLink {
83+
// One resource larger than the whole budget is refused outright, rather
84+
// than evicting everything else and still exceeding the budget.
85+
if (blob.length > MAX_MINTED_BYTES) {
86+
throw new Error(
87+
`Cannot keep ${name} for later reading: its ${blob.length} bytes of content exceed the ${MAX_MINTED_BYTES}-byte limit for minted resources`,
88+
);
89+
}
8290
const now = Date.now();
8391
sweep(now);
8492
makeRoom(blob.length);

‎src/everything/tools/simulate-research-query.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ const config = {
7171
"input_required until the client answers its clarification request with tasks/update.",
7272
inputSchema: SimulateResearchQuerySchema,
7373
annotations: {
74-
readOnlyHint: true,
74+
// Each call creates a task, and a full task store drops its oldest one.
75+
readOnlyHint: false,
7576
destructiveHint: false,
7677
idempotentHint: false,
7778
openWorldHint: false,

0 commit comments

Comments
 (0)