#2847·ag-ui

langgraph (python): set `name` on `TEXT_MESSAGE_START` for named sub-agent messages

Author: BenTaylorDevCreated Sep 28, 2026Updated Oct 1, 2026

Problem

TextMessageStartEvent has a name field, and @ag-ui/client copies it into the new message. The Python LangGraph adapter never sets it. A sub-agent message gets its name only when the next MESSAGES_SNAPSHOT arrives.

Because of this, a client cannot tell which agent wrote a message while that message streams. A frontend that hides sub-agent messages by name shows the text while it streams. The text disappears at the snapshot.

Downstream issue: CopilotKit/CopilotKit#1959 (hide langgraph-supervisor worker messages). CopilotKit is adding the frontend filter by name. This issue is the adapter half, which removes the flash.

Measurements

ag-ui-langgraph 0.0.45, langgraph-supervisor 0.0.31, one math_expert worker, with scripted models.

TEXT_MESSAGE_START for the worker reply:

{'type': 'TEXT_MESSAGE_START', 'message_id': 'lc_run--…', 'role': 'assistant'}

The same message ID in the final MESSAGES_SNAPSHOT carries name: "math_expert".

Metadata on the worker's on_chat_model_stream events:

Worker built with chunk.name lc_agent_name
langchain.agents.create_agent(name="math_expert") None math_expert
langgraph.prebuilt.create_react_agent(name="math_expert") None None

Proposed change

If the event metadata has lc_agent_name, set name from it when the adapter emits TEXT_MESSAGE_START. This covers create_agent workers.

Legacy create_react_agent workers expose no name during the stream. For those workers, the snapshot stays the first point where name is known. create_react_agent is deprecated in LangGraph 1.0.

Open question: the parent agent's own messages. For a create_agent parent, lc_agent_name is the parent's name, so its messages get a name too. That matches what the snapshot already reports, so I expect no conflict. A test must confirm it.