(self, node: Node, trace_payload: Any)
| 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): |
no test coverage detected