@@ -451,6 +451,62 @@ def test_swarm_auto_completion_without_handoff():
451451 no_handoff_agent .invoke_async .assert_called ()
452452
453453
454+ def test_swarm_configurable_entry_point ():
455+ """Test swarm with configurable entry point."""
456+ # Create multiple agents
457+ agent1 = create_mock_agent ("agent1" , "Agent 1 response" )
458+ agent2 = create_mock_agent ("agent2" , "Agent 2 response" )
459+ agent3 = create_mock_agent ("agent3" , "Agent 3 response" )
460+
461+ # Create swarm with agent2 as entry point
462+ swarm = Swarm ([agent1 , agent2 , agent3 ], entry_point = "agent2" )
463+
464+ # Verify entry point is set correctly
465+ assert swarm .entry_point == "agent2"
466+
467+ # Execute swarm
468+ result = swarm ("Test task" )
469+
470+ # Verify agent2 was the first to execute
471+ assert result .status == Status .COMPLETED
472+ assert len (result .node_history ) == 1
473+ assert result .node_history [0 ].node_id == "agent2"
474+
475+
476+ def test_swarm_invalid_entry_point ():
477+ """Test swarm with invalid entry point raises error."""
478+ agent1 = create_mock_agent ("agent1" , "Agent 1 response" )
479+ agent2 = create_mock_agent ("agent2" , "Agent 2 response" )
480+
481+ # Try to create swarm with non-existent entry point
482+ with pytest .raises (ValueError , match = "Entry point 'nonexistent' not found in swarm nodes" ):
483+ Swarm ([agent1 , agent2 ], entry_point = "nonexistent" )
484+
485+ # Try with random string entry point
486+ with pytest .raises (ValueError , match = "Entry point 'xyz123random' not found in swarm nodes" ):
487+ Swarm ([agent1 , agent2 ], entry_point = "xyz123random" )
488+
489+
490+ def test_swarm_default_entry_point ():
491+ """Test swarm uses first agent as default entry point."""
492+ agent1 = create_mock_agent ("agent1" , "Agent 1 response" )
493+ agent2 = create_mock_agent ("agent2" , "Agent 2 response" )
494+
495+ # Create swarm without specifying entry point
496+ swarm = Swarm ([agent1 , agent2 ])
497+
498+ # Verify no explicit entry point is set
499+ assert swarm .entry_point is None
500+
501+ # Execute swarm
502+ result = swarm ("Test task" )
503+
504+ # Verify first agent was used as entry point
505+ assert result .status == Status .COMPLETED
506+ assert len (result .node_history ) == 1
507+ assert result .node_history [0 ].node_id == "agent1"
508+
509+
454510def test_swarm_validate_unsupported_features ():
455511 """Test Swarm validation for session persistence and callbacks."""
456512 # Test with normal agent (should work)
0 commit comments