perf(background-task): reduce output poll latency

This commit is contained in:
YeonGyu-Kim
2026-05-28 18:41:14 +09:00
parent 105a7ea5e6
commit 4b464ad622
2 changed files with 74 additions and 1 deletions
@@ -15,6 +15,7 @@ import { recordBackgroundOutputConsumption } from "../../shared/background-outpu
const SISYPHUS_JUNIOR_AGENT = getAgentDisplayName("sisyphus-junior")
const MISSING_BACKGROUND_TASK_RETRY_DELAY_MS = 100
const BACKGROUND_OUTPUT_POLL_INTERVAL_MS = 100
type ToolContextWithMetadata = {
sessionID: string
@@ -140,7 +141,8 @@ export function createBackgroundOutput(manager: BackgroundOutputManager, client:
if (shouldBlock && isTaskActiveStatus(task.status)) {
const startTime = Date.now()
while (Date.now() - startTime < timeoutMs) {
await delay(1000)
const remainingMs = timeoutMs - (Date.now() - startTime)
await delay(Math.min(BACKGROUND_OUTPUT_POLL_INTERVAL_MS, Math.max(1, remainingMs)))
const currentTask = await getTaskWithMissingRetry(manager, args.task_id)
if (!currentTask) {