@devries-cameron20 / t3code-1 / commits / 121f0cf014
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(server): t3_thread_list clamps an oversized limit instead of failing (#27814)

Co-authored-by: maria-rcks <maria@kuuro.net> Co-authored-by: Julius Marminge <julius0216@outlook.com>

MarcoDotIO committed Nov 14, 2026 at 06:09 UTC 121f0cf014dcd6e94327588bf3f1f200a5f07ad7
3 files changed +31 -16
apps/server/src/mcp/McpHttpServer.test.ts
+15
@@ -276,6 +276,7 @@ it.effect.each([
276 const layerRecordingTools = (calls: Array<unknown>) => {
277 const RecordingToolkit = Toolkit.make(
278 OrchestratorToolkit.tools.delegate_task,
279 + OrchestratorToolkit.tools.t3_thread_list,
280 OrchestratorToolkit.tools.t3_thread_read,
281 OrchestratorToolkit.tools.t3_thread_wait,
282 ProjectToolkit.tools.t3_project_update,
@@ -292,6 +293,7 @@ const layerRecordingTools = (calls: Array<unknown>) => {
293 RecordingToolkit,
294 McpToolAccess.toLayer(RecordingToolkit, {
295 delegate_task: record,
296 + t3_thread_list: record,
297 t3_thread_read: record,
298 t3_thread_wait: record,
299 t3_project_update: record,
@@ -727,6 +729,19 @@ it.effect.each(["limit", "runLimit", "maxCharsPerItem"])(
729 },
730 );
731
732 +it.effect("clamps a t3_thread_list limit above its maximum instead of rejecting the call", () => {
733 + const calls: Array<unknown> = [];
734 + return Effect.gen(function* () {
735 + yield* callTool("t3_thread_list", { allProjects: true, limit: 200 });
736 + yield* callTool("t3_thread_list", { allProjects: true, limit: 7 });
737 +
738 + expect(calls).toEqual([
739 + { allProjects: true, limit: 100 },
740 + { allProjects: true, limit: 7 },
741 + ]);
742 + }).pipe(Effect.provide(layerRecordingTools(calls)));
743 +});
744 +
745 it("keeps cross-tool routing out of the delegate_task description", () => {
746 const description = OrchestratorToolkit.tools.delegate_task.description ?? "";
747 expect(description).toContain("Start one child agent with only `task`");
apps/server/src/provider/agentContextBudget.json
+1 -1
@@ -1,5 +1,5 @@
1 {
2 "claudeSystemAppendBytes": 5930,
3 "codexAdditionalContextBytes": 7324,
4 - "mcpToolListJsonBytes": 49806
4 + "mcpToolListJsonBytes": 49792
5 }
packages/contracts/src/orchestratorMcp.ts
+15 -15
@@ -339,6 +339,20 @@ export const OrchestratorMcpEnvironmentTarget = Schema.optional(
339 }),
340 );
341
342 +// Codex hides `minimum` and `maximum` from the model, so a value above the maximum clamps on
343 +// decode instead of failing the call; pagination returns the rest. Values below 1 still fail:
344 +// 0 asks for nothing, and answering it with one item would be a different request.
345 +const clampedPositiveInt = (maximum: number) =>
346 + PositiveInt.pipe(
347 + Schema.decodeTo(
348 + PositiveInt.check(Schema.isLessThanOrEqualTo(maximum)),
349 + SchemaTransformation.transform({
350 + decode: (value) => Math.min(value, maximum),
351 + encode: (value) => value,
352 + }),
353 + ),
354 + );
355 +
356 export const OrchestratorMcpThreadListInput = Schema.Struct({
357 environmentId: OrchestratorMcpEnvironmentTarget,
358 projectId: OrchestratorMcpProjectTarget,
@@ -351,7 +365,7 @@ export const OrchestratorMcpThreadListInput = Schema.Struct({
365 snoozed: Schema.optional(Schema.Boolean),
366 includeSubagents: Schema.optional(Schema.Boolean),
367 cursor: Schema.optional(NonNegativeInt),
354 - limit: Schema.optional(PositiveInt.check(Schema.isLessThanOrEqualTo(100))),
368 + limit: Schema.optional(clampedPositiveInt(100)),
369 });
370 export type OrchestratorMcpThreadListInput = typeof OrchestratorMcpThreadListInput.Type;
371
@@ -421,20 +435,6 @@ export const OrchestratorMcpThreadListResult = Schema.Struct({
435 });
436 export type OrchestratorMcpThreadListResult = typeof OrchestratorMcpThreadListResult.Type;
437
424 -// Codex hides `minimum` and `maximum` from the model, so a value above the maximum clamps on
425 -// decode instead of failing the call; pagination returns the rest. Values below 1 still fail:
426 -// 0 asks for nothing, and answering it with one item would be a different request.
427 -const clampedPositiveInt = (maximum: number) =>
428 - PositiveInt.pipe(
429 - Schema.decodeTo(
430 - PositiveInt.check(Schema.isLessThanOrEqualTo(maximum)),
431 - SchemaTransformation.transform({
432 - decode: (value) => Math.min(value, maximum),
433 - encode: (value) => value,
434 - }),
435 - ),
436 - );
437 -
438 export const OrchestratorMcpThreadReadInput = Schema.Struct({
439 environmentId: OrchestratorMcpEnvironmentTarget,
440 threadId: ThreadId,