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 != ""
This commit is contained in:
parent
b8f8e3f25f
commit
c2d814bdc6
1 changed files with 1 additions and 2 deletions
|
|
@ -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 != ""
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue