Merge pull request #1570 from alexhoshina/fix/cron-deliver-default-false
fix(cron): default scheduled jobs to agent execution
This commit is contained in:
commit
dfafdf7c53
2 changed files with 25 additions and 3 deletions
|
|
@ -96,7 +96,7 @@ func (t *CronTool) Parameters() map[string]any {
|
||||||
},
|
},
|
||||||
"deliver": map[string]any{
|
"deliver": map[string]any{
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"description": "If true, send message directly to channel. If false, let agent process message (for complex tasks). Default: true",
|
"description": "If true, send message directly to channel. If false, let agent process message (for complex tasks). Default: false",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"required": []string{"action"},
|
"required": []string{"action"},
|
||||||
|
|
@ -174,8 +174,8 @@ func (t *CronTool) addJob(ctx context.Context, args map[string]any) *ToolResult
|
||||||
return ErrorResult("one of at_seconds, every_seconds, or cron_expr is required")
|
return ErrorResult("one of at_seconds, every_seconds, or cron_expr is required")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read deliver parameter, default to true
|
// Read deliver parameter, default to false so scheduled tasks execute through the agent
|
||||||
deliver := true
|
deliver := false
|
||||||
if d, ok := args["deliver"].(bool); ok {
|
if d, ok := args["deliver"].(bool); ok {
|
||||||
deliver = d
|
deliver = d
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -114,3 +114,25 @@ func TestCronTool_NonCommandJobAllowedFromRemoteChannel(t *testing.T) {
|
||||||
t.Fatalf("expected non-command reminder to succeed from remote channel, got: %s", result.ForLLM)
|
t.Fatalf("expected non-command reminder to succeed from remote channel, got: %s", result.ForLLM)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestCronTool_NonCommandJobDefaultsDeliverToFalse(t *testing.T) {
|
||||||
|
tool := newTestCronTool(t)
|
||||||
|
ctx := WithToolContext(context.Background(), "telegram", "chat-1")
|
||||||
|
result := tool.Execute(ctx, map[string]any{
|
||||||
|
"action": "add",
|
||||||
|
"message": "send me a poem",
|
||||||
|
"at_seconds": float64(600),
|
||||||
|
})
|
||||||
|
|
||||||
|
if result.IsError {
|
||||||
|
t.Fatalf("expected non-command reminder to succeed, got: %s", result.ForLLM)
|
||||||
|
}
|
||||||
|
|
||||||
|
jobs := tool.cronService.ListJobs(false)
|
||||||
|
if len(jobs) != 1 {
|
||||||
|
t.Fatalf("expected 1 job, got %d", len(jobs))
|
||||||
|
}
|
||||||
|
if jobs[0].Payload.Deliver {
|
||||||
|
t.Fatal("expected deliver=false by default for non-command jobs")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue