diff --git a/api/core/workflow/nodes/agent/clarification_helper.py b/api/core/workflow/nodes/agent/clarification_helper.py index 90c1c313fb..0debf19f47 100644 --- a/api/core/workflow/nodes/agent/clarification_helper.py +++ b/api/core/workflow/nodes/agent/clarification_helper.py @@ -27,7 +27,7 @@ def should_enable_clarification(node_data: AgentNodeData) -> bool: def extract_clarification_request( - agent_output: dict[str, Any], + _agent_output: dict[str, Any], enable_clarification: bool, ) -> dict[str, Any] | None: """ @@ -37,7 +37,7 @@ def extract_clarification_request( Currently returns None as clarification is not yet implemented. Args: - agent_output: The output from agent execution. + _agent_output: The output from agent execution. Currently unused, reserved for future HITL expansion. enable_clarification: Whether clarification is enabled. Returns: diff --git a/api/tests/unit_tests/core/workflow/nodes/agent/test_clarification_helper.py b/api/tests/unit_tests/core/workflow/nodes/agent/test_clarification_helper.py index cad5c0997f..9c5a44adf9 100644 --- a/api/tests/unit_tests/core/workflow/nodes/agent/test_clarification_helper.py +++ b/api/tests/unit_tests/core/workflow/nodes/agent/test_clarification_helper.py @@ -2,6 +2,8 @@ Tests for agent node clarification helper and configuration. """ +import pytest + from core.workflow.nodes.agent.clarification_helper import ( extract_clarification_request, should_enable_clarification, @@ -10,51 +12,47 @@ from core.workflow.nodes.agent.entities import AgentNodeData from dify_graph.enums import NodeType +@pytest.fixture +def base_node_data_args() -> dict: + """Fixture providing base arguments for AgentNodeData construction.""" + return { + "id": "test_node", + "type": NodeType.AGENT, + "agent_strategy_provider_name": "test_provider", + "agent_strategy_name": "test_strategy", + "agent_strategy_label": "Test Strategy", + "agent_parameters": {}, + } + + class TestClarificationHelper: """Test suite for clarification helper functions.""" - def test_should_enable_clarification_when_enabled(self): + def test_should_enable_clarification_when_enabled(self, base_node_data_args): """Test that should_enable_clarification returns True when enabled.""" node_data = AgentNodeData( - id="test_node", - type=NodeType.AGENT, - agent_strategy_provider_name="test_provider", - agent_strategy_name="test_strategy", - agent_strategy_label="Test Strategy", - agent_parameters={}, + **base_node_data_args, enable_human_clarification=True, ) assert should_enable_clarification(node_data) is True - def test_should_enable_clarification_when_disabled(self): + def test_should_enable_clarification_when_disabled(self, base_node_data_args): """Test that should_enable_clarification returns False when disabled.""" node_data = AgentNodeData( - id="test_node", - type=NodeType.AGENT, - agent_strategy_provider_name="test_provider", - agent_strategy_name="test_strategy", - agent_strategy_label="Test Strategy", - agent_parameters={}, + **base_node_data_args, enable_human_clarification=False, ) assert should_enable_clarification(node_data) is False - def test_should_enable_clarification_default_false(self): + def test_should_enable_clarification_default_false(self, base_node_data_args): """Test that clarification is disabled by default.""" - node_data = AgentNodeData( - id="test_node", - type=NodeType.AGENT, - agent_strategy_provider_name="test_provider", - agent_strategy_name="test_strategy", - agent_strategy_label="Test Strategy", - agent_parameters={}, - ) + node_data = AgentNodeData(**base_node_data_args) assert should_enable_clarification(node_data) is False def test_extract_clarification_request_when_disabled(self): """Test that extract_clarification_request returns None when disabled.""" result = extract_clarification_request( - agent_output={"text": "test output"}, + _agent_output={"text": "test output"}, enable_clarification=False, ) assert result is None @@ -63,31 +61,22 @@ class TestClarificationHelper: """Test that extract_clarification_request returns None when enabled (placeholder).""" # Currently returns None as placeholder for future implementation result = extract_clarification_request( - agent_output={"text": "test output"}, + _agent_output={"text": "test output"}, enable_clarification=True, ) assert result is None - def test_agent_node_data_with_clarification_field(self): + def test_agent_node_data_with_clarification_field(self, base_node_data_args): """Test that AgentNodeData properly stores enable_human_clarification.""" node_data = AgentNodeData( - id="test_node", - type=NodeType.AGENT, - agent_strategy_provider_name="test_provider", - agent_strategy_name="test_strategy", - agent_strategy_label="Test Strategy", - agent_parameters={}, + **base_node_data_args, enable_human_clarification=True, ) assert node_data.enable_human_clarification is True node_data_disabled = AgentNodeData( - id="test_node", - type=NodeType.AGENT, - agent_strategy_provider_name="test_provider", - agent_strategy_name="test_strategy", - agent_strategy_label="Test Strategy", - agent_parameters={}, + **base_node_data_args, enable_human_clarification=False, ) assert node_data_disabled.enable_human_clarification is False +