MCPcopy Index your code
hub / github.com/OpenBMB/ChatDev / _get_final_node

Method _get_final_node

workflow/graph.py:776–790  ·  view source on GitHub ↗

Return the explicitly configured end node, or sink node as fallback.

(self)

Source from the content-addressed store, hash-verified

774 return results
775
776 def _get_final_node(self) -> Node:
777 """Return the explicitly configured end node, or sink node as fallback."""
778 end_node_ids = self.graph.config.definition.end_nodes
779
780 if end_node_ids:
781 for end_node_id in end_node_ids:
782 if end_node_id in self.graph.nodes:
783 node = self.graph.nodes[end_node_id]
784 # Check if node has output
785 if node.output:
786 return node
787
788 # Fallback to default behavior - return sink node
789 sink_node = [node for node in self.graph.nodes.values() if not node.successors]
790 return sink_node[0] if sink_node else None
791
792 def _restore_context_trace(self, node: Node, trace_payload: Any) -> bool:
793 if not isinstance(trace_payload, list):

Callers 2

Calls

no outgoing calls

Tested by

no test coverage detected