Why AutoGen 0.4 makes TerminationCondition a first class primitive instead of leaving it to convention
Termination as a typed runtime object moves the stop rule from fragile prompt convention into deterministic code the runtime enforces after every turn.
Imagine two kids playing catch and you tell them 'stop when you feel done.' They never feel done. Now imagine you set an egg timer next to them: when it rings, the game ends, no debate. A typed termination condition is the egg timer for agents. Without one, two agents will throw the ball at each other forever, or one keeps saying 'almost there' until your snack budget is gone. With one, the ball stops bouncing exactly when you said it would, even if the kids would have happily kept going. The grown-up running the game holds the clock; the kids do not get to vote on it.
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.
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.
Every multi-agent framework eventually adds a typed termination primitive, because the alternative, relying on the agents to stop themselves, produces the same incident in every production deployment. Two agents loop, a critic rejects forever, a planner-executor pair burns tokens in slow motion. The pattern is universal enough that AutoGen 0.4 hoisted TerminationCondition to a first-class composable type, and other frameworks have converged on equivalent constructs.
The design decision is not just ergonomic. It encodes a separation between the agents (who reason about content) and the runtime (which decides whether the system is allowed to keep running). That separation is the difference between a system you can deploy without a babysitter and a system that needs a human watching the dashboard.
This section walks through why prompt-based termination fails predictably, how composable typed primitives fix it, what the common composition patterns look like in 2026, and how to choose the numeric bounds without starving real work or licensing runaway loops.
Why prompt-based stop rules fail
The intuitive first attempt at termination is a system-prompt instruction: 'stop when the answer is complete.' This fails for three independent reasons, and any production multi-agent run will hit at least one of them.
First, long-context forgetting. By turn 10 of a busy GroupChat, the original system prompt is competing with thousands of tokens of conversational scroll. Models attend less to instructions that appeared 8k tokens ago; the stop rule degrades silently.
Second, subjective completion. 'Complete' is not a well-defined predicate. A researcher agent can always find one more source; a critic can always find one more weakness; a planner can always add one more step. Subjective stop conditions get evaluated by the same model that benefits from continuing.
Third, disagreement licenses continuation. In a two-agent loop, if one agent thinks the work is done and the other does not, the default is to continue. A unanimous-stop requirement is too strict; a majority-stop requirement adds another layer of orchestration. Either way, the prompt cannot enforce the resolution.
These failures are not bugs in any specific model. They are predictable consequences of asking generative output to enforce control flow. The fix is to put control flow in code.
Situations where this technique stops working.
2–4 min · Everything important, quickly.
Real products, models, and research that use this idea.
- AutoGen 0.4's TerminationCondition family (MaxMessageTermination, TextMentionTermination, TokenUsageTermination, ExternalTermination) composed with `|` and `&` operators.
- LangGraph's recursion_limit on compiled graphs serves the equivalent role for graph-shaped agents in 2026 production deployments.
What an interviewer would ask next. Try answering before peeking at the approach.
QHow would you pick the numeric values for MaxMessageTermination and TokenUsageTermination in a new workflow?
Run the happy path five times, take the p95 message count and token spend, multiply by 1.5 for the cap. Refine after a week of production traces. Avoid round-number guesses like 100 and 100k; they encode no actual signal.
Red flags & common mistakes
The phrases that signal junior thinking. Click to expand.
Red flags & common mistakes
The phrases that signal junior thinking. Click to expand.
Relying on prompt instructions like 'stop when you are satisfied' as the only stop signal. Models forget, disagree, or rationalise another round, and the workflow runs until the budget is gone.
60 second bullets to scan on the way to the call.
Why prompt-based stop instructions fail in long multi-agent runs
The three primitive termination types and what each one bounds
Primary sources. Browse if you want the original framing.
Same topic, related formats. Practice these next.