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

Method _restore_context_trace

workflow/graph.py:792–816  ·  view source on GitHub ↗
(self, node: Node, trace_payload: Any)

Source from the content-addressed store, hash-verified

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):
794 return False
795
796 restored = 0
797 for entry in trace_payload:
798 if not isinstance(entry, dict):
799 continue
800 try:
801 message = Message.from_dict(entry)
802 if message.role not in [MessageRole.USER, MessageRole.ASSISTANT]:
803 continue
804 except Exception as exc:
805 self.log_manager.warning(
806 f"Failed to deserialize context trace for node {node.id}: {exc}"
807 )
808 continue
809 node.append_input(self._ensure_source(message, node.id))
810 restored += 1
811
812 if restored:
813 self.log_manager.debug(
814 f"Node {node.id} preserved {restored} messages from its tool execution trace"
815 )
816 return restored > 0
817
818 def _payload_to_text(self, payload: Any) -> str:
819 if isinstance(payload, Message):

Callers 1

_execute_nodeMethod · 0.95

Calls 5

_ensure_sourceMethod · 0.95
append_inputMethod · 0.80
from_dictMethod · 0.45
warningMethod · 0.45
debugMethod · 0.45

Tested by

no test coverage detected