Message Flow#
This document explains how messages flow through the Chat USD system, from user input to final response. Understanding this flow is essential for extending or customizing the system.
Overview#
Messages in Chat USD flow through a series of components, each processing the message and passing it to the next component in the chain. The flow is orchestrated by the ChatUSDNetworkNode
and ChatUSDSupervisorNode
, which route messages to specialized agents based on the message content.
Message Types#
Chat USD uses several types of messages, defined in the LC Agent framework:
HumanMessage: Represents user input
AIMessage: Represents AI-generated responses
SystemMessage: Provides instructions to the AI
ToolMessage: Represents the output of tool calls
These message types are used throughout the system to represent different types of information.
Basic Message Flow#
The basic message flow in Chat USD follows these steps:
User Input: The user provides a query through the chat interface, which is converted to a
HumanMessage
ChatUSDNetworkNode: The message is received by the
ChatUSDNetworkNode
, which is the main entry point for the systemChatUSDSupervisorNode: The message is passed to the
ChatUSDSupervisorNode
, which analyzes it to determine its intentSpecialized Agent: The message is routed to the appropriate specialized agent based on its intent
Agent Processing: The agent processes the message and generates a response as an
AIMessage
Response Integration: The response is passed back to the
ChatUSDSupervisorNode
, which integrates it into a coherent replyFinal Response: The integrated response is returned to the user
This flow ensures that each message is handled by the most appropriate agent and that the response is coherent and comprehensive.
Error Handling in Message Flow#
When errors occur in the message flow, they are handled through a combination of error detection, reporting, and handling:
Error Detection: Errors are detected at the component where they occur
Error Reporting: Errors are reported through the component’s metadata
Error Handling: Errors are handled by modifiers or other components
For example, if a code execution error occurs in the USDCodeInteractiveNetworkNode
, it is detected, reported, and handled by the DoubleRunUSDCodeGenInterpreterModifier
.