All posts

28 Oct 2026 · LangGraph & Agents

Streaming Multi-Agent Workflows with LangGraph.js in Next.js 15

Supervisor to worker StateGraph, streaming intermediate reasoning over SSE, and why App Router Route Handlers beat a single chat completion.

A single streamText call is a chatbot. A supervisor that delegates to a researcher and a summarizer is a product. The hard part is not the graph. It is getting each node token onto the same SSE response the chat UI already understands.

AgenticPacks OSS is the streaming chat baseline (Vercel AI SDK, no graph): Agentic-Packs/agenticpacks-oss. The 3-node LangGraph (Supervisor, Tavily researcher, summarizer) with a live reasoning stream is Pro. Try it on the production demo if you want the UI before the code.

Why a Route Handler, not a Server Action

Server Actions want a result. A 90 second graph wants a stream. Use a Route Handler with runtime = "nodejs" and return the AI SDK data stream (or LangGraph's HTTP adapter) immediately. The client uses the same hooks you already have for chat.

If the proxy buffers, you will see one dump at the end. Fix that in Caddy SSE. If the socket dies between nodes, fix timeouts in SSE connection drops.

A small supervisor graph

import { StateGraph, Annotation } from "@langchain/langgraph";

const State = Annotation.Root({
  question: Annotation<string>(),
  notes: Annotation<string>(),
  brief: Annotation<string>(),
});

const supervisor = async (state: typeof State.State) => {
  // decide: research or summarize
  return state;
};

const researcher = async (state: typeof State.State) => {
  // Tavily (or your tool) then write state.notes
  return state;
};

const summarizer = async (state: typeof State.State) => {
  // model writes state.brief
  return state;
};

export const graph = new StateGraph(State)
  .addNode("supervisor", supervisor)
  .addNode("researcher", researcher)
  .addNode("summarizer", summarizer)
  .addEdge("__start__", "supervisor")
  .compile();

Conditional edges from supervisor to researcher or summarizer are the actual product. Keep node functions small. Put Tavily and model calls behind tools so you can test without the network.

Stream node events, not only the final string

The UI should show "researching…" then quotes, then the brief. That means the HTTP response emits:

  • node start / node end
  • token deltas from the summarizer
  • tool calls (search query, URL list)

Map those onto the AI SDK data protocol the AgenticPacks OSS chat already consumes, or onto a thin event stream your message list understands. Do not invent a second chat client.

Persist threads in Prisma (Conversation, Message) the same way AgenticPacks OSS does. Store the brief as markdown. Pro also archives executive reports with pagination.

Checkpoints belong in Postgres

In-memory graphs die when the Node process restarts. LangGraph checkpointing into Postgres (or Redis) lets you resume. That is also the door to human-in-the-loop: interrupt before a destructive tool, wait for Approve.

Redis in Pro is the queue and cache next to that graph, not a second database of record. Postgres remains source of truth for threads and usage.

Tired of wiring a supervisor graph and an SSE UI from scratch?

Clone streaming chat first: Agentic-Packs/agenticpacks-oss.

The compiled 3-node graph, Tavily, and reasoning stream are in the 3-agent LangGraph core in Pro.

What this is not

It is not a Python LangGraph service next to Next.js unless you like two deploys. LangGraph.js in the same Node process as the App Router is the shape that fits Docker Compose on a small VPS. See self-hosting cost.

Tool routing across OpenAI and Anthropic without a graph is a different post: AI SDK tool calling.


Where to Go From Here

You do not have to spend a week on StateGraph plus a chat pane.

Option A: Free open-source baseline (MIT)


Option B: Ship with AgenticPacks Pro ($149 one-time)

If you want the graph already compiled:

  • Automated Hetzner provisioning: Terraform, Caddy SSE, Compose.
  • Production multi-agent core: Supervisor, Tavily researcher, summarizer, live reasoning stream, report archive.
  • Usage & Unit Economics: Stripe and token-to-dollar ledger (including search fees).