Execute a human node. Args: node: Human node definition inputs: Input messages Returns: Result supplied by the human reviewer
(self, node: Node, inputs: List[Message])
| 15 | """Executor used for human interaction nodes.""" |
| 16 | |
| 17 | def execute(self, node: Node, inputs: List[Message]) -> List[Message]: |
| 18 | """Execute a human node. |
| 19 | |
| 20 | Args: |
| 21 | node: Human node definition |
| 22 | inputs: Input messages |
| 23 | |
| 24 | Returns: |
| 25 | Result supplied by the human reviewer |
| 26 | """ |
| 27 | self._ensure_not_cancelled() |
| 28 | if node.node_type != "human": |
| 29 | raise ValueError(f"Node {node.id} is not a human node") |
| 30 | |
| 31 | human_config = node.as_config(HumanConfig) |
| 32 | if not human_config: |
| 33 | raise ValueError(f"Node {node.id} has no human configuration") |
| 34 | |
| 35 | human_task_description = human_config.description |
| 36 | # Use prompt-style preview so humans see the same flattened text format |
| 37 | # instead of raw message JSON. |
| 38 | input_data = self._inputs_to_text(inputs) |
| 39 | |
| 40 | prompt_service = self.context.get_human_prompt_service() |
| 41 | if prompt_service is None: |
| 42 | raise RuntimeError("HumanPromptService is not configured; cannot execute human node") |
| 43 | |
| 44 | prompt_result = prompt_service.request( |
| 45 | node.id, |
| 46 | human_task_description or "", |
| 47 | inputs=input_data, |
| 48 | metadata={"node_type": "human"}, |
| 49 | ) |
| 50 | |
| 51 | return [self._build_message( |
| 52 | MessageRole.USER, |
| 53 | prompt_result.as_message_content(), |
| 54 | source=node.id, |
| 55 | )] |
| 56 |
nothing calls this directly
no test coverage detected