@@ -265,7 +265,7 @@ def test_agent_mentions():
265
265
max_consecutive_auto_reply = 2 ,
266
266
human_input_mode = "NEVER" ,
267
267
llm_config = False ,
268
- default_auto_reply = "This is alice sepaking ." ,
268
+ default_auto_reply = "This is alice speaking ." ,
269
269
)
270
270
agent2 = autogen .ConversableAgent (
271
271
"bob" ,
@@ -330,11 +330,64 @@ def test_agent_mentions():
330
330
)
331
331
332
332
333
+ def test_termination ():
334
+ agent1 = autogen .ConversableAgent (
335
+ "alice" ,
336
+ max_consecutive_auto_reply = 10 ,
337
+ human_input_mode = "NEVER" ,
338
+ llm_config = False ,
339
+ default_auto_reply = "This is alice speaking." ,
340
+ )
341
+ agent2 = autogen .ConversableAgent (
342
+ "bob" ,
343
+ max_consecutive_auto_reply = 10 ,
344
+ human_input_mode = "NEVER" ,
345
+ llm_config = False ,
346
+ default_auto_reply = "This is bob speaking." ,
347
+ )
348
+ agent3 = autogen .ConversableAgent (
349
+ "sam" ,
350
+ max_consecutive_auto_reply = 10 ,
351
+ human_input_mode = "NEVER" ,
352
+ llm_config = False ,
353
+ default_auto_reply = "This is sam speaking. TERMINATE" ,
354
+ )
355
+
356
+ # Test empty is_termination_msg function
357
+ groupchat = autogen .GroupChat (
358
+ agents = [agent1 , agent2 , agent3 ], messages = [], speaker_selection_method = "round_robin" , max_round = 10
359
+ )
360
+
361
+ group_chat_manager = autogen .GroupChatManager (groupchat = groupchat , llm_config = False , is_termination_msg = None )
362
+
363
+ agent1 .initiate_chat (group_chat_manager , message = "'None' is_termination_msg function." )
364
+ assert len (groupchat .messages ) == 10
365
+
366
+ # Test user-provided is_termination_msg function
367
+ agent1 .reset ()
368
+ agent2 .reset ()
369
+ agent3 .reset ()
370
+
371
+ groupchat = autogen .GroupChat (
372
+ agents = [agent1 , agent2 , agent3 ], messages = [], speaker_selection_method = "round_robin" , max_round = 10
373
+ )
374
+
375
+ group_chat_manager = autogen .GroupChatManager (
376
+ groupchat = groupchat ,
377
+ llm_config = False ,
378
+ is_termination_msg = lambda x : x .get ("content" , "" ).rstrip ().find ("TERMINATE" ) >= 0 ,
379
+ )
380
+
381
+ agent1 .initiate_chat (group_chat_manager , message = "User-provided is_termination_msg function." )
382
+ assert len (groupchat .messages ) == 3
383
+
384
+
333
385
if __name__ == "__main__" :
334
386
# test_func_call_groupchat()
335
387
# test_broadcast()
336
388
# test_chat_manager()
337
389
# test_plugin()
338
- test_speaker_selection_method ()
339
- test_n_agents_less_than_3 ()
390
+ # test_speaker_selection_method()
391
+ # test_n_agents_less_than_3()
340
392
# test_agent_mentions()
393
+ test_termination ()
0 commit comments