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.
Detailed answer & concept explanation~4 min readEverything 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. 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.
- AutoGen Studio's chat tutorials universally show is_termination_msg patterns precisely because new users hit this bug
- Microsoft's AutoGen v0.4 release notes call out termination-control changes after community feedback on runaway loops
- Production teams running AutoGen on Claude Opus 4.7 typically set max_consecutive_auto_reply explicitly to bound spend per request
- LangGraph's StateGraph is frequently chosen over AutoGen specifically for the explicit termination semantics
What an interviewer would ask next. Try answering before peeking at the approach.
QWhy is the default max_consecutive_auto_reply set high instead of 1?
QHow would you implement termination if the conversation should end only when the assistant has emitted valid JSON?
Don't say thisRed flags and common mistakes that signal junior thinking. Click to expand.
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.
Same topic, related formats. Practice these next.