diff --git a/assets/oh-my-opencode.schema.json b/assets/oh-my-opencode.schema.json index f63a98e24..cfe085234 100644 --- a/assets/oh-my-opencode.schema.json +++ b/assets/oh-my-opencode.schema.json @@ -5744,6 +5744,10 @@ "type": "number", "minimum": 10000 }, + "taskCleanupDelayMs": { + "type": "number", + "minimum": 60000 + }, "syncPollTimeoutMs": { "type": "number", "minimum": 60000 diff --git a/src/config/schema/background-task.ts b/src/config/schema/background-task.ts index 4b62612fa..415ef274b 100644 --- a/src/config/schema/background-task.ts +++ b/src/config/schema/background-task.ts @@ -19,6 +19,8 @@ export const BackgroundTaskConfigSchema = z.object({ taskTtlMs: z.number().min(300000).optional(), /** Timeout for tasks whose session has completely disappeared from the status registry (default: 60000 = 1 minute, minimum: 10000 = 10 seconds). When a session is gone (likely crashed), this shorter timeout is used instead of the normal stale timeout. */ sessionGoneTimeoutMs: z.number().min(10000).optional(), + /** Delay before removing completed/cancelled/errored tasks from memory in milliseconds (default: 600000 = 10 minutes, minimum: 60000 = 1 minute). */ + taskCleanupDelayMs: z.number().min(60000).optional(), syncPollTimeoutMs: z.number().min(60000).optional(), /** Maximum tool calls per subagent task before circuit breaker triggers (default: 200, minimum: 10). Prevents runaway loops from burning unlimited tokens. */ maxToolCalls: z.number().int().min(10).optional(), diff --git a/src/features/background-agent/manager.ts b/src/features/background-agent/manager.ts index 3485461ca..bdedc17cc 100644 --- a/src/features/background-agent/manager.ts +++ b/src/features/background-agent/manager.ts @@ -2157,7 +2157,7 @@ The task was re-queued on a fallback model after a retryable failure. SessionCategoryRegistry.remove(task.sessionId) } log("[background-agent] Removed completed task from memory:", taskId) - }, TASK_CLEANUP_DELAY_MS) + }, this.config?.taskCleanupDelayMs ?? TASK_CLEANUP_DELAY_MS) this.completionTimers.set(taskId, timer) }