Feature:Add Scheduled tasks - #73
Conversation
- add scheduled task CRUD, dispatch, run history, and owner-based run locking - validate schedule expressions, positive intervals, and timezone-aware next runs - add scheduled task management frontend page - append scheduled task tables to data_source.sql
|
大的PR,加一下设计思路以作记录 |
|
如果 |
- collapse AgentService chat stream overloads into ToolCallContext - move TaskType out of ToolCallContext and restore context builder - move scheduled task persistence logic out of controller - add scheduled task response DTO and scheduler service operations - split scheduled task execution from mapper-backed scheduling service
|
pls resolve conflicts |
- rename scheduler API to ScheduledAgentTaskService - split database polling into DatabaseScheduledAgentTaskDispatcher - move database claim and finish state handling into DatabaseScheduledAgentTaskRunner - keep ScheduledAgentTaskExecutor focused on agent execution only - add configuration for dispatcher mode, batch size, and executor pool settings
|
@codex review |
| public record ToolCallContext(String sessionId, Integer userId) {} | ||
| public record ToolCallContext( | ||
| String sessionId, | ||
| String userInput, |
There was a problem hiding this comment.
ToolCallContext定位是 “向工具传递业务上下文”, 详细看文档 “https://java.agentscope.io/v1/zh/docs/quickstart/agent.html#id4”
所以不要把 userInput、datasourceId 这种不向 工具传递业务上下文的放在这个对象。
userid需要保留在这个工具,因为后面鉴权的时候工具需要依赖它。
| */ | ||
| package io.github.malonetalk.enums; | ||
|
|
||
| public enum ScheduledAgentScheduleType { |
There was a problem hiding this comment.
CRON表达式已经足够表达 每天执行 这种场景了,所以这个枚举类的DAILY 可以废弃,DAILY 可以并入 CRON,但是可以保留INTERVAL ,因为分钟字段上限 59,CRON表达式表达不了
代码评审意见整体上这个 PR 的工程质量是好的:执行和调度拆开了( 核心建议一:把"执行"抽成一个框架无关的
|
任务调度用数据库锁做轻量分布式协调:多个实例轮询时,只有抢到 lock_owner + lock_until 的实例能执行。
锁不是永久锁,任务失败或实例异常后可以靠 lock_until 自动释放。
锁时长交给部署配置,避免长任务超过固定 30 分钟后被其他实例重复执行 SQL/生成报告。
普通聊天保留 ask_user 挂起能力;定时任务关闭人工追问能力,让 Agent 自己判断无法完成并结束。
强约束放在工具层,prompt 只作为行为提示,不作为可靠控制边界。
主要修改
新增了定时任务的后端 CRUD、实体、Mapper、调度器、下次执行时间计算逻辑,以及前端定时任务管理页。调度器负责轮询到期任务、抢锁、异步执行、完成后计算下一次运行时间。AgentService 和 AskUserTool 增加了 allowUserPrompt 执行上下文,用来区分普通会话和定时任务。
#36