2026-02-08 15:01:42 +09:00
|
|
|
import { z } from "zod"
|
|
|
|
|
|
2026-03-17 16:31:04 +09:00
|
|
|
const CircuitBreakerConfigSchema = z.object({
|
|
|
|
|
maxToolCalls: z.number().int().min(10).optional(),
|
|
|
|
|
windowSize: z.number().int().min(5).optional(),
|
|
|
|
|
repetitionThresholdPercent: z.number().gt(0).max(100).optional(),
|
|
|
|
|
})
|
|
|
|
|
|
2026-02-08 15:01:42 +09:00
|
|
|
export const BackgroundTaskConfigSchema = z.object({
|
|
|
|
|
defaultConcurrency: z.number().min(1).optional(),
|
|
|
|
|
providerConcurrency: z.record(z.string(), z.number().min(0)).optional(),
|
|
|
|
|
modelConcurrency: z.record(z.string(), z.number().min(0)).optional(),
|
2026-03-11 17:46:04 +09:00
|
|
|
maxDepth: z.number().int().min(1).optional(),
|
|
|
|
|
maxDescendants: z.number().int().min(1).optional(),
|
2026-02-08 15:01:42 +09:00
|
|
|
/** Stale timeout in milliseconds - interrupt tasks with no activity for this duration (default: 180000 = 3 minutes, minimum: 60000 = 1 minute) */
|
|
|
|
|
staleTimeoutMs: z.number().min(60000).optional(),
|
2026-03-12 01:14:43 +09:00
|
|
|
/** Timeout for tasks that never received any progress update, falling back to startedAt (default: 1800000 = 30 minutes, minimum: 60000 = 1 minute) */
|
2026-02-14 14:56:51 +09:00
|
|
|
messageStalenessTimeoutMs: z.number().min(60000).optional(),
|
2026-02-27 13:54:50 +08:00
|
|
|
syncPollTimeoutMs: z.number().min(60000).optional(),
|
2026-03-16 10:28:38 +09:00
|
|
|
/** 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(),
|
2026-03-17 16:31:04 +09:00
|
|
|
circuitBreaker: CircuitBreakerConfigSchema.optional(),
|
2026-02-08 15:01:42 +09:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
export type BackgroundTaskConfig = z.infer<typeof BackgroundTaskConfigSchema>
|