Your lightweight open-source personal agent.
Python agent-frameworkai-agentai-agentschatbotchatopsdiscord-botllm-agentsllmslocal-llmmcpmodel-context-protocolmulti-agentopenai-compatibleopenclawpersonal-ai-assistantpythonself-hostedtelegram-bot-ai-assistantwebuiworkflow-automation
Merge origin/main into fix/cron-contract-repeat-guard
Xubin Renadc1e843b414
diff --cc nanobot/agent/tools/cron.pyindex dd2d9d430,f1af59d76..111bb1c85--- a/nanobot/agent/tools/cron.py+++ b/nanobot/agent/tools/cron.py@@@ -14,64 -9,37 +14,62 @@@ from nanobot.agent.tools.schema importfrom nanobot.cron.service import CronServicefrom nanobot.cron.types import CronJob, CronJobState, CronSchedule--@tool_parameters(- tool_parameters_schema(- action=StringSchema("Action to perform", enum=["add", "list", "remove"]),- name=StringSchema(- "Optional short human-readable label for the job "- "(e.g., 'weather-monitor', 'daily-standup'). Defaults to first 30 chars of message."- ),- message=StringSchema(- "REQUIRED when action='add'. Instruction for the agent to execute when the job triggers "- "(e.g., 'Send a reminder to WeChat: xxx' or 'Check system status and report'). "- "Not used for action='list' or action='remove'."- ),- every_seconds=IntegerSchema(0, description="Interval in seconds (for recurring tasks)"),- cron_expr=StringSchema("Cron expression like '0 9 * * *' (for scheduled tasks)"),- tz=StringSchema(- "Optional IANA timezone for cron expressions (e.g. 'America/Vancouver'). "- "When omitted with cron_expr, the tool's default timezone applies."- ),- at=StringSchema(- "ISO datetime for one-time execution (e.g. '2026-02-12T10:30:00'). "- "Naive values use the tool's default timezone."- ),- deliver=BooleanSchema(- description="Whether to deliver the execution result to the user channel (default true)",- default=True,- ),- job_id=StringSchema("REQUIRED when action='remove'. Job ID to remove (obtain via action='list')."),- required=["action"],- )+_CRON_PARAMETERS = tool_parameters_schema(+ action=StringSchema("Action to perform", enum=["add", "list", "remove"]),+ name=StringSchema(+ "Optional short human-readable label for the job "+ "(e.g., 'weather-monitor', 'daily-standup'). Defaults to first 30 chars of message."+ ),+ message=StringSchema(- "Instruction for the agent to execute when the job triggers. "- "Required when action='add' "- "(e.g., 'Send a reminder to WeChat: xxx' or 'Check system status and report')"++ "REQUIRED when action='add'. Instruction for the agent to execute when the job triggers "++ "(e.g., 'Send a reminder to WeChat: xxx' or 'Check system status and report'). "++ "Not used for action='list' or action='remove'."+ ),+ every_seconds=IntegerSchema(0, description="Interval in seconds (for recurring tasks)"),+ cron_expr=StringSchema("Cron expression like '0 9 * * *' (for scheduled tasks)"),+ tz=StringSchema(+ "Optional IANA timezone for cron expressions (e.g. 'America/Vancouver'). "+ "When omitted with cron_expr, the tool's default timezone applies."+ ),+ at=StringSchema(+ "ISO datetime for one-time execution (e.g. '2026-02-12T10:30:00'). "+ "Naive values use the tool's default timezone."+ ),+ deliver=BooleanSchema(+ description="Whether to deliver the execution result to the user channel (default true)",+ default=True,+ ),- job_id=StringSchema("Job ID (for remove)"),++ job_id=StringSchema("REQUIRED when action='remove'. Job ID to remove (obtain via action='list')."),+ required=["action"],+ description=(+ "Action-specific parameters: add requires a non-empty message plus one schedule "+ "(every_seconds, cron_expr, or at); remove requires job_id; list only needs action."+ ),)+_CRON_PARAMETERS["oneOf"] = [+ {+ "properties": {+ "action": {"enum": ["add"]},+ "message": {"type": "string", "minLength": 1},+ },+ "required": ["action", "message"],+ },+ {+ "properties": {+ "action": {"enum": ["list"]},+ },+ "required": ["action"],+ },+ {+ "properties": {+ "action": {"enum": ["remove"]},+ },+ "required": ["action", "job_id"],+ },+]++- @tool_parameters(- _CRON_PARAMETERS- )++@tool_parameters(_CRON_PARAMETERS)class CronTool(Tool):"""Tool to schedule reminders and recurring tasks."""@@@ -171,8 -130,9 +169,9 @@@) -> str:if not message:return (- "Error: cron action='add' requires a non-empty 'message' "- "parameter describing what to do when the job triggers "+ "Error: cron action='add' requires a non-empty 'message' parameter "- "describing what to do when the job triggers. Retry including message=\"...\"."++ "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)"