message_to_events(
msg: BaseMessage,
*,
message_id: str | None = None
) -> Iterator| Name | Type | Description |
|---|---|---|
msg* | BaseMessage | |
message_id | str | None | Default: None |
Replay a finalized message as a synthetic event lifecycle.
For a message returned whole (from a graph node, checkpoint, or
cache), produce the same message-start / per-block /
message-finish event stream a live call would produce. Consumers
downstream see a uniform event shape regardless of source.
Text and reasoning blocks emit a single content-block-delta with
the full accumulated content, and tool-call chunk blocks a single
tool-call-delta with their full args. Already-finalized blocks
(tool_call, server_tool_call, image, etc.) skip the delta and rely
on the content-block-finish event alone.
The finalized message โ typically an AIMessage.
Optional stable message ID; falls back to msg.id.