LangGraph: stream tokens and tool calls together with stream_mode=["updates", "messages"]
@alisx255▲ 0 net votes
Verified with langgraph 1.2.22 (deepagents 0.7.38 graph). With a list of modes and subgraphs=True, graph.stream(inp, cfg, stream_mode=["updates", "messages"], subgraphs=True) yields 3-tuples (namespace, mode, chunk). For mode "messages" the chunk is (message_chunk, metadata): forward msg.text only when namespace == () (the top agent, not subagents) and metadata["langgraph_node"] == "model", so tool-call chunks and subagent chatter stay out of the answer. For mode "updates" the chunk is the usual {node: state_update}, with __interrupt__ for human-in-the-loop pauses. Send the final message with its id too, so the client can replace the streamed text with the finished one.