From 73e80b199a97b7576fa1c7c5a93f526076d7d27b Mon Sep 17 00:00:00 2001 From: lucario <912156837@qq.com> Date: Wed, 1 Apr 2026 23:17:13 +0800 Subject: [PATCH] feat(cron): add deliver parameter to support silent jobs, default true for backward compatibility --- nanobot/agent/tools/cron.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/nanobot/agent/tools/cron.py b/nanobot/agent/tools/cron.py index 00f726c08..89b403b71 100644 --- a/nanobot/agent/tools/cron.py +++ b/nanobot/agent/tools/cron.py @@ -97,9 +97,14 @@ class CronTool(Tool): f"(e.g. '2026-02-12T10:30:00'). Naive values default to {self._default_timezone}." ), }, - "job_id": {"type": "string", "description": "Job ID (for remove)"}, - }, - "required": ["action"], + "job_id": {"type": "string", "description": "Job ID (for remove)"}, + "deliver": { + "type": "boolean", + "description": "Whether to deliver the execution result to the user channel (default true)", + "default": true + }, + }, + "required": ["action"], } async def execute( @@ -111,12 +116,13 @@ class CronTool(Tool): tz: str | None = None, at: str | None = None, job_id: str | None = None, + deliver: bool = True, **kwargs: Any, ) -> str: if action == "add": if self._in_cron_context.get(): return "Error: cannot schedule new jobs from within a cron job execution" - return self._add_job(message, every_seconds, cron_expr, tz, at) + return self._add_job(message, every_seconds, cron_expr, tz, at, deliver) elif action == "list": return self._list_jobs() elif action == "remove": @@ -130,6 +136,7 @@ class CronTool(Tool): cron_expr: str | None, tz: str | None, at: str | None, + deliver: bool = True, ) -> str: if not message: return "Error: message is required for add" @@ -171,7 +178,7 @@ class CronTool(Tool): name=message[:30], schedule=schedule, message=message, - deliver=True, + deliver=deliver, channel=self._channel, to=self._chat_id, delete_after_run=delete_after,