mirror of
https://github.com/lobehub/lobe-chat.git
synced 2026-06-17 21:08:36 +00:00
🐛 fix: update the agent cron job update way (#11877)
* feat: add the setAgentBuilderContent tools into agent group builder to slove setEditor not work * feat: update the system prompt * feat: add the maxtools result call lenght in agent config * fix: update the cronJob Update config way
This commit is contained in:
@@ -79,12 +79,35 @@ export class AgentCronJobModel {
|
||||
|
||||
// Update cron job
|
||||
async update(id: string, data: UpdateAgentCronJobData): Promise<AgentCronJob | null> {
|
||||
// Check if critical fields (cronPattern or timezone) are being changed
|
||||
// If so, reset lastExecutedAt to allow immediate execution with new schedule
|
||||
let shouldResetLastExecuted = false;
|
||||
|
||||
if (data?.cronPattern !== undefined || data?.timezone !== undefined) {
|
||||
const existing = await this.findById(id);
|
||||
if (existing && (
|
||||
(data?.cronPattern !== undefined && data?.cronPattern !== existing.cronPattern) ||
|
||||
(data?.timezone !== undefined && data?.timezone !== existing.timezone)
|
||||
)) {
|
||||
shouldResetLastExecuted = true;
|
||||
}
|
||||
}
|
||||
|
||||
const updateData: Record<string, unknown> = {
|
||||
...data,
|
||||
...(shouldResetLastExecuted ? { lastExecutedAt: null } : {}),
|
||||
updatedAt: new Date(),
|
||||
};
|
||||
|
||||
// When maxExecutions is updated, reset remainingExecutions to match
|
||||
// This ensures the new limit takes effect immediately
|
||||
if (data?.maxExecutions !== undefined) {
|
||||
updateData.remainingExecutions = data.maxExecutions;
|
||||
}
|
||||
|
||||
const result = await this.db
|
||||
.update(agentCronJobs)
|
||||
.set({
|
||||
...data,
|
||||
updatedAt: new Date(),
|
||||
})
|
||||
.set(updateData)
|
||||
.where(and(eq(agentCronJobs.id, id), eq(agentCronJobs.userId, this.userId)))
|
||||
.returning();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user