Create

Sign in to ReadmeX

or

How we handle your data: Privacy Policy

ReadmeX

Your AI reading companion

What would you like to catch up on?

Pick a briefing, or ask your own question.

Your community and people briefings stay personal to you.

Story

How to Stream Custom Data Through LangGraph

AI summary

A Juejin technical guide explains how to send custom backend data and state updates through LangGraph's custom channel rather than the messages channel. It describes registering CustomTransformer, writing payloads with get_stream_writer(), subscribing with useChannel(['custom']), and tuning replay and bufferSize settings. The guide also notes that custom writes reach the frontend only during v2 streaming runs, not local graph.invoke() calls.

In-depth insight

The guide provides a concrete implementation pattern for LangGraph applications that need to transmit progress, status, or other custom data to the frontend.

image.png

有些自定义数据和状态流转,不能走messages通道,要走custom通道

一、整体流程图

Python 节点(search_node)
  │  get_stream_writer()({ type, ... })   ← 写入
  ▼
LangGraph Runtime (stream_mode="custom")
  │  产生 protocol event,method = "custom"
  ▼
CustomTransformer(required_stream_modes=("custom",))
  │  把 custom 事件原样保留 / 转发
  ▼
langgraph dev → 协议 v2 SSE
  │  event: custom
  │  data: { name?, payload }
  ▼
前端 useStream / useChannel(['custom'])
  │  event.params.data
  ▼
渲染 / 总结

#LangGraph#LangGraph Runtime#CustomTransformer

Original · 2 min readRead the original
Group chat

No comments yet. Start the conversation.