Zenaique

How is the termination condition expressed in an AutoGen GroupChat?

MCQ·Medium·4.0 · 0·~1 min·Asked atCharacter AiDeloitteDify
Attempt it
TL;DR

AutoGen terminates via two layers. An `is_termination_msg` predicate over the last message plus a `max_round` hard ceiling on the GroupChat.

Memory aid
Sign in to see the mnemonic that makes this stick.
Easy to grasp

Think of a brainstorming meeting with a written rule and a clock on the wall. The rule says 'when anyone slides a sticky note that says STOP, we are done.' The clock says 'no matter what, the meeting ends after 30 minutes.' Most meetings end on the sticky note. The clock exists for the day everyone forgets the rule and keeps talking. AutoGen runs its multi-agent chat the same way. A predicate checks the last message for a stop signal, and a round counter on the chat ends things if no one ever slides the note.

Concept explanation~2 min read

Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.

Termination is one of those topics that sounds boring until you ship an agent that does not stop. Then it becomes the first incident you write a postmortem about. AutoGen's design has clear opinions on this, and the question above probes whether a candidate has actually wired the framework or only read the README.

The two layers, predicate and ceiling, show up in nearly every agent framework, but AutoGen names them explicitly: is_termination_msg and max_round. Understanding why both exist, and what each catches, is the difference between a candidate who can ship the framework and one who will produce a token-burn incident in their first sprint.

Layer 1. The predicate

is_termination_msg is a function that takes the last message and returns True or False. AutoGen calls it after every message. True stops the agent from sending further replies in the current run.

The conventional implementation is a sentinel-string check. You instruct the assistant in its system prompt to write 'TERMINATE' on its final message, and the predicate checks for that substring. Why a string rather than a structured tool call? GroupChat predates the universal tool-calling surface and a string sentinel works across every backing model without configuration.

code
is_termination_msg=lambda m: "TERMINATE" in (m.get("content") or "")

Stricter predicates exist. Exact match, JSON-parse, regex on a tool-call name, or an LLM call that decides whether the task looks complete. The framework is agnostic; you pick the discipline.

Layer 2. The ceiling
Why each agent has its own predicate
AutoGen 0.4. Declarative TerminationCondition
What the wrong answers reveal
Sign in to unlock the full deep dive.

Situations where this technique stops working.

Sign in to see when this approach fails.

2–4 min · Everything important, quickly.

Sign in to see the quick scan of the deep dive.
python
from autogen import AssistantAgent, UserProxyAgent, GroupChat, GroupChatManager

def is_done(msg):
    return "TERMINATE" in (msg.get("content") or "")

assistant = AssistantAgent(
    name="planner",
    system_message="Solve the task. When finished, write TERMINATE on its own line.",
    is_termination_msg=is_done,
)
user = UserProxyAgent(
    name="user",
    is_termination_msg=is_done,
    human_input_mode="NEVER",
)

chat = GroupChat(agents=[assistant, user], messages=[], max_round=12)
manager = GroupChatManager(groupchat=chat, is_termination_msg=is_done)

user.initiate_chat(manager, message="Outline a 1-week launch plan.")

Real products, models, and research that use this idea.

  • Microsoft Research's AutoGen demos use the 'TERMINATE' sentinel pattern in their reference notebooks for GroupChat tutorials
  • AutoGen 0.4 introduced `TerminationCondition` classes (MaxMessageTermination, TextMentionTermination, TokenUsageTermination) that compose the predicate plus ceiling pattern explicitly
Sign in to see more production examples.

What an interviewer would ask next. Try answering before peeking at the approach.

QHow does AutoGen 0.4's `TerminationCondition` class system change the predicate plus ceiling story?
A

Walk through how MaxMessageTermination, TextMentionTermination, and TokenUsageTermination compose with logical operators, and how that replaces ad-hoc lambdas with declarative conditions.

2 more follow-ups an interviewer would ask next. Sign in to reveal them.

Red flags & common mistakes

The phrases that signal junior thinking. Click to expand.

Most common mistake

Relying only on `max_round` and never wiring an `is_termination_msg`. The conversation runs to the ceiling every time, wasting tokens and producing trailing junk turns.

Sign in to see all red flags and common mistakes.

60 second bullets to scan on the way to the call.

  • Signature of an is_termination_msg predicate

  • Where the conventional 'TERMINATE' sentinel comes from

Sign in to unlock the revision sheet.

Primary sources. Browse if you want the original framing.

Similar questions

Same topic, related formats. Practice these next.

4 curated
Next question
Design a sensible migration…
Short answer·Hard