From c2d814bdc6e57827648ecdf4ea73a56746189eae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E8=B7=AF=E8=B7=AF?= Date: Wed, 4 Mar 2026 09:12:32 +0800 Subject: [PATCH] fix(cron): validate schedule params to prevent LLM default values from hijacking priority LLMs often fill unused optional parameters with default values (e.g., at_seconds=0). Go's type assertion on float64 returns true for zero values, causing at_seconds to always win the priority check. This turns all recurring tasks (every_seconds, cron_expr) into one-time 'at' tasks with deleteAfterRun=true. Add value validity checks after type assertions: - hasAt requires atSeconds > 0 - hasEvery requires everySeconds > 0 - hasCron requires cronExpr != "" --- pkg/tools/cron.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkg/tools/cron.go b/pkg/tools/cron.go index 6af0aa9e1..1ff036d03 100644 --- a/pkg/tools/cron.go +++ b/pkg/tools/cron.go @@ -141,8 +141,7 @@ func (t *CronTool) addJob(ctx context.Context, args map[string]any) *ToolResult everySeconds, hasEvery := args["every_seconds"].(float64) cronExpr, hasCron := args["cron_expr"].(string) - // Fix: type assertions return true for zero values, need additional validity checks - // This prevents LLMs that fill unused optional parameters with defaults (0) from triggering wrong type + // Validate: ignore zero/empty values (LLMs often send default 0 for unused params) hasAt = hasAt && atSeconds > 0 hasEvery = hasEvery && everySeconds > 0 hasCron = hasCron && cronExpr != ""