diff --git a/apps/web/app/api/chat/subagent-stream/route.ts b/apps/web/app/api/chat/subagent-stream/route.ts index a0d1c8f74ba..75a93999587 100644 --- a/apps/web/app/api/chat/subagent-stream/route.ts +++ b/apps/web/app/api/chat/subagent-stream/route.ts @@ -1,4 +1,4 @@ -import { subscribeToSubagent, hasActiveSubagent, isSubagentRunning, ensureRegisteredFromDisk } from "@/lib/subagent-runs"; +import { subscribeToSubagent, hasActiveSubagent, isSubagentRunning, ensureRegisteredFromDisk, ensureSubagentStreamable } from "@/lib/subagent-runs"; import type { SseEvent } from "@/lib/subagent-runs"; import { existsSync, readFileSync } from "node:fs"; import { join } from "node:path"; @@ -51,6 +51,10 @@ export async function GET(req: Request) { return new Response("Subagent not found", { status: 404 }); } + // For still-running subagents rehydrated from disk, activate the gateway + // WebSocket subscription so new events arrive in real time. + ensureSubagentStreamable(sessionKey); + const isActive = isSubagentRunning(sessionKey); const encoder = new TextEncoder(); let closed = false;