fix(#2825): secondary agents no longer pruned after 30 min of total runtime

TTL (pruneStaleTasksAndNotifications) now resets on last activity:
- Uses task.progress.lastUpdate as TTL anchor for running tasks
  (was always using startedAt, causing 30-min hard deadline)
- Added taskTtlMs config option for user-adjustable TTL
- Error message shows actual TTL duration, not hardcoded '30 minutes'
- 3 new tests for the new behavior
This commit is contained in:
YeonGyu-Kim
2026-03-27 16:06:38 +09:00
parent 3b4420bc23
commit c41e59e9ab
5 changed files with 144 additions and 5 deletions
+1
View File
@@ -1751,6 +1751,7 @@ Use \`background_output(task_id="${task.id}")\` to retrieve this result when rea
pruneStaleTasksAndNotifications({
tasks: this.tasks,
notifications: this.notifications,
taskTtlMs: this.config?.taskTtlMs,
onTaskPruned: (taskId, task, errorMessage) => {
const wasPending = task.status === "pending"
log("[background-agent] Pruning stale task:", { taskId, status: task.status, age: Math.round(((wasPending ? task.queuedAt?.getTime() : task.startedAt?.getTime()) ? (Date.now() - (wasPending ? task.queuedAt!.getTime() : task.startedAt!.getTime())) : 0) / 1000) + "s" })