From 0415052872835c2ce7aec4cf7812a092b865b88e Mon Sep 17 00:00:00 2001 From: viettranx Date: Fri, 20 Mar 2026 18:27:18 +0700 Subject: [PATCH] fix(tools): strip tab indent from cron description, restore lost context Remove leading tabs that wasted tokens in LLM system prompt. Restore timezone example (Asia/Ho_Chi_Minh) and channel auto-fill info that were dropped in #307. --- internal/tools/cron.go | 130 +++++++++++++++++------------------------ 1 file changed, 55 insertions(+), 75 deletions(-) diff --git a/internal/tools/cron.go b/internal/tools/cron.go index 68711381..20efcf87 100644 --- a/internal/tools/cron.go +++ b/internal/tools/cron.go @@ -29,90 +29,70 @@ func (t *CronTool) Name() string { return "cron" } func (t *CronTool) Description() string { return `Manage Gateway cron jobs. - Always send a JSON object with an "action" field. +Always send a JSON object with an "action" field. - VALID ACTIONS AND EXACT PAYLOAD SHAPES: - 1) status - { - "action": "status" - } +VALID ACTIONS AND EXACT PAYLOAD SHAPES: +1) status +{ "action": "status" } - 2) list - { - "action": "list", - "includeDisabled": true|false // optional, default false - } +2) list +{ "action": "list", "includeDisabled": true|false } - 3) add - { - "action": "add", - "job": { - "name": "string", // required, lowercase slug: [a-z0-9-]+ - "schedule": { ... }, // required - "message": "string", // required - "deliver": true|false, // optional, default false - "channel": "string", // optional - "to": "string", // optional - "agentId": "string", // optional, defaults to current agent - "deleteAfterRun": true|false // optional, default true for schedule.kind="at" - } - } +3) add +{ + "action": "add", + "job": { + "name": "string", // required, lowercase slug: [a-z0-9-]+ + "schedule": { ... }, // required + "message": "string", // required + "deliver": true|false, // optional, default false + "channel": "string", // optional, auto-filled from current channel context + "to": "string", // optional + "agentId": "string", // optional, defaults to current agent + "deleteAfterRun": true|false // optional, default true for schedule.kind="at" + } +} - 4) update - { - "action": "update", - "jobId": "string", // required - "patch": { - "name": "string", // optional - "schedule": { ... }, // optional - "message": "string", // optional - "deliver": true|false, // optional - "channel": "string", // optional - "to": "string", // optional - "agentId": "string", // optional - "deleteAfterRun": true|false, // optional - "disabled": true|false // optional - } - } +4) update +{ + "action": "update", + "jobId": "string", + "patch": { + "name": "string", + "schedule": { ... }, + "message": "string", + "deliver": true|false, + "channel": "string", + "to": "string", + "agentId": "string", + "deleteAfterRun": true|false, + "disabled": true|false + } +} - 5) remove - { - "action": "remove", - "jobId": "string" - } +5) remove +{ "action": "remove", "jobId": "string" } - 6) run - { - "action": "run", - "jobId": "string" - } +6) run +{ "action": "run", "jobId": "string" } - 7) runs - { - "action": "runs", - "jobId": "string" - } +7) runs +{ "action": "runs", "jobId": "string" } - SCHEDULE SCHEMA: +SCHEDULE SCHEMA: +- at: { "kind": "at", "atMs": } +- every: { "kind": "every", "everyMs": } +- cron: { "kind": "cron", "expr": "<5-field cron>", "tz": "" } - - at: - { "kind": "at", "atMs": } - - - every: - { "kind": "every", "everyMs": } - - - cron: - { "kind": "cron", "expr": "<5-field cron expression>", "tz": "" } - - RULES: - - For action="add", send the job inside "job". Do not place job fields at the root level. - - For action="update", send changes inside "patch". Do not place patch fields at the root level. - - Always use "jobId". Do not use "id" unless explicitly required by older compatibility code. - - "name", "schedule", and "message" are required for add. - - "name" must match: lowercase letters, numbers, hyphens only. - - Before creating or updating a scheduled job, call the datetime tool first to get the precise current time and unix_ms timestamp. Never guess timestamps. - - Omit optional fields when unknown; do not invent placeholder values like "", 0, or null unless required. - - Jobs run as isolated agent turns using the provided "message".` +RULES: +- For action="add", send the job inside "job". Do not place job fields at the root level. +- For action="update", send changes inside "patch". Do not place patch fields at the root level. +- Always use "jobId". Do not use "id". +- "name", "schedule", and "message" are required for add. +- "name" must match: lowercase letters, numbers, hyphens only. +- Before creating or updating a scheduled job, call the datetime tool first to get the precise current time and unix_ms timestamp. Never guess timestamps. +- Omit optional fields when unknown; do not invent placeholder values like "", 0, or null unless required. +- Jobs run as isolated agent turns using the provided "message".` } func (t *CronTool) Parameters() map[string]any {