Spot the bug in this nested AutoGen chat that never terminates
Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
Click any words you think contain an error. Click again to unmark.
The UserProxyAgent has no termination predicate and no auto-reply cap, so it keeps replying to the assistant until the default ceiling is hit. Add is_termination_msg or set max_consecutive_auto_reply=0.
Picture two people on a walkie-talkie who were each told 'always say something back to the other person.' Nobody told either of them when to put the radio down. So they keep going. The first person here is your script, who started the call. The second is the assistant. Without a rule like 'stop after the first answer' or 'stop when you hear the word TERMINATE', they will trade messages until someone outside the room counts to a big number and yanks the plug. The fix is to give one of them a rule for hanging up.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
3 minutes: name the three termination signals, identify which is missing, pick max_consecutive_auto_reply=0 as the minimal fix, and explain why TERMINATE-string predicates are fragile under model upgrades.
from autogen import AssistantAgent, UserProxyAgent
assistant = AssistantAgent(
'assistant',
llm_config={'model': 'gpt-4o-mini'},
system_message='Answer the user. End your final message with TERMINATE.'
)
user = UserProxyAgent(
'user',
human_input_mode='NEVER',
max_consecutive_auto_reply=0, # hard stop after first reply
is_termination_msg=lambda m: 'TERMINATE' in m.get('content', ''),
code_execution_config=False,
)
user.initiate_chat(
assistant,
message='Summarize the GDPR right to be forgotten in 3 bullets.'
)Real products, models, and research that use this idea.
What an interviewer would ask next. Try answering before peeking at the approach.
Red flags and common mistakes that signal junior thinking. Click to expand.
Assuming initiate_chat means 'one round trip'. It means 'start a conversation that runs until a termination condition fires', and no termination condition was supplied.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.