From f3c0cb718cce44fa6a6113a43f87872b7c0e1186 Mon Sep 17 00:00:00 2001 From: stablegenius49 <185121704+stablegenius49@users.noreply.github.com> Date: Wed, 11 Mar 2026 20:05:37 -0700 Subject: [PATCH] fix: prefer named weekday cron examples --- astrbot/core/tools/cron_tools.py | 2 +- tests/unit/test_cron_tools.py | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 tests/unit/test_cron_tools.py diff --git a/astrbot/core/tools/cron_tools.py b/astrbot/core/tools/cron_tools.py index d504f128ad..b939b53fa8 100644 --- a/astrbot/core/tools/cron_tools.py +++ b/astrbot/core/tools/cron_tools.py @@ -30,7 +30,7 @@ class CreateActiveCronTool(FunctionTool[AstrAgentContext]): "properties": { "cron_expression": { "type": "string", - "description": "Cron expression defining recurring schedule (e.g., '0 8 * * *').", + "description": "Cron expression defining recurring schedule (e.g., '0 8 * * *' or '0 23 * * mon-fri'). Prefer named weekdays like 'mon-fri' or 'sat,sun' instead of numeric day-of-week ranges such as '1-5' to avoid ambiguity across cron implementations.", }, "run_at": { "type": "string", diff --git a/tests/unit/test_cron_tools.py b/tests/unit/test_cron_tools.py new file mode 100644 index 0000000000..25f7212489 --- /dev/null +++ b/tests/unit/test_cron_tools.py @@ -0,0 +1,15 @@ +"""Tests for cron tool metadata.""" + +from astrbot.core.tools.cron_tools import CreateActiveCronTool + + +def test_create_future_task_cron_description_prefers_named_weekdays(): + """The cron tool should steer users toward unambiguous named weekdays.""" + tool = CreateActiveCronTool() + + description = tool.parameters["properties"]["cron_expression"]["description"] + + assert "mon-fri" in description + assert "sat,sun" in description + assert "1-5" in description + assert "avoid ambiguity" in description