Skip to content

Commit 4dac298

Browse files
Yurii Chukhlibclaude
authored andcommitted
fix(cron): use jobId parameter instead of id for AI tool schema
Fixes parameter mismatch between AI tool schema and internal validation. The TypeBox schema now uses `jobId` for update/remove/run/runs actions, matching what users expect based on the returned job objects. Changes: - Changed parameter from `id` to `jobId` in TypeBox schema for update/remove/run/runs - Updated execute function to read `jobId` parameter - Updated tests to use `jobId` in input parameters The gateway protocol still uses `id` internally - the tool now maps `jobId` from the AI to `id` for the gateway call. Fixes #185 Co-Authored-By: Claude <[email protected]>
1 parent 28a0864 commit 4dac298

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

src/agents/tools/cron-tool.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ describe("cron tool", () => {
1616
it.each([
1717
[
1818
"update",
19-
{ action: "update", id: "job-1", patch: { foo: "bar" } },
19+
{ action: "update", jobId: "job-1", patch: { foo: "bar" } },
2020
{ id: "job-1", patch: { foo: "bar" } },
2121
],
22-
["remove", { action: "remove", id: "job-1" }, { id: "job-1" }],
23-
["run", { action: "run", id: "job-1" }, { id: "job-1" }],
24-
["runs", { action: "runs", id: "job-1" }, { id: "job-1" }],
22+
["remove", { action: "remove", jobId: "job-1" }, { id: "job-1" }],
23+
["run", { action: "run", jobId: "job-1" }, { id: "job-1" }],
24+
["runs", { action: "runs", jobId: "job-1" }, { id: "job-1" }],
2525
])("%s sends id to gateway", async (action, args, expectedParams) => {
2626
const tool = createCronTool();
2727
await tool.execute("call1", args);

src/agents/tools/cron-tool.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,29 +47,29 @@ const CronToolSchema = Type.Union([
4747
gatewayUrl: Type.Optional(Type.String()),
4848
gatewayToken: Type.Optional(Type.String()),
4949
timeoutMs: Type.Optional(Type.Number()),
50-
id: Type.String(),
50+
jobId: Type.String(),
5151
patch: Type.Object({}, { additionalProperties: true }),
5252
}),
5353
Type.Object({
5454
action: Type.Literal("remove"),
5555
gatewayUrl: Type.Optional(Type.String()),
5656
gatewayToken: Type.Optional(Type.String()),
5757
timeoutMs: Type.Optional(Type.Number()),
58-
id: Type.String(),
58+
jobId: Type.String(),
5959
}),
6060
Type.Object({
6161
action: Type.Literal("run"),
6262
gatewayUrl: Type.Optional(Type.String()),
6363
gatewayToken: Type.Optional(Type.String()),
6464
timeoutMs: Type.Optional(Type.Number()),
65-
id: Type.String(),
65+
jobId: Type.String(),
6666
}),
6767
Type.Object({
6868
action: Type.Literal("runs"),
6969
gatewayUrl: Type.Optional(Type.String()),
7070
gatewayToken: Type.Optional(Type.String()),
7171
timeoutMs: Type.Optional(Type.Number()),
72-
id: Type.String(),
72+
jobId: Type.String(),
7373
}),
7474
Type.Object({
7575
action: Type.Literal("wake"),
@@ -121,7 +121,7 @@ export function createCronTool(): AnyAgentTool {
121121
);
122122
}
123123
case "update": {
124-
const id = readStringParam(params, "id", { required: true });
124+
const id = readStringParam(params, "jobId", { required: true });
125125
if (!params.patch || typeof params.patch !== "object") {
126126
throw new Error("patch required");
127127
}
@@ -134,19 +134,19 @@ export function createCronTool(): AnyAgentTool {
134134
);
135135
}
136136
case "remove": {
137-
const id = readStringParam(params, "id", { required: true });
137+
const id = readStringParam(params, "jobId", { required: true });
138138
return jsonResult(
139139
await callGatewayTool("cron.remove", gatewayOpts, { id }),
140140
);
141141
}
142142
case "run": {
143-
const id = readStringParam(params, "id", { required: true });
143+
const id = readStringParam(params, "jobId", { required: true });
144144
return jsonResult(
145145
await callGatewayTool("cron.run", gatewayOpts, { id }),
146146
);
147147
}
148148
case "runs": {
149-
const id = readStringParam(params, "id", { required: true });
149+
const id = readStringParam(params, "jobId", { required: true });
150150
return jsonResult(
151151
await callGatewayTool("cron.runs", gatewayOpts, { id }),
152152
);

0 commit comments

Comments
 (0)