mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-05-28 20:41:23 +00:00
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:
parent
14ee7cb121
commit
19dada927a
@ -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:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user