Enhance callback runInfo with more graph information
I'm currently working with callbacks and have noticed that the RunInfo structure passed to the callback contains limited information about the graph. Specifically, the current RunInfo struct is defined as:
type RunInfo struct {
Name string
Type string
Component components.Component
}
However, this information is not sufficient to accurately identify which node the callback is being triggered from. The Name and Type fields do not provide enough uniqueness to pinpoint the exact node, making it difficult to understand the context of the callback.It would be extremely helpful if the RunInfo structure could include more detailed information about the graph and the specific node. Additionally, including information about the node's position or path within the graph could also be beneficial for debugging and logging purposes.
For example, adding fields such as NodeID or NodeKey (if available) would greatly enhance the ability to trace back to the exact node triggering the callback. Or maybe we can provide GraphSchema(from eino-ext/devops) in callbacks RunInfo
And for general trace implementation, we also want to get the info of graph which is generating the trace. in this way, we can mapping the trace to graph then to node.
Usually, each node can be identified by its name
Node name is not a choice for user to identifer node.
- Node name is not unique within a graph.
- Eino reports errors or injects callbacks through node key, which is quite different from node name.
The current Callback is positioned as an aspect of a Component. This aspect can be applied both when the component is used standalone and when it is integrated into a graph orchestration. Given this, we should avoid exposing runtime information of the graph within the component's aspect.
If we need to incorporate graph runtime information into the RunInfo of the Callback, we must carefully evaluate whether to redefine the role of the Callback so that it no longer supports the aspect execution when components are used standalone.
For scenarios where you need to retrieve outputs from specific nodes, we recommend:
- Using NewHandlerBuilder() to construct a CallbackHandler tailored to the designated node type. Combining it with compose.DesignateNode or compose.DesignateNodeWithPath to specify the nodes where the CallbackHandler should take effect. https://www.cloudwego.io/zh/docs/eino/core_modules/chain_and_graph_orchestration/callback_manual/