Skip to content

Commit fe1c613

Browse files
t3dotggclaude
andcommitted
fix(contracts): keep the one-time schedule out of the MCP context budget
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent a281472 commit fe1c613

4 files changed

Lines changed: 20 additions & 9 deletions

File tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"claudeSystemAppendBytes": 5129,
33
"codexAdditionalContextBytes": 6859,
4-
"mcpToolListJsonBytes": 46191
4+
"mcpToolListJsonBytes": 46163
55
}

‎packages/contracts/src/orchestratorMcp.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ const OrchestratorMcpSchedule = Schema.Union([
6767
OrchestratorMcpScheduleFromJsonString,
6868
]).annotate({
6969
description:
70-
"Trigger: {type:'interval',everyMs}, {type:'fixed_time',timeOfDay,weekdays?} daily, {type:'once',runAt} for one date and time, or {type:'webhook'}.",
70+
"Trigger: {type:'interval',everyMs}, {type:'fixed_time',timeOfDay,weekdays?}, {type:'once',runAt}, or {type:'webhook'}.",
7171
});
7272

7373
const OrchestratorMcpTargetOptionsFromRecord = Schema.Record(

‎packages/contracts/src/scheduledTask.test.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,15 @@ describe("ScheduledTaskSchedule", () => {
2222
everyMs: MIN_SCHEDULED_TASK_INTERVAL_MS - 1,
2323
});
2424
});
25+
26+
it("accepts a one-time run only with an offset", () => {
27+
for (const runAt of ["2026-11-03T09:00Z", "2026-11-03T09:00:00.000-08:00"]) {
28+
expect(decodeUpsertSchedule({ type: "once", runAt })).toEqual({ type: "once", runAt });
29+
}
30+
for (const runAt of ["2026-11-03T09:00", "2026-13-03T09:00Z", "tomorrow"]) {
31+
expect(() => decodeUpsertSchedule({ type: "once", runAt })).toThrow();
32+
}
33+
});
2534
});
2635

2736
it.each(["literal", " ", "\t\n", "{{body.bad", "{{unknown.field}}"])(

‎packages/contracts/src/scheduledTask.ts‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,18 @@ const ScheduledTaskFixedTimeSchedule = Schema.Struct({
4545
),
4646
});
4747

48+
const ISO_WITH_OFFSET = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:\d{2})$/;
49+
50+
// Checked by filter, not pattern, to keep the MCP tool schema small.
4851
const ScheduledTaskOnceSchedule = Schema.Struct({
4952
type: Schema.Literal("once"),
5053
runAt: TrimmedNonEmptyString.check(
51-
Schema.isPattern(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:\d{2})$/),
52-
Schema.makeFilter((value) => Number.isFinite(Date.parse(value)) || "Invalid date."),
53-
).annotate({
54-
description: "ISO 8601 date and time with an offset, such as 2026-11-02T15:00:00-08:00.",
55-
}),
56-
}).annotate({
57-
description: "Run once at this time. If the server is offline then, it runs when back.",
54+
Schema.makeFilter(
55+
(value) =>
56+
(ISO_WITH_OFFSET.test(value) && Number.isFinite(Date.parse(value))) ||
57+
"Expected an ISO date and time with an offset.",
58+
),
59+
),
5860
});
5961

6062
const ScheduledTaskWebhookSignatureFields = {

0 commit comments

Comments
 (0)