Skip to content

Commit 5805892

Browse files
fix UnboundLocalError in function_target
1 parent 0ef1d3d commit 5805892

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

autogen/agentchat/group/targets/function_target.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,10 @@ def construct_broadcast_messages_list(
6464
next_target = target.agent_name
6565
for agent in group_chat.agents:
6666
if agent.name == next_target:
67-
messages = [FunctionTargetMessage(content=messages, msg_target=agent)]
67+
messages_list = [FunctionTargetMessage(content=messages, msg_target=agent)]
6868
break
69+
else:
70+
raise ValueError(f"No agent found with in the group chat matching the target agent name {next_target}.")
6971
elif isinstance(target, RevertToUserTarget) and user_agent is not None:
7072
messages_list = [FunctionTargetMessage(content=messages, msg_target=user_agent)]
7173
elif isinstance(target, StayTarget):

0 commit comments

Comments
 (0)