fix: make cron tool schema require message for add action

Previously the JSON schema only required "action" but the runtime
rejected empty messages, causing LLM retry loops. Making "message"
required in the schema prevents the mismatch, and the improved error
message guides the LLM to retry with the correct parameters.

Fixes #3113

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Your Name 2026-04-15 17:13:27 +08:00 committed by Xubin Ren
parent 14ee7cb121
commit 19dada927a

View File

@ -36,7 +36,7 @@ from nanobot.cron.types import CronJob, CronJobState, CronSchedule
default=True,
),
job_id=StringSchema("Job ID (for remove)"),
required=["action"],
required=["action", "message"],
)
)
class CronTool(Tool):
@ -128,7 +128,11 @@ class CronTool(Tool):
deliver: bool = True,
) -> str:
if not message:
return "Error: message is required for add"
return (
"Error: cron action='add' requires a non-empty 'message' "
"parameter describing what to do when the job triggers "
"(e.g. the reminder text). Retry including message=\"...\"."
)
if not self._channel or not self._chat_id:
return "Error: no session context (channel/chat_id)"
if tz and not cron_expr: