Skip to content

Commit 710e77e

Browse files
committed
fix(server): state t3_thread_read limits in its parameter descriptions
Codex shows models a TypeScript view of each MCP tool that drops minimum and maximum, so limit, runLimit and maxCharsPerItem looked unbounded and calls above 100, 50 and 50000 failed validation. The bounds now appear in each property's description, on the outer property because Codex also drops descriptions inside anyOf members. Assisted by: Claude (Claude Code)
1 parent 8a9d0e0 commit 710e77e

2 files changed

Lines changed: 36 additions & 3 deletions

File tree

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { expect, it } from "@effect/vitest";
2+
import { Tool } from "effect/ai";
3+
4+
import { OrchestratorToolkit } from "./tools.ts";
5+
6+
interface PropertySchema {
7+
readonly maximum?: number;
8+
readonly description?: string;
9+
readonly anyOf?: ReadonlyArray<PropertySchema>;
10+
}
11+
12+
// Codex shows models a TypeScript view of each tool that drops minimum, maximum and any
13+
// description inside anyOf, so an enforced bound must be stated on the property itself.
14+
it("states t3_thread_read numeric bounds in the parameter descriptions", () => {
15+
const schema = Tool.getJsonSchema(OrchestratorToolkit.tools.t3_thread_read) as {
16+
readonly properties: Readonly<Record<string, PropertySchema>>;
17+
};
18+
const bounded = Object.entries(schema.properties).flatMap(([name, property]) =>
19+
[property, ...(property.anyOf ?? [])]
20+
.filter((member) => member.maximum !== undefined && member.maximum < Number.MAX_SAFE_INTEGER)
21+
.map((member) => [name, property.description, member.maximum] as const),
22+
);
23+
expect(bounded.map(([name]) => name)).toEqual(["limit", "runLimit", "maxCharsPerItem"]);
24+
for (const [name, description, maximum] of bounded) {
25+
expect(description, name).toContain(String(maximum));
26+
}
27+
});

‎packages/contracts/src/orchestratorMcp.ts‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -373,9 +373,15 @@ export const OrchestratorMcpThreadReadInput = Schema.Struct({
373373
textOffset: Schema.optional(NonNegativeInt),
374374
view: Schema.optional(Schema.Literals(["messages", "activity"])),
375375
afterPosition: Schema.optional(NonNegativeInt),
376-
limit: Schema.optional(PositiveInt.check(Schema.isLessThanOrEqualTo(100))),
377-
runLimit: Schema.optional(PositiveInt.check(Schema.isLessThanOrEqualTo(50))),
378-
maxCharsPerItem: Schema.optional(PositiveInt.check(Schema.isLessThanOrEqualTo(50_000))),
376+
limit: Schema.optional(PositiveInt.check(Schema.isLessThanOrEqualTo(100))).annotate({
377+
description: "Maximum timeline items to return, from 1 to 100.",
378+
}),
379+
runLimit: Schema.optional(PositiveInt.check(Schema.isLessThanOrEqualTo(50))).annotate({
380+
description: "Maximum recent runs to return, from 1 to 50.",
381+
}),
382+
maxCharsPerItem: Schema.optional(PositiveInt.check(Schema.isLessThanOrEqualTo(50_000))).annotate({
383+
description: "Maximum text characters per item, from 1 to 50000.",
384+
}),
379385
});
380386
export type OrchestratorMcpThreadReadInput = typeof OrchestratorMcpThreadReadInput.Type;
381387

0 commit comments

Comments
 (0)