From dd6bc1dcdb51f766bf45d0cdc94f44e99a467836 Mon Sep 17 00:00:00 2001 From: eason <85663565+mango766@users.noreply.github.com> Date: Sat, 14 Mar 2026 20:52:00 +0800 Subject: [PATCH] fix: add missing spaces in cron prompt and replace deprecated utcnow() (#6192) 1. Fix missing spaces in cron job wake prompt string concatenation. Python implicit string concatenation produced: "...scheduled taskProceed..." and "...conversation.After..." which sent garbled instructions to the LLM agent, causing unreliable cron job execution. 2. Replace deprecated datetime.utcnow() with datetime.now(datetime.timezone.utc) in JWT generation. utcnow() is deprecated since Python 3.12 and returns naive datetime which can cause incorrect token expiry on non-UTC systems. Closes #6103 Closes #6165 Co-authored-by: easonysliu --- astrbot/core/cron/manager.py | 4 ++-- astrbot/dashboard/routes/auth.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/astrbot/core/cron/manager.py b/astrbot/core/cron/manager.py index d12878be3..25a3a219c 100644 --- a/astrbot/core/cron/manager.py +++ b/astrbot/core/cron/manager.py @@ -332,9 +332,9 @@ class CronJobManager: cron_job=cron_job_str ) req.prompt = ( - "You are now responding to a scheduled task" + "You are now responding to a scheduled task. " "Proceed according to your system instructions. " - "Output using same language as previous conversation." + "Output using same language as previous conversation. " "After completing your task, summarize and output your actions and results." ) if not req.func_tool: diff --git a/astrbot/dashboard/routes/auth.py b/astrbot/dashboard/routes/auth.py index 40db1f60b..1d88f6ee4 100644 --- a/astrbot/dashboard/routes/auth.py +++ b/astrbot/dashboard/routes/auth.py @@ -82,7 +82,7 @@ class AuthRoute(Route): def generate_jwt(self, username): payload = { "username": username, - "exp": datetime.datetime.utcnow() + datetime.timedelta(days=7), + "exp": datetime.datetime.now(datetime.timezone.utc) + datetime.timedelta(days=7), } jwt_token = self.config["dashboard"].get("jwt_secret", None) if not jwt_token: